[antlr-interest] whitespaces in middle of rule
Terence Parr
parrt at jguru.com
Wed Jan 22 19:46:07 PST 2003
On Wednesday, January 22, 2003, at 06:22 PM, William Lam
<xeenman at yahoo.com> wrote:
> Sorry for this newbie question, but I wish to parse a grammar
> such as a Java import statement i.e.
>
> import aaaa.bbbb.cccc.*;
>
> so I set up a grammar similar to this
>
> import_statement:
> "import" IDENT (DOT (IDENT | STAR))* SEMI
> ;
>
> The problem is that the rule will validate statments filled with
> spaces, such as this
>
> import aaaa . bbbb . cccc . *;
>
> How do I make sure my import statements do not have any spaces? I
> notice that the example under antlr/examples/java exhibit this
> problem.
Is it really illegal in Java?
Anyway, move it into the lexer if you need to. Might be a
context-sensitive problem though then matching ID.
Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list