Using the token "~ []" with lexical states

I am trying to write a javacc based parser that includes the following tokens / lexical states:

TOKEN : { <"{"> : FIRST } <FIRST, DEFAULT> TOKEN : { <"~[]"> : DEFAULT } 

Attempting to parse "{;}" results in a lexical error

Found: ";" (59), after: ""

which I do not understand. I can avoid the error in two ways:

  • replacing the pattern "~ []" with explicit ";" literal
  • removing the first lexical state of FIRST

However, I really need both of them (as you can guess, above all this is just a minimal test case), so this is not suitable for solving the problem. Any idea what is wrong with the token definition above?

Thanks!

+5
source share
1 answer

Too many quotes. Do you want to

 TOKEN : { <"{"> : FIRST } <FIRST, DEFAULT> TOKEN : { <~[]> : DEFAULT } 
+1
source

All Articles