[antlr-interest] Newline not recognized

Thomas Brandon tbrandonau at gmail.com
Sun Jan 13 23:20:27 PST 2008


Can't tell exactly what's going on without seeing the full grammar.
Do you have a lexer rule that matches newlines? Tokens and literals are not
interchangeable. i.e. given:
literalNL: '\n';
NL: '\n';
literalNL won't work as all newlines will have been matched by the NL rule
while the literal '\n' will generate a new lexer rule with a different token
type.

Tom.
On 1/14/08, Cory Isaacson <cory.isaacson at compuflex.com> wrote:
>
>  I have a rule like this:
>
>
>
> r : MYSTARTTOKEN '\n' NEXTTOKEN ;
>
>
>
> When I parse it doesn't see the '\n' char.
>
>
>
> If I put the '\n' into to Lexer rule like this:
>
>
>
> NEXTTOKEN : '\n' 'xyz' ;
>
>
>
> It works fine, but this won't meet my needs as I need to get the text of
> NEXTTOKEN (without the newline).
>
>
>
> Any idea what is wrong in what I'm doing?
>
>
>
> Cory
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080114/3fa57630/attachment.html 


More information about the antlr-interest mailing list