[antlr-interest] distinguish "3 + 4" from "3 +4"

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Wed Oct 5 13:11:20 PDT 2011


Yes, I believe that does work, for some reason I was thinking in terms 
of strictly k=1... don't know where my brain's been lately (other than 
dredging policy analysis in education stuff)

Sam

On 05/10/2011 14:39, Douglas Godfrey wrote:
> define a Number lexer rule that parses signed numbers with no intervening
> whitespace between the "+" or "-" and the digits.
>
> Then the parser will receive Number Number instead of  Number Plus Number.
>
> The Plus rule will succeed any time there is whitespace between the sign
> and the number.
>
>
> On 10/5/11 7:14 AM, "Andreas Liebig"<liebigandreas at yahoo.com>  wrote:
>
>> Hello,
>> I am not very experienced with ANTLR, and I would like to ask for some
>> ideas how to solve this task:
>>
>> I have to distinguish input streams like
>> "3 + 4" (parsed as three tokens NUMBER PLUS NUMBER) from
>> "3 +4" (parsed as NUMBER NUMBER, because the + is part of the number +4).
>>
>> I would like to ignore whitespace in general using the "$channel=HIDDEN;"
>> syntax. But only in this situation whitespace does matter.
>> Can you guide me to a good explanation of a possible solution?
>>
>> Thanks
>> Andreas
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list