Handling errors

7 views
Skip to first unread message

David Koontz

unread,
Mar 22, 2008, 5:11:14 PM3/22/08
to Treetop Development
I have a grammar that parses ok, but when I run into invalid input all
I get back from parse is a nil. Is there a way to get back a node
that I can check the errors on or does this need to be handled
internally somehow.

As an example, I'm trying to report an error for this situation

rule foo
"foo"
end

rule bar
"bar"
end

@parser.parse("foo bar") <-- how do I report the error in having "bar"
after "foo"?

David Koontz

Nathan Sobo

unread,
Mar 22, 2008, 11:20:36 PM3/22/08
to treet...@googlegroups.com
You can send #failure_reason to the parser and get a good idea what might have caused it.
Reply all
Reply to author
Forward
0 new messages