[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tokens priority

The only other alternative I see (without additional context) is something

sentence = literal special_literal literal;
special_literal = {literal} literal | {name} name | ... | ...;

In other words, you create one production that accepts a literal or any


-----Original Message-----
From: Benjamin Ryzman <Benjamin.Ryzman@SOLsoft.Com>
To: Etienne Gagnon <egagnon@sprynet.com>
Cc: sablecc-list@sable.mcgill.ca <sablecc-list@sable.mcgill.ca>
Date: Thursday, April 02, 1998 5:51 AM
Subject: Re: Tokens priority

>Etienne Gagnon wrote:
>> >I know it is possible to use states in order to solve this problem. Is
>> >there any other way (except from the obvious:
>> > sentence =
>> > {case1} litteral name litteral |
>> > {case2} litteral litteral litteral;)
>> Why not eliminate the unwanted alternative from the grammar after the AST
>> has been built?
>Well, even if this solution is elegant in its object oriented way of doing,
>it is not viable for me. My example was just for illustration purpose, the
>real-world problem is much more complex, with tons of various tokens that
>would produce tons and tons of multiple case productions. I think I'll have
>to either simplify the grammar (and lexically parse the contents of the
>in the analyser) or maybe introduce more states.
>Benjamin Ryzman   "Deliver yesterday, code today, think tomorrow."
>Software Engineer, NetPartitioner(TM) design team.
>SOLsoft SA, 4bis rue de la Gare, 92300 Levallois-Perret, France.