Re: [treetop] Build AST based on tokens (#40)

56 views
Skip to first unread message

Clifford Heath

unread,
Sep 12, 2015, 11:40:54 PM9/12/15
to nathansobo/treetop, treetop-dev@googlegroups.com Development
Nathan orphaned Treetop shortly after announcing it. I am maintainer.
The official support list is at <mailto:treet...@googlegroups.com>.

As you can see on my recent answer on Stack Overflow, you need to follow
keywords with negative look-ahead to avoid this problem. See my answer
here:

<http://stackoverflow.com/questions/32373050/treetop-boolean-logic-operations/32490728#32490728>

Clifford Heath.

> On 13 Sep 2015, at 1:02 pm, Sergey Potapov <notifi...@github.com> wrote:
>
> Here is an example with german words bahn and bahnhof
>
> grammar:
>
> grammar Test
>
> rule phrase
> word space word
>
> end
>
>
> rule word
>
> 'bahn' / 'bahnhof'
>
>
> end
>
>
> rule space
>
> ' '+
>
>
> end
> end
> ruby code:
>
> require 'treetop'
>
>
>
> Treetop.load 'test'
>
> test_parser
> = TestParser.new
>
>
> p test_parser.parse(
> "bahn bahnhof"
> )
> puts test_parser.failure_reason
>
> Output:
>
> nil
> Expected something other than <END OF INPUT> at line 1, column 10 (byte 10) after
>
> If I change word rule to:
>
> rule word
>
> 'bahnhof' / 'bahn'
>
>
> end
> it will work.
>
> —
> Reply to this email directly or view it on GitHub.
>

Reply all
Reply to author
Forward
0 new messages