diff options
Diffstat (limited to 'taccle/examples/infix_calc.tac')
-rw-r--r-- | taccle/examples/infix_calc.tac | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/taccle/examples/infix_calc.tac b/taccle/examples/infix_calc.tac deleted file mode 100644 index 95ef2ee..0000000 --- a/taccle/examples/infix_calc.tac +++ /dev/null @@ -1,35 +0,0 @@ -# $Id: infix_calc.tac,v 1.1 2004/09/29 16:23:28 tang Exp $ - -# This example demonstrates how taccle handles operator precedence. -# The code is shamelessly borrowed from the GNU Bison info manual. - -# taccle Declarations -%token ID NEWLINE -%left '-' '+' -%left '*' '/' -%left NEG # negation--unary minus -%right '^' # exponentiation - -# Grammar follows -%% -input: # empty string - | input line -; - -line: NEWLINE - | exp NEWLINE { puts [format "\t%.10g" $1] } -; - -exp: ID { set _ $1 } - | exp '+' exp { set _ [expr {$1 + $3}] } - | exp '-' exp { set _ [expr {$1 - $3}] } - | exp '*' exp { set _ [expr {$1 * $3}] } - | exp '/' exp { set _ [expr {$1 / $3}] } - | '-' exp %prec NEG { set _ [expr {-1.0 * $2}] } - | exp '^' exp { set _ [expr {pow($1, $3)}] } - | '(' exp ')' { set _ $2 } -; -%% - -source simple_scanner.tcl -yyparse |