[DGD]parse_string

Felix A. Croes felix at dworkin.nl
Tue Feb 1 15:10:10 CET 2000


Ludger Merkens <balduin at uni-paderborn.de> wrote:

> Another parse_string example
> I try the following:
>
>     grammar = "\
> whitespace=/[ !-[]+/            \ /* note the [ in the set */
> tag=/<[a-zA-Z]+>/               \
> term =/\\(*[A-Za-z`']+\\)*/     \
> s : term ? _term                \
> s : tag ?  _tag                 \
> ";
>
> if i call parse_string("! <abc>",grammar) i receive
> ({"abc"}) and the function _term is called.
> looks wrong to me.

Token rules, from dgd/doc/parser:

    [set]   a single character in the given set, which is constructed of
            single characters such as `a' and/or character ranges such as
            `a-z'.  `\' may be used to escape the characters `]', `^', `-', `\'

The range `!-[' is perhaps more inclusive than you suspected.

The alternative grammar succeeds because `-' at the beginning or end
of a character set obviously cannot be part of a range, and therefore
is not interpreted as such.

Regards,
Dworkin

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list