From: Minero Aoki Date: 2003-12-12T14:04:01+09:00 Subject: Re: problems with racc: $end token Hi, In mail "Re: problems with racc: $end token" "Luke A. Kanies" wrote: > There is debugging in racc, and using racc -E to embed the parser and then > manually setting @yydebug = true can turn it on. I'm sure there's a > better way. Set @yydebug=true in your "inner" and use racc -g. % cat t.y class MyParser options no_result_var rule program: list list : { [] } | list ITEM { val[0].push val[1]; val[0] } ---- inner def parse @tokens = [ [:ITEM, '1'], [:ITEM, '2'], [:ITEM, '3'] ] @yydebug = true ##### do_parse end def next_token @tokens.shift end ---- footer p MyParser.new.parse ~/tmp % racc -ot.rb t.y ~/tmp % ruby t.rb ["1", "2", "3"] ~/tmp % racc -g -ot.rb t.y ~/tmp % ruby t.rb reduce --> list [ (list []) ] goto 2 [ 0 2 ] read :ITEM(ITEM) "1" shift ITEM (snip) > Also, you must set 'return' manually, although it can be any type of > variable. Try this: class MyParser options no_result_var #### this line rule .... Regards, Minero Aoki