[antlr-interest] Lexer rule for INTEGER and COMMA_INTEGER

Bernard Kaiflin bkaiflin.ruby at gmail.com
Fri Nov 9 23:18:35 PST 2012


There is no ambiguity since SPACE_COMMA is defined before WS and will
consume the space and the comma before the 2 in a single token. I had
suppressed the full trace to shorten my reply. But if you cut and paste the
grammar and the example input and run it on your machine, with the v3.4
solution as is, you will see how the lexer interprets the input, here for
<3 ,4>. Unless unknown incompatibility problem, you should see this :

rule INT  `3`
rule element found an atom : <2>
1b rule list chose element <2>
rule SPACE_COMMA ` ,`
rule INT  `4`
rule element found an atom : <3>
1c rule list chose element <3>
rule SPACE_COMMA ` ,`
rule WS
rule INT  `5`
rule element found an atom : <4>
1c rule list chose element <4>


2012/11/10 Zhaohui Yang <yezonghui at gmail.com>

> The main ambiguity here is that a sequence like "1  ,2" can either by
> recognized as a comma_integer (INT WS COMMA INT) or a list
> (comma_integer=INT, seperator=SPACE_COMMA, comma_integer=INT).
>
>


More information about the antlr-interest mailing list