Treetop seems pretty nice, but information on it’s usage is kind of scattered all over internet
. Here are a few tips that I used to debug grammars:
- You can try a specific rule by writing this:
tree = parser.parse(content,:root => "rule_name")
- I usually have my code structured like this, to get some info about where the parser chokes:
if tree puts "succesful" else puts "unsuccesful at #{parser.index}" puts parser.failure_reason end
Hope this helps you as much as it helped me.
0 Responses to “some treetop debug tips”