[antlr-interest] Newbie grammar question...

Indhu Bharathi indhu.b at s7software.com
Mon Jun 8 06:07:36 PDT 2009


I don't get any exception. BTW, it is good to match the entire 'phrase' as
one token in the lexical analysis itself. Something like:

 

PHRASE      :    ( '0'..'9' | 'A'..'Z' | ' ' | '\t')+ ;

 

and modify stmt to:

 

stmt :    SUBJ_TOK COLON PHRASE NL+ ;

 

Else, you'll end up creating too many tokens (one per each char).

 

Cheers, Indhu

 

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Sylvain, Gregory
[USA]
Sent: Monday, June 08, 2009 6:03 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Newbie grammar question...

 

Hello all,

 

I thought I've done a million times, but that was a while ago and now I
can't get this to work.  Can someone point me in the right direction:

 

 

stmt :    SUBJ_TOK COLON PHRASE+ NL+ ;

 

SUBJ_TOK   :     'SUBJECT' ;

COLON        :     ':' ;

PHRASE      :    ( '0'..'9' | 'A'..'Z' | ' ' | '\t') ;

NL                :    ( '\r' | '\n' ) ;

 

 

I keep getting EarlyExitException on all input when the ANTLR get to the
PHRASE.

 

"SUBJECT: FOO\n" ==> reads SUBJECT_TOK COLON "F" EarlyExitException and
Resync

 

Thanks in advance for your clarifications.

Greg

 

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


More information about the antlr-interest mailing list