Note: Before I start, I have noticed your other suggestion, however this is based off of this code.
Well, I've modified your suggestion a little, and assuming I understood your suggestion's intent, I seem to have screwed it up somewhere along the line, because it still does not handle ( ) properly, but I can't see why. This is what I now have:
use Parse::RecDescent; use Data::Dumper; use strict; use warnings; $::RD_TRACE = 1; my $grammar = q~ expression: <leftop: term termop term> eod termop: /and/i | /xor/i | /or/i term: '(' <commit> expression ')' | condition condition: element comparison element element: '<' <commit> /-?\w+/ '>' | /\d+/ comparison: /=[><]=/ <commit> <error: Unable to match comparison> | /=?[><]=?/ | '=' | '!=' eod: /^\Z/ ~; my $parser = new Parse::RecDescent($grammar) or die; #defined($parser->RecTest('h =>= h')) or die; my $test = '(<MONTH> => <DAY>)'; # or (<MONTH> = <MARCH> and <DAY> = < +TUESDAY>)'; print Dumper($parser->expression($test));
I repeatedly get "$VAR1 = undef;" in reply, as well as enough debugging info to scroll off my screen (unfortunately I can't capture it into a file either, Parse::RecDescent overrides any re-declarations on STDERR, and I can't use "perl language.pl | more" or any other similar methods since those don't want to capture the error messages...) Anyone see what I'm missing, it's probably obvious, but I've been staring at it for 4 hours now without anything more constructive happening than the condensing of a few rules in the grammar declaration.
My code doesn't have bugs, it just develops random features.
Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)
In reply to Re: •Re: Parse::RecDescent and mini-language parsing
by Flame
in thread Parse::RecDescent and mini-language parsing
by Flame
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |