I don't want to post the entire code because it is unnecessary. In fact I don't have any problems with the parser I have written. The grammar works fine and my evals all return what I have asked them to. All I want to know/do is read in a file and parse it. I'm having trouble understanding if this is in fact how Parse::RecDescent could potentially be used.
Here is part of the code:use strict; use warnings; use Parse::RecDescent; $::RD_ERRORS = 1; $::RD_WARN = 1; $::RD_HINT = 1; my $grammar = q{ identifier : /[a-z]\w+/ binops : '+' | '-' | '/' | '*' | '%' | '**' lbinops: '!' | '<' | '>' | '>='| '<='| '&&'| '||' | '==' integer: /-\d+/ {print "hello $item[-1]" if $::debugging;} number : /(\d+|\d*\.\d+)/ {print "hello $item[-1]" if $::debuggin +g;} }; #evals: these will evaluate to "1" and print #print "valid number\n" if $parser->number(2); #print "valid integer\n" if $parser->integer(-2);
In reply to Re^2: Parsing and Translation pt.2
by speedyshady
in thread Parsing and Translation pt.2
by speedyshady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |