And watch what happens. The ')' that it prints is the result of the first set of brackets (if you dont create any actions, it returns the last thing that successfully matched.) It threw the rest away as it couldnt match it.$RD_TRACE = 1; $RD_HINT = 1;
C.condition: booleanexpr | '&&' booleanexpr | '||' booleanexpr booleanexpr: '!' booleanexpr { $return = $item[1] . $item[2]; } | '(' booleanexpr ')' { $return = $item[1] . $item[2] . $item[3]; } | Value_op comparator Value_op { $return = $item[1] . $item[2] . $item[3]; } comparator: '==' | '<' | '>' | '<=' | '>=' | '!=' Value_op: operation | Value Value: String | Number | Float operation: operator plusminus(?) { my $op; $op = ''; if(@{$item[2]}) { $op = $item[2]->[0]; } $return = $item[1] . $op; 1; } plusminus: '+' operator { $return = $item[1] . $item[2]; } | '-' operator { $return = $item[1] . $item[2]; } operator: ('*' Value | '/' Value) | '(' operation ')' | Value
In reply to Re: Parse::RecDescent and mini-language parsing
by castaway
in thread Parse::RecDescent and mini-language parsing
by Flame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |