The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Line numbers with ParseTree

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marty Andrews

Posts: 190
Nickname: wry
Registered: Dec, 2003

Marty Andrews is an agile coach and developer for Thoughtworks Australia
Line numbers with ParseTree Posted: Sep 9, 2008 6:53 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Marty Andrews.
Original Post: Line numbers with ParseTree
Feed Title: Ramblings of the Wry Tradesman
Feed URL: http://www.wrytradesman.com/blog/index.rdf
Feed Description: Marty Andrews talks about the day to day issues he faces as an agile coach on large enterprise applications in Australia.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Marty Andrews
Latest Posts From Ramblings of the Wry Tradesman

Advertisement

I reluctantly moved Roodi over to ParseTree recently because I figured that would make it more accessible to people. My reluctance came from the fact that I was going to lose the line number support the I had in JRuby. Happy days - it turns out I was wrong!

The following bit of code sets up ParseTree so you can parse some code:

parse_tree = ParseTree.new
tree = parse_tree.parse_tree_for_string(ruby_code_as_text, filename)

It turns out that one very small tweak will give me line number support:

parse_tree = ParseTree.new(true)
tree = parse_tree.parse_tree_for_string(ruby_code_as_text, filename)

The addition of that boolean means that ParseTree will now include newline nodes in the tree structure that it gives me. Every newline node includes the line number and the name of the file that it came from. That made the output from Roodi much more useful.

Read: Line numbers with ParseTree

Topic: Roodi on ParseTree instead of JRuby Previous Topic   Next Topic Topic: YouTube Playlists

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use