Differences From Artifact [638f60c677]:
- File generic/tclCompExpr.c — part of check-in [011da3090c] at 2007-08-28 16:24:25 on branch trunk — * generic/tclBasic.c: Used unions to better clarify overloading of * generic/tclCompExpr.c: the fields of the OpCmdInfo and * generic/tclCompile.h: TclOpCmdClientData structs. (user: dgp size: 79918)
To Artifact [586a0889da]:
- File generic/tclCompExpr.c — part of check-in [a042911ac1] at 2007-08-28 17:43:03 on branch trunk — * generic/tclCompExpr.c: Use a table lookup in ParseLexeme() to determine lexemes with single-byte representations. (user: dgp size: 80974)
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tclCompExpr.c -- * * This file contains the code to parse and compile Tcl expressions * and implementations of the Tcl commands corresponding to expression * operators, such as the command ::tcl::mathop::+ . * * Contributions from Don Porter, NIST, 2006-2007. (not subject to US copyright) * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclCompExpr.c -- * * This file contains the code to parse and compile Tcl expressions * and implementations of the Tcl commands corresponding to expression * operators, such as the command ::tcl::mathop::+ . * * Contributions from Don Porter, NIST, 2006-2007. (not subject to US copyright) * * 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.86 2007/08/28 17:43:07 dgp Exp $ */ #include "tclInt.h" #include "tclCompile.h" /* CompileEnv */ /* * Expression parsing takes place in the routine ParseExpr(). It takes a |
| ︙ | ︙ | |||
430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
INST_UMINUS, /* UNARY_MINUS */
0, /* FUNCTION */
0, /* START */
0, /* OPEN_PAREN */
INST_LNOT, /* NOT*/
INST_BITNOT, /* BIT_NOT*/
};
/*
* The JumpList struct is used to create a stack of data needed for the
* TclEmitForwardJump() and TclFixupForwardJump() calls that are performed
* when compiling the short-circuiting operators QUESTION/COLON, AND, and OR.
* Keeping a stack permits the CompileExprTree() routine to be non-recursive.
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
INST_UMINUS, /* UNARY_MINUS */
0, /* FUNCTION */
0, /* START */
0, /* OPEN_PAREN */
INST_LNOT, /* NOT*/
INST_BITNOT, /* BIT_NOT*/
};
/*
* A table mapping a byte value to the corresponding lexeme for use by
* ParseLexeme().
*/
static unsigned char Lexeme[] = {
INVALID /* NUL */, INVALID /* SOH */,
INVALID /* STX */, INVALID /* ETX */,
INVALID /* EOT */, INVALID /* ENQ */,
INVALID /* ACK */, INVALID /* BEL */,
INVALID /* BS */, INVALID /* HT */,
INVALID /* LF */, INVALID /* VT */,
INVALID /* FF */, INVALID /* CR */,
INVALID /* SO */, INVALID /* SI */,
INVALID /* DLE */, INVALID /* DC1 */,
INVALID /* DC2 */, INVALID /* DC3 */,
INVALID /* DC4 */, INVALID /* NAK */,
INVALID /* SYN */, INVALID /* ETB */,
INVALID /* CAN */, INVALID /* EM */,
INVALID /* SUB */, INVALID /* ESC */,
INVALID /* FS */, INVALID /* GS */,
INVALID /* RS */, INVALID /* US */,
INVALID /* SPACE */, 0 /* ! or != */,
QUOTED /* " */, INVALID /* # */,
VARIABLE /* $ */, MOD /* % */,
0 /* & or && */, INVALID /* ' */,
OPEN_PAREN /* ( */, CLOSE_PAREN /* ) */,
0 /* * or ** */, PLUS /* + */,
COMMA /* , */, MINUS /* - */,
0 /* . */, DIVIDE /* / */,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0-9 */
COLON /* : */, INVALID /* ; */,
0 /* < or << or <= */,
0 /* == or INVALID */,
0 /* > or >> or >= */,
QUESTION /* ? */, INVALID /* @ */,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A-M */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* N-Z */
SCRIPT /* [ */, INVALID /* \ */,
INVALID /* ] */, BIT_XOR /* ^ */,
INVALID /* _ */, INVALID /* ` */,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a-m */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* n-z */
BRACED /* { */, 0 /* | or || */,
INVALID /* } */, BIT_NOT /* ~ */,
INVALID /* DEL */
};
/*
* The JumpList struct is used to create a stack of data needed for the
* TclEmitForwardJump() and TclFixupForwardJump() calls that are performed
* when compiling the short-circuiting operators QUESTION/COLON, AND, and OR.
* Keeping a stack permits the CompileExprTree() routine to be non-recursive.
*/
|
| ︙ | ︙ | |||
1771 1772 1773 1774 1775 1776 1777 |
Tcl_Obj **literalPtr) /* Write corresponding literal value to this
storage, if non-NULL. */
{
const char *end;
int scanned;
Tcl_UniChar ch;
Tcl_Obj *literal = NULL;
| | < < < < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < | < < < < < < < < < < < < < < < < < < < < | 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 |
Tcl_Obj **literalPtr) /* Write corresponding literal value to this
storage, if non-NULL. */
{
const char *end;
int scanned;
Tcl_UniChar ch;
Tcl_Obj *literal = NULL;
unsigned char byte;
if (numBytes == 0) {
*lexemePtr = END;
return 0;
}
byte = (unsigned char)(*start);
if (byte < sizeof(Lexeme) && Lexeme[byte] != 0) {
*lexemePtr = Lexeme[byte];
return 1;
}
switch (byte) {
case '*':
if ((numBytes > 1) && (start[1] == '*')) {
*lexemePtr = EXPON;
return 2;
}
*lexemePtr = MULT;
return 1;
|
| ︙ | ︙ |