in reply to Re^2: To make the Model WORK
in thread To make the Model WORK
Real returned values might be '0', as well. That would fail.
Nope. '0' will not fail a production. Only undef.
I stand corrected:
use Parse::RecDescent; my $parser; $parser = Parse::RecDescent->new(q` test: { $return = 1 } `); print($parser->test('') ? 'ok' : 'fail', "\n"); # ok $parser = Parse::RecDescent->new(q` test: { $return = 0 } `); print($parser->test('') ? 'ok' : 'fail', "\n"); # fail $parser = Parse::RecDescent->new(q` test: { $return = '0' } `); print($parser->test('') ? 'ok' : 'fail', "\n"); # fail $parser = Parse::RecDescent->new(q` test: { $return = undef } `); print($parser->test('') ? 'ok' : 'fail', "\n"); # fail $parser = Parse::RecDescent->new(q` test: /\d+/ `); print($parser->test('1') ? 'ok' : 'fail', "\n"); # ok print($parser->test('0') ? 'ok' : 'fail', "\n"); # fail
I never got into that situation, because I'd be returning
[ ident => ident ]
or
[ literal => literal ]
or
[ '*' => expr, expr ]
or
[ '/' => expr, expr ]
or
...
|
|---|