[antlr-interest] newbie problems

Gevik Babakhani gevik at xs4all.nl
Sat Jun 23 05:46:59 PDT 2007


Hi,

 

Here is a fix for your grammar. These things are well explained in the ANTLR
book.

 

grammar Test; 

 

site    :  page+

            ;

 

page    :            'PAGE' ID

            ;

 

ID         :           LETTER+

            ;

 

TEXT    :    LETTER ( LETTER )*

            ;

    

LETTER            :           'a'..'z'|'A'..'Z' 

            ;

 

    

WS       :           (' ' | '\t' | '\r' | '\n')+ {$channel=HIDDEN;}

            ;

 

 

  _____  

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Anders Hessellund
Sent: Saturday, June 23, 2007 12:50 PM
To: antlr
Subject: [antlr-interest] newbie problems

 

Hi,

I am sorry about the newbie question but neither google nor this list seems
to have any obvious answers to my question :)

I have just started with antlr by defining this little grammar:

grammar Web;

site    :    page+ 
    ;

page    :    'PAGE' ID
    ;

ID    :    LETTER+
    ;

TEXT    :    LETTER ( LETTER | WS )*
    ;
    
LETTER    :    'a'..'z'|'A'..'Z' 
    ;

NEWLINE    :    '\r'? '\n'
    ;

WS    :    (' ' | '\t' | '\n' | '\r' )+ { skip(); }
    ;


Then I generate my lexer and parser tools and feed them the follow input
file 

 

PAGE helloWorld


I get the following strange error. Could someone please explain why?? 

line 0:-1 required (...)+ loop did not match anything at input '<EOF>' 



-- Anders 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070623/0c61b9b0/attachment.html 


More information about the antlr-interest mailing list