27
Jan
12

some treetop debug tips



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:

  1. You can try a specific rule by writing this:

    tree = parser.parse(content,:root => "rule_name")
  2. 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.

Advertisements

0 Responses to “some treetop debug tips”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 221,294 hits

%d bloggers like this: