Skip to content

Instantly share code, notes, and snippets.

@xxx
Created January 16, 2011 23:21
Show Gist options
  • Save xxx/782256 to your computer and use it in GitHub Desktop.
Save xxx/782256 to your computer and use it in GitHub Desktop.
parser = File.open(outfile.path) { |f| LPC::Parser.new(f) }
return_val = parser.translation_unit
tokens = parser.input
tree = return_val.tree
# Everything is OK up to here.
node_stream = ANTLR3::CommonTreeNodeStream.new(tree)
optimizations = LPCTreeRewrites::TreeParser.new(node_stream)
tree = optimizations.downup(tree, false)
$ ruby LPCTreeRewrites.rb --lexer-name "LPC::Lexer" --parser-name "LPC::Parser" --parser-rule "translation_unit" < foobar.cpp
/usr/home/pope/.rvm/gems/ruby-1.8.7-p248/gems/antlr3-1.8.8/lib/antlr3/main.rb:576:in `send': nil is not a symbol (TypeError)
from /usr/home/pope/.rvm/gems/ruby-1.8.7-p248/gems/antlr3-1.8.8/lib/antlr3/main.rb:576:in `recognize'
from /usr/home/pope/.rvm/gems/ruby-1.8.7-p248/gems/antlr3-1.8.8/lib/antlr3/main.rb:162:in `execute'
from /usr/home/pope/.rvm/gems/ruby-1.8.7-p248/gems/antlr3-1.8.8/lib/antlr3/tree.rb:108:in `main'
from LPCTreeRewrites.rb:297
from LPCTreeRewrites.rb:297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment