Hi Nigel, I changed the matching order according to your suggestion and it works!
Thanks a lot. Regards, Thiel Op 13-11-2012 1:31, Nigel Thorne schreef: > It successfully matching integer, then get stuck before it gets to try > float. Put float first, and it will try to match that.. if it fails > (no decimal point) it will then move onto trying integer for > intergers. > > > --- > "No man is an island... except Philip" > > > On Tue, Nov 13, 2012 at 10:42 AM, Thiel Chang <[email protected]> wrote: >> Hi, >> >> I am trying to parse the next inputs: >> >> pp Parser.new.float.parse_with_debug('12.3') >> Output: {:float=>"12.3"@0} >> >> pp Parser.new.factor.parse_with_debug('12.3') >> Output: Don't know what to do with ".3" at line 1 char 3. >> >> with the following rules: >> >> rule(:factor) { ( space? >> lpar.as(:lpar) >> space? >> aex.as(:aex) >> >> space? >> >> rpar.as(:rpar) ) | integer | identifier | float | >> epsilon } >> >> rule(:float) { >> ( >> str('-').maybe >> ( >> ( match('[1-9]') >> digit.repeat) >> ) >> ( str('.') >> digit.repeat(1) ) >> ).as(:float) >> } >> >> Why does the parse statement: >> Parser.new.factor.parse_with_debug('12.3') gives a different result ? >> >> Can anyone tell me why? >> >> Thanks in advance, >> >> Thiel >> >> >>
