diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-10-08 15:39:37 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-10-08 15:39:37 (GMT) |
commit | b8ad7e6569c1ac14d88d993310013ae3095d00b1 (patch) | |
tree | 8013273a78ab046ca1744309207ab85ea5ab26c9 /generic/tclParseExpr.c | |
parent | 4b9c1da0d3b0ca6029c1fe83989006927422d95d (diff) | |
download | tcl-b8ad7e6569c1ac14d88d993310013ae3095d00b1.zip tcl-b8ad7e6569c1ac14d88d993310013ae3095d00b1.tar.gz tcl-b8ad7e6569c1ac14d88d993310013ae3095d00b1.tar.bz2 |
Core of implementation of TIP#201 ('in' and 'ni' operators)
Diffstat (limited to 'generic/tclParseExpr.c')
-rw-r--r-- | generic/tclParseExpr.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c index 266466c..2a1c151 100644 --- a/generic/tclParseExpr.c +++ b/generic/tclParseExpr.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParseExpr.c,v 1.22 2004/10/04 13:56:37 dkf Exp $ + * RCS: @(#) $Id: tclParseExpr.c,v 1.23 2004/10/08 15:39:55 dkf Exp $ */ #include "tclInt.h" @@ -134,6 +134,13 @@ typedef struct ParseInfo { #define EXPON 36 /* + * List containment operators + */ + +#define IN_LIST 37 +#define NOT_IN_LIST 38 + +/* * Mapping from lexemes to strings; used for debugging messages. These * entries must match the order and number of the lexeme definitions above. */ @@ -144,7 +151,7 @@ static char *lexemeStrings[] = { "*", "/", "%", "+", "-", "<<", ">>", "<", ">", "<=", ">=", "==", "!=", "&", "^", "|", "&&", "||", "?", ":", - "!", "~", "eq", "ne", "**" + "!", "~", "eq", "ne", "**", "in", "ni" }; /* @@ -747,8 +754,8 @@ ParseEqualityExpr(infoPtr) } lexeme = infoPtr->lexeme; - while ((lexeme == EQUAL) || (lexeme == NEQ) - || (lexeme == STREQ) || (lexeme == STRNEQ)) { + while (lexeme == EQUAL || lexeme == NEQ || lexeme == NOT_IN_LIST || + lexeme == IN_LIST || lexeme == STREQ || lexeme == STRNEQ) { operator = infoPtr->start; code = GetLexeme(infoPtr); /* skip over ==, !=, 'eq' or 'ne' */ if (code != TCL_OK) { @@ -1857,7 +1864,7 @@ GetLexeme(infoPtr) case 'e': if ((src[1] == 'q') && ((infoPtr->lastChar - src) > 1) && - (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { + (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { infoPtr->lexeme = STREQ; infoPtr->size = 2; infoPtr->next = src+2; @@ -1869,12 +1876,31 @@ GetLexeme(infoPtr) case 'n': if ((src[1] == 'e') && ((infoPtr->lastChar - src) > 1) && - (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { + (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { infoPtr->lexeme = STRNEQ; infoPtr->size = 2; infoPtr->next = src+2; parsePtr->term = infoPtr->next; return TCL_OK; + } else if ((src[1] == 'i') && ((infoPtr->lastChar - src) > 1) && + (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { + infoPtr->lexeme = NOT_IN_LIST; + infoPtr->size = 2; + infoPtr->next = src+2; + parsePtr->term = infoPtr->next; + return TCL_OK; + } else { + goto checkFuncName; + } + + case 'i': + if ((src[1] == 'n') && ((infoPtr->lastChar - src) > 1) && + (infoPtr->lastChar-src==2 || !isalpha(UCHAR(src[2])))) { + infoPtr->lexeme = IN_LIST; + infoPtr->size = 2; + infoPtr->next = src+2; + parsePtr->term = infoPtr->next; + return TCL_OK; } else { goto checkFuncName; } |