Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. node_extensions.rb parser.rb tranlan.treetop
  2.  
  3. # node_extensions.rb
  4. module TranLan
  5.  
  6. end
  7.  
  8. # parser.rb
  9. require 'treetop'
  10.  
  11. # Find out what our base path is
  12. base_path = File.expand_path(File.dirname(__FILE__))
  13.  
  14. # Load our custom syntax node classes so the parser can use them
  15. require File.join(base_path, 'node_extensions.rb')
  16.  
  17. class Parser
  18. base_path = File.expand_path(File.dirname(__FILE__))
  19. Treetop.load(File.join(base_path, 'tranlan_parser.treetop'))
  20. @@parser = SexpParser.new
  21.  
  22. def self.parse(data)
  23. tree = @@parser.parse(data)
  24. raise Exception, "Parser error at offset: #{@@parser.index}" if tree.nil?
  25. tree
  26. end
  27. end
  28.  
  29. # tranlan.treetop
  30. grammar TranLan
  31.  
  32. end
  33.  
  34. /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)
  35. from /Users/maca/.rvm/gems/ruby-2.1.4/gems/treetop-1.5.3/lib/treetop/compiler/grammar_compiler.rb:37:in `open'
  36. from /Users/maca/.rvm/gems/ruby-2.1.4/gems/treetop-1.5.3/lib/treetop/compiler/grammar_compiler.rb:37:in `load'
  37. from parser.rb:17:in `<class:Parser>'
  38. from parser.rb:10:in `<main>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement