[antlr-interest] How to recognize a String

Jim Idle jimi at temporal-wave.com
Fri Sep 9 16:31:15 PDT 2011


Use the debugger, not the interpreter.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of The Researcher
> Sent: Friday, September 09, 2011 2:46 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] How to recognize a String
>
> Hi Gabriel,
>
> It would help if you could post your entire grammar and the exact error
> message here.
>
> Also, don't you mean
>
> LPAREN: '(";
> RPAREN: ')';
>
> Don't worry we have all been there.
>
> Thanks, Eric
>
>
>
>
> On Fri, Sep 9, 2011 at 5:34 PM, Gabriel Miro <gsmiro at gmail.com> wrote:
>
> > Hello all!
> > I'm new to ANTLR and I'm trying to build a simple grammar that can
> > recognize strings like ('val'). I'm using ANTLRWORKS and it generates
> > a rule for string values with single quotes and I mapped the
> > parenthesis to lexer
> > tokens:
> >
> > RPAREN:'(';
> > LPAREN:')';
> > ...
> > STRING
> >    :  '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\''
> >    ;
> >
> >
> > Now, if I try to write the following:
> >
> > rule : RPAREN STRING
> >
> > and evaluate the input ('blah', I get an error in the interpreter. I
> > have no idea why, but I'm thinking the STRING rule is evaluating EOF
> > and returning an error.
> >
> > Any ideas on how to make this work?
> >
> > Regards,
> > Gabriel Miró
> > ANTLR Newbie
> >
> > 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