[DGD] Newbie question regarding parse_string()
Troels Therkelsen
troels at 2-10.org
Mon Oct 22 19:11:34 CEST 2001
Hi all,
I have the following grammar:
word = /[a-zA-Z]+/
path = /[^ :]+/
Grammar: '[' word ']'
With input string "[foo]" it fails (returns nil). If I remove the path
token from the grammar, it works and returns ({ "[", "foo", "]" }) as
expected.
It's probably my lacking an understanding of how the internals work, but
I thought the parser would only try to match against a token if your
production rules mention it?
I'm guessing it's because path can match '[', 'foo' and ']' (which is
longer than the nothing the word token will match, and the docs say
the longest regex will be matched) so the parser thinks the string
starts with a path token, which means when the production rule asks
for '[' it will already have been taken by the path token.
I'd like for someone with more insights to confirm whether this guess is
true or not, and possibly come up with a solution (path HAS to contain
'[' and ']').
Thanks :-)
Regards,
/Troels Therkelsen
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list