5

I'm trying to write a javacc-based parser that involves the following tokens / lexical states:

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

Trying to parse "{;}" results in the lexical error

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

which I don't understand. I can avoid the error in two ways:

  • by replacing the "~[]" pattern by an explicit ";" literal
  • by removing the FIRST lexical state

However, I do need both of these (as you can guess, the above is just a minimal test case), so this isn't a suitable workaround. Any idea what is wrong with the above token definition ?

Thanks !

1 Answers1

1

Too many quote marks. What you want is

TOKEN :
{
  <"{"> : FIRST
}
<FIRST, DEFAULT> TOKEN :
{
  <~[]> : DEFAULT
}
Theodore Norvell
  • 15,366
  • 6
  • 31
  • 45