[antlr-interest] Diference bettew Tokens and Lexical Rules

Victor Giordano power_giordo at yahoo.com.ar
Wed Aug 11 21:00:18 PDT 2010


Hi John!! Thanks!
Fine here, struggling with antlr a little jejeje. Well nothing to worry 
about.
You trully have a teacher spirit, the question was fulfil!.
So that's is't, two ways to do the same.

Thanks you again!!.
Gretting.
Víctor.

(Today it's my birthday, by not the way jejej :P).



El 11/08/2010 11:37 p.m., John B. Brodie escribió:
> Greetings!
>
> On Wed, 2010-08-11 at 22:57 -0300, Victor Giordano wrote:
>> Hi there!!. How you doing guys? Hope good!.
>
> I am fine, I hope you are too!
>
>> A have another question about tokens and lexical rules, i really don't
>> get the idea...
>> For example, assume we have this:
>>
>> 1)
>> tokens
>> {
>> 	PLUS= '+';
>> }
>>
>> 2) PLUS : '+';
>>
>> and then a rule
>> expr: INT (PLUS INT)*;
>>
>> so... if a use one of another is exactly the same. The parse tree is the
>> same, and the generated AST is also the same.
>> Can you help me, and try to explain it to me. I read the book, but i
>> don't understand.
>>
>
> As you have discovered, in this instance, ANTLR has 2 ways to express
> the same concept.
>
> There is, I believe, nothing else to explain here. You have correctly
> analyzed that specifying a string value in the tokens{} block is
> equivalent to specifying a lexical rule. Not a problem.
>
> Perhaps I have mis-understood your question, please try to re-state your
> question if you are still confused by these two equivalent
> meta-syntactic constructs.
>
> Hope this helps...
>     -jbb
>
>
>
>



More information about the antlr-interest mailing list