Author: mdiep
Date: Thu Aug 18 07:15:38 2005
New Revision: 8985
Modified:
trunk/languages/tcl/lib/expression.pir
trunk/languages/tcl/t/cmd_expr.t
Log:
tcl: Add support for subcommands in [expr]
Modified: trunk/languages/tcl/lib/expression.pir
==============================================================================
--- trunk/languages/tcl/lib/expression.pir (original)
+++ trunk/languages/tcl/lib/expression.pir Thu Aug 18 07:15:38 2005
@@ -56,6 +56,7 @@ chunk_loop:
if $I0 == 1 goto get_number
$I0 = ord expr, chunk_start
+ if $I0 == 91 goto subcommand # [
if $I0 == 40 goto get_parenthetical # (
if $I0 == 36 goto get_variable # $
if $I0 == 46 goto get_number # .
@@ -114,6 +115,16 @@ get_variable:
chunk = new TclList
chunk[0] = OPERAND
chunk[1] = retval
+ push chunks, chunk
+ dec chunk_start
+ goto chunk_loop
+
+subcommand:
+ (retval, chunk_start) = get_subcommand(expr, chunk_start)
+
+ chunk = new TclList
+ chunk[0] = OPERAND
+ chunk[1] = retval
push chunks, chunk
dec chunk_start
goto chunk_loop
Modified: trunk/languages/tcl/t/cmd_expr.t
==============================================================================
--- trunk/languages/tcl/t/cmd_expr.t (original)
+++ trunk/languages/tcl/t/cmd_expr.t Thu Aug 18 07:15:38 2005
@@ -261,6 +261,12 @@ TCL
0.333333333333
OUT
+language_output_is("tcl",<<'TCL',<<'OUT',"nested expr (braces)");
+ puts [expr {2 * [expr {2 - 1}]}];
+TCL
+2
+OUT
+
TODO: {
local $TODO = "bugs";
@@ -271,9 +277,4 @@ TCL
1
OUT
-language_output_is("tcl",<<'TCL',<<'OUT',"nested expr (braces)");
- puts [expr {2 * [expr {2 - 1}]}];
-TCL
-2
-OUT
}