19|ifthenelse|>>Matched action<< (return value: []) | 19|ifthenelse|>>Matched production: [if elsif else | | |endif]<< | 19|ifthenelse|>>Matched rule<< (return value: | | |[ARRAY(0x870cb08)]) | 19|ifthenelse|(consumed: []) | #### if stw!=0 then stw else 1.40 * 1e-6 endif #### expr: ifthenelse { $return = main::evaluate($main::c_v, @item); } ifthenelse: if elsif(s?) else(?) endif { $return = 'NIL'; for (my $i = 1; $i < @item; $i++) { print " iftest: $i '" . $item[$i] . "'\n"; if ($item[$i] ne 'NIL') { $return = $item[$i]; last; } } if ($return eq 'NIL') { die "IF statement '@item' not resolvable! $!\n"; } } if: /if/i expr /then/i expr { print 'i2: ' . $item[2] ."\n"; if($item[2]) { $return = $item[4]; } else { $return = 'NIL'; } } else: /else/i expr { $return = $item[2]; } elsif: /elsif/i expr /then/i expr { if ($item[2]) { $return = $item[4] } else { $return = 'NIL' } } endif: /endif/i { $return = 'NIL'; } #### sub evaluate { my $contvar = shift; shift; my $estr = join(' ', @_); my @whatsleft = @_; print " evaluating '$estr'\n"; $estr =~ s/ARRAY\x28[^\x28\x29]+\x29//g; $estr = trim($estr); if ($estr !~ /^[\s\.\/\x28\x290-9eE*+-]+$/) { my $parser = SpiceGrammar->new() or die "Bad SpiceGrammar: $!\n"; print " evaluating variable\n"; defined(my $value = $parser->vardef($estr)) or die "Bad input: {$estr} $!\n"; if ($value eq '') { $value = 0; print " substituting\n"; } return $value; } else { my $value = eval($estr); $vartable{$contvar} = $value; return $value; } } #### 21| expr |>>Matched action<< (return value: | | |[1.4e-06]) | 21| expr |>>Matched production: [number operator| | |expr]<< | 21| expr |>>Matched rule<< (return value: [1.4e-| | |06]) | 21| expr |(consumed: [ 1.40 * 1e-6]) | 20| else |>>Matched subrule: [expr]<< (return | | |value: [1.4e-06] | 20| else |Trying action | 20| else |>>Matched action<< (return value: | | |[1.4e-06]) | 20| else |>>Matched production: [/else/i expr]<<| 20| else |>>Matched rule<< (return value: [1.4e-| | |06]) | 20| else |(consumed: [ else 1.40 * 1e-6]) | 19|ifthenelse|>>Matched repeated subrule: [else]<< | | |(1 times)