Reputation: 41
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
Upvotes: 0
Views: 826
Reputation: 16221
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>
}
Upvotes: 1