[DGD] Help with parse_string() grammar

Felix A. Croes felix at dworkin.nl
Mon Apr 10 13:46:01 CEST 2006


=?ISO-8859-1?Q?Petter_Nystr=F6m?= <md1pette at mdstud.chalmers.se> wrote:

> One thing though, the parser matches tokens in the string from right to 
> left. For example, if I have the string, "A &1little&2 girl." and use LPC 
> function calls when the &c tokens are matched, the &2 token will be 
> matched before the &1 one. Since I want to build a state in the parser 
> object while parsing, that can decide how the remainder of the string will 
> be parsed, I would like if the matches were made in left to right order? 
> This seems tricky to me, but I have to ask. Is there a way one could write 
> the grammar rules to force matching to be made in the other direction?

Your grammar has the rule:

    Output: Output Elem

Changing that to:

    Output: Elem Output

should do the trick.

Regards,
Dworkin



More information about the DGD mailing list