Open wentaoshang opened 9 years ago
Have you tried:
%lex
%%
"-"?[0-9]+ return 'INT'
/lex
%start integer
%%
integer
: INT <<EOF>> { return Number($1); }
;
From the documentation on lexical analysis:
[T]here is ... one minor inconvenience compared to Flex patterns, namely exact string patterns must be placed in quotes.
Does this solve your problem?
Yes, this one works. But it is equally annoying as writing the square brackets.
It is a little surprising that patterns like
a?[0-9]+
works fine for jison without the need to quote. The problem only occurs with a certain set of punctuators like -. That's why I suspect there is bug (or a feature?)
Found this error when I tried to write a rule (in Flex/Bison format) to parse integers (both positive and negative):
I got an error when I tried to parse this file:
Currently I have to use "[-]?[0-9]+" to walk around this issue.
The Jison version I'm using is 0.4.15