Trying to follow the tutorial from http://thingsaaronmade.com/blog/a-quick-intro-to-writing-a-parser-using-treetop.html
I get the following error.
spundun$ bundle exec pry
[1] pry(main)> require './parser'
=> true
[2] pry(main)> Parser.parse('(this "is" a test( 1 2.0 3))')
Exception: Parse error at offset: 0
from /Users/spundun/Documents/code_samples/s_expression_parser/parser.rb:35:in `parse'
[3] pry(main)>
The error goes away if I move the body
rule in sexp_parser.treetop
from the bottom to the top. (Making it the first rule).
spundun$ bundle exec pry
[1] pry(main)> require './parser'
=> true
[2] pry(main)> Parser.parse('(this "is" a test( 1 2.0 3))')
=> [[:this, "is", :a, :test, [1, 2.0, 3]]]
[3] pry(main)> quit