diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-11-02 04:53:42 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-11-02 04:53:42 +0000 |
commit | 5986bee212e6e15328b6b9fc24072c40864b35d1 (patch) | |
tree | 912d24ac20372efc5fc4d645bf7f9dfe052a4a1e /utils | |
parent | 0f1d0f4629a98b130322f088db26e38c689929f6 (diff) |
Fewer errors. CLI script wrapper still doesn't work though
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@460 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'utils')
-rw-r--r-- | utils/cli/ledgersmb_cli.pl | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/utils/cli/ledgersmb_cli.pl b/utils/cli/ledgersmb_cli.pl index 4652c2d5..995682b1 100644 --- a/utils/cli/ledgersmb_cli.pl +++ b/utils/cli/ledgersmb_cli.pl @@ -39,10 +39,10 @@ $syntax = << '_END_SYNTAX_'; expression : NUMBER OP expression { return main::expression(@item) } - | key OP expression + | KEY OP expression { return main::expression(@item) } - | INTEGER - | VARIABLE + | NUMBER + | KEY assign_instruction : KEY "=" expression { ${main::stackref}->{$item{key}} = $item{expression} } @@ -82,10 +82,19 @@ $syntax = << '_END_SYNTAX_'; startrule : instruction _END_SYNTAX_ - + $::RD_HINT = 1; + $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error + $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c.` my $stackref; my @loopstack; +sub expression { + shift; + my ($lhs,$op,$rhs) = @_; + $lhs = $VARIABLE{$lhs} if $lhs=~/[^-+0-9]/; + return eval "$lhs $op $rhs"; +} + sub call { my ($call, $argstr) = @_; $argstr =~ s/form/\\\%\$form/; @@ -130,10 +139,10 @@ sub load_mod { eval { require "$mod.pm"; }; } -my $scriptparse = new Parse::RecDescent($grammer); +my $scriptparse = new Parse::RecDescent($syntax); while ($line = <>){ - $scriptparse->instruction($line); + $scriptparse->startrule($line); } delete $form->{password}; |