Hi what would be appropriate to recognize string in a lex.
I have already tried
enter code here
import java_cup.runtime.*;
%%
%cup
%line
NUM = [0-9]
ID = [a-zA-Z]
Pun= [:=;#@$^~]
WhiteSpace = [ \t\r\n\f]
SDQuo = [\"]
%%
({SDQuo}+) ({ID}|{NUM})* ({SDQuo}+) { return new Symbol(sym.STR, new String(yytext()));}
but the macro fail to be recognized. The error message that I kept getting is: Processing first section -- user code. Processing second section -- JLex declarations. Processing third section -- lexical rules. Creating NFA machine representation. Error: Parse error at line 39. Description: Missing brace at start of lexical action. Parse error.
Loose the
=
signs in the definitions ofNUM
etc. and don't place them between%%
. Instead place the last rule between%%
.