summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-02 17:07:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-11-02 17:07:56 +0000
commitfc91f7ed3693603c67b4a5dbe6d7bc15a8b99969 (patch)
tree1d02a1d0b94750908a59335ee1ae0e7e5509e2f3
parent803c62d22eb4e2eb3a79a66a03dc0e8a9da23e01 (diff)
Nested IF support for the CLI script host
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@465 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--utils/cli/ledgersmb_cli.pl13
-rw-r--r--utils/cli/sample.lsmb5
2 files changed, 15 insertions, 3 deletions
diff --git a/utils/cli/ledgersmb_cli.pl b/utils/cli/ledgersmb_cli.pl
index 39d550e7..4bdd0d5f 100644
--- a/utils/cli/ledgersmb_cli.pl
+++ b/utils/cli/ledgersmb_cli.pl
@@ -134,9 +134,7 @@ sub pop_loop {
sub if_handler {
my $key = shift;
if (!$stackref->{$key}){
- while ($line !~ /^(\s*FI\s*|\s*END\s+IF\s*)$/ ){
- $line = <>;
- }
+ $if_count = 1;
}
}
@@ -155,6 +153,15 @@ sub load_mod {
my $scriptparse = new Parse::RecDescent($syntax);
while ($line = <>){
+ if ($if_count){
+ if ($line =~ /^\s*IF\s/){
+ ++$if_count;
+ }
+ if ($line =~ /^(\s*FI\s*|\s*END\s+IF\s*)$/){
+ --$if_count;
+ }
+ }
+ next if ($if_count);
$line =~ s/#.*$//; # strip comments
$scriptparse->startrule($line);
}
diff --git a/utils/cli/sample.lsmb b/utils/cli/sample.lsmb
index 9e544b4e..24747b26 100644
--- a/utils/cli/sample.lsmb
+++ b/utils/cli/sample.lsmb
@@ -1,3 +1,4 @@
+# Comments start with a pund sign
ENV:PGUSER = postgres # how to set an environment variable
login = demo # How to set a form variable
password = demo
@@ -7,3 +8,7 @@ id = 10139
vc = customer
db = customer
CALL CT->create_links(user, form) # call a function
+IF bcc4 # Conditional IF's can be nested
+testing = hi
+FI
+