why "abc" / "abcd" doesn't match "abcd" ???

13 views
Skip to first unread message

Iñaki Baz Castillo

unread,
Mar 19, 2008, 6:20:59 AM3/19/08
to treet...@googlegroups.com
Hi, I'm very annoyed, why the following rule doesn't match "abcd"?

rule request
'abc' / 'abcd'
end


I've discovered that I must use:

rule request
'abcd' / 'abc'
end

This is: the longest match first.

Please, any reason for this? is it pointed somewhere in the doc?

Thanks a lot.

--
Iñaki Baz Castillo
<i...@aliax.net>

Martin Gamsjaeger

unread,
Mar 19, 2008, 10:40:59 AM3/19/08
to treet...@googlegroups.com
Hi Iñaki,

Taken from treetop website:

Parsers attempt to match ordered choices in left-to-right order, and
stop after the first successful match.

"foobar" / "foo" / "bar"

Note that if "foo" in the above expression came first, "foobar" would
never be matched.

cheers
Martin

Iñaki Baz Castillo

unread,
Mar 19, 2008, 10:51:01 AM3/19/08
to treet...@googlegroups.com
2008/3/19, Martin Gamsjaeger <gams...@gmail.com>:

> Hi Iñaki,
>
> Taken from treetop website:
>
> Parsers attempt to match ordered choices in left-to-right order, and
> stop after the first successful match.
>
> "foobar" / "foo" / "bar"
>
> Note that if "foo" in the above expression came first, "foobar" would
> never be matched.

Opss, nice point. Thanks a lot, it's clear now.

Reply all
Reply to author
Forward
0 new messages