[antlr-interest] Ident with ending In or Out word

Kirby Bohling kirby.bohling at gmail.com
Fri Feb 11 07:39:04 PST 2011


On Fri, Feb 11, 2011 at 9:17 AM, Roohul <roohul17 at yahoo.com> wrote:
> Sorry for that..
>
> when i use only letters (a..z | A..Z) in the variables and connectors it give an error while creating an AST that "no viable alternative at input 'real'" and when creating variables with digits the grammar do not compile at all and give the following error.
> "The following token definitions can never be matched because prior tokens match the same  input: Alpha"
>
> I hope that it is more elaboration..
>

I would try moving some of that to real lexer items.  You are using
generated tokens, which depending on where they go, 'real', would be
matched by the rule for ID, and there would be no way to generate
that.  I don't know where they end up, but I do remember it being
recommended to avoid them until you have more experience.  Given the
error, I think that is what is happening here.  Look at the sample
grammars and how they handle keywords.

My guess is that you are trying to do too much in the lexer, you can
detect a lot of this at a much later state in the parser/analysis
phase.  But that is just parroting common advise on this list.

Kirby



> Regards
>
> Roohul
>
>
>
>
> --- On Fri, 2/11/11, Bart Kiers <bkiers at gmail.com> wrote:
>
> From: Bart Kiers <bkiers at gmail.com>
> Subject: Re: [antlr-interest] Ident with ending In or Out word
> To: "Roohul" <roohul17 at yahoo.com>
> Cc: "ANTLR" <antlr-interest at antlr.org>
> Date: Friday, February 11, 2011, 5:30 AM
>
> On Fri, Feb 11, 2011 at 2:27 PM, Roohul <roohul17 at yahoo.com> wrote:
>
> Hi,
> This is my sample grammar.. this did not work.. another thing is
> that my variables and connectors both can have digits so I created Alpha
>  : LETTER (LETTER | DIGIT)*; for this but it also give an error.
>
>
> The problem descriptions "did not work" and "also give an error" do not tell much. Care to elaborate?
>
> Bart.
>
>
>
>
>
>
> 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