From: Young Tae Kim Date: 2009-03-10T08:36:46+09:00 Subject: Re: Treetop Parser whitespace Clifford Heath wrote: > Young tae Kim wrote: >> I can't understand why the following test fails. >> Could you tell me why? Thanks, in advance. > > It works for me. What version of Treetop and Polyglot > are you using. Can you please tell us what is printed > by "puts parser.failure_reason"? > > Clifford Heath. I revised my example like this but it doesn't work as well. # in arithmetic.treetop grammar Arithmetic rule num [1-9] [0-9]* { def value text_value end } end rule space [ \t\n\r]+ { def value text_value end } end end # in test_parser.rb require "rubygems" require "treetop" require "arithmetic" parser = ArithmeticParser.new p parser.parse("123") p parser.parse(" \n\t\r") puts parser.failure_reason # the execution result $ ruby test_parser.rb SyntaxNode+Num1+Num0 offset=0, "123" (value): SyntaxNode offset=0, "1" SyntaxNode offset=1, "23": SyntaxNode offset=1, "2" SyntaxNode offset=2, "3" nil nil -- Posted via http://www.ruby-forum.com/.