summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-02 04:53:42 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-02 04:53:42 +0000
commit5986bee212e6e15328b6b9fc24072c40864b35d1 (patch)
tree912d24ac20372efc5fc4d645bf7f9dfe052a4a1e
parent0f1d0f4629a98b130322f088db26e38c689929f6 (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
-rw-r--r--utils/cli/ledgersmb_cli.pl21
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};