0

I need to convert the following to javacc from EBNF, I have tried various methods however I am getting an error.

EBNF: code ::== [\x20 - \x7E]

How would this be converted ?

Thanks in advance

tas
  • 41
  • 1
  • 6

1 Answers1

1

JavaCC supports character ranges. E.g. [" "-"~"] It also supports Unicode escapes as in Java, e.g., ["\u0020"-"\u007E"].

These ranges can be used in the specification of the token manager. Note that the three rules outlined in Question 3.3 of the FAQ apply. So if you have

TOKEN: {
    <LETTER : ["a"-"z","A"-"Z"] >
|
    <PRINTABLE : [" "-"~"] >
}

then in the parser you will want

void Printable() {
    <LETTER> | <PRINTABLE>
}
Theodore Norvell
  • 15,366
  • 6
  • 31
  • 45
  • Thanks! So if I give the following as a grammar in javacc it is the same as ["/u0020" -"/u007E"] ? Since wen i use the later i am geting s javacc compile error – tas Apr 19 '14 at 20:33
  • Not quite. `< PRINTABLE : [" "-"~"] >` is the same as `< PRINTABLE : ["\u0020"-"\u007E"] >`. – Theodore Norvell Apr 20 '14 at 12:43