summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-07-09 17:34:14 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-07-09 17:34:14 (GMT)
commit0baf5c4e529557b37cb4e4abe3ce13ddc65dc36e (patch)
treea2f3403b0e9f4219b69fd9225143ce55c031cf53 /generic/tclCompExpr.c
parente57b07943eb8c2ee68eb8c1c9a23d9837116d0da (diff)
downloadtcl-0baf5c4e529557b37cb4e4abe3ce13ddc65dc36e.zip
tcl-0baf5c4e529557b37cb4e4abe3ce13ddc65dc36e.tar.gz
tcl-0baf5c4e529557b37cb4e4abe3ce13ddc65dc36e.tar.bz2
* generic/tclCompExpr.c: Revision so that the END lexeme never
gets inserted into the parse tree. Later tree traversal never reaches it since its location in the tree is not variable. Starting and stopping with the START lexeme (node 0) is sufficient. Also finished lexeme code commentary.
Diffstat (limited to 'generic/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 3474562..7741634 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.60 2007/07/09 14:51:44 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.61 2007/07/09 17:34:14 dgp Exp $
*/
#include "tclInt.h"
@@ -70,7 +70,7 @@
/* Leaf lexemes */
#define NUMBER ( LEAF | 1) /* For literal numbers */
-#define SCRIPT ( LEAF | 2) /* Command substitution; [foo] */
+#define SCRIPT ( LEAF | 2) /* Script substitution; [foo] */
#define BOOLEAN ( LEAF | BAREWORD) /* For literal booleans */
#define BRACED ( LEAF | 4) /* Braced string; {foo bar} */
#define VARIABLE ( LEAF | 5) /* Variable substitution; $x */
@@ -163,8 +163,33 @@
* ParseExpr(). */
#define IN_LIST ( BINARY | 25)
#define NOT_IN_LIST ( BINARY | 26)
-#define CLOSE_PAREN ( BINARY | 27) /**/
-#define END ( BINARY | 28) /**/
+#define CLOSE_PAREN ( BINARY | 27) /* By categorizing the CLOSE_PAREN
+ * lexeme as a BINARY operator, the
+ * normal parsing rules for binary
+ * operators assure that a close paren
+ * will not directly follow another
+ * operator, and the machinery already
+ * in place to connect operands to
+ * operators according to precedence
+ * performs most of the work of
+ * matching open and close parens for
+ * us. In the end though, a close
+ * paren is not really a binary
+ * operator, and some special coding
+ * in ParseExpr() make sure we never
+ * put an actual CLOSE_PAREN node
+ * in the parse tree. The
+ * sub-expression between parens
+ * becomes the single argument of
+ * the matching OPEN_PAREN unary
+ * operator. */
+#define END ( BINARY | 28) /* This lexeme represents the end of
+ * the string being parsed. Treating
+ * it as a binary operator follows the
+ * same logic as the CLOSE_PAREN lexeme
+ * and END pairs with START, in the
+ * same way that CLOSE_PAREN pairs with
+ * OPEN_PAREN. */
/*
* Integer codes indicating the form of an operand of an operator.
@@ -793,6 +818,9 @@ ParseExpr(
code = TCL_ERROR;
continue;
}
+ if (lexeme == END) {
+ continue;
+ }
/*
* Link orphan as left operand of new node.