Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- node_extensions.rb parser.rb tranlan.treetop
- # node_extensions.rb
- module TranLan
- end
- # parser.rb
- require 'treetop'
- # Find out what our base path is
- base_path = File.expand_path(File.dirname(__FILE__))
- # Load our custom syntax node classes so the parser can use them
- require File.join(base_path, 'node_extensions.rb')
- class Parser
- base_path = File.expand_path(File.dirname(__FILE__))
- Treetop.load(File.join(base_path, 'tranlan_parser.treetop'))
- @@parser = SexpParser.new
- def self.parse(data)
- tree = @@parser.parse(data)
- raise Exception, "Parser error at offset: #{@@parser.index}" if tree.nil?
- tree
- end
- end
- # tranlan.treetop
- grammar TranLan
- end
- /Users/maca/.rvm/gems/ruby-2.1.4/gems/treetop-1.5.3/lib/treetop/compiler/grammar_compiler.rb:37:in `initialize': No such file or directory @ rb_sysopen - /Users/maca/devel/playground/treetop-grammar/tranlan_parser.treetop (Errno::ENOENT)
- from /Users/maca/.rvm/gems/ruby-2.1.4/gems/treetop-1.5.3/lib/treetop/compiler/grammar_compiler.rb:37:in `open'
- from /Users/maca/.rvm/gems/ruby-2.1.4/gems/treetop-1.5.3/lib/treetop/compiler/grammar_compiler.rb:37:in `load'
- from parser.rb:17:in `<class:Parser>'
- from parser.rb:10:in `<main>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement