[DGD] Working with parse_string()

Felix A. Croes felix at dworkin.nl
Fri Jul 24 00:48:13 CEST 2009


Dread Quixadhal <quixadhal at chartermi.net> wrote:

>[...]
> If I remember correctly, parse_string() can return all matches as an
> array(?)  If so, you could then walk each result to see if it's an actual
> functional match for the context in which it's being applied.

Yes, you can instruct parse_string() to return multiple alternate
parse trees.

However, at this point I think it may be best to handle this problem in
LPC.  At the grammar level, it's always going to look as "give word word
word word word..." without a grammatical way to determine where OBJI
ends and where LIV starts (unless you can determine case at the token
level).  So I'd change the grammar to

    give: 'give' obji_to_liv
    obji_to_liv: words		? scan_obji_liv
    words: words word
    words:

and use scan_obji_liv() to scan for OBJI from left to right, and LIV
from right to left, and see how far you get with either.

Regards,
Felix Croes



More information about the DGD mailing list