| ︙ | | |
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
-
+
|
/*
* Main parsing loop parses one lexeme per iteration. We exit the loop
* only when there's a syntax error with a "goto error" which takes us to
* the error handling code following the loop, or when we've successfully
* completed the parse and we return to the caller.
*/
while (1) {
while (true) {
OpNode *nodePtr; /* Points to the OpNode we may fill this pass
* through the loop. */
unsigned char lexeme; /* The lexeme we parse this iteration. */
Tcl_Obj *literal; /* Filled by the ParseLexeme() call when a
* literal is parsed that has a Tcl_Obj rep
* worth preserving. */
|
| ︙ | | |
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
-
+
|
tokenPtr = parsePtr->tokenPtr + parsePtr->numTokens;
tokenPtr->type = TCL_TOKEN_COMMAND;
tokenPtr->start = start;
tokenPtr->numComponents = 0;
end = start + numBytes;
start++;
while (1) {
while (true) {
code = Tcl_ParseCommand(interp, start, end - start, 1,
nestedPtr);
if (code != TCL_OK) {
parsePtr->term = nestedPtr->term;
parsePtr->errorType = nestedPtr->errorType;
parsePtr->incomplete = nestedPtr->incomplete;
break;
|
| ︙ | | |
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
|
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
|
-
+
|
* join "3" to "2*"; the next pass will join "2*3" to "1+". Then
* we'll exit the loop and join "1+2*3" to "-". When we return to
* parse another lexeme, our stack of incomplete trees is START
* and "1+2*3-".
*/
OpNode *incompletePtr;
while (1) {
while (true) {
incompletePtr = nodes + incomplete;
if (incompletePtr->precedence < precedence) {
break;
}
if (incompletePtr->precedence == precedence) {
|
| ︙ | | |
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
|
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
|
-
+
|
Tcl_Token *tokenPtr,
Tcl_Parse *parsePtr)
{
Tcl_Size subExprTokenIdx = 0;
OpNode *nodePtr = nodes;
int next = nodePtr->right;
while (1) {
while (true) {
Tcl_Size scanned, parentIdx;
unsigned char lexeme;
/*
* Advance the mark so the next exit from this node won't retrace
* steps over ground already covered.
*/
|
| ︙ | | |
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
|
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
|
-
+
|
{
OpNode *nodePtr = nodes + index;
OpNode *rootPtr = nodePtr;
int numWords = 0;
JumpList *jumpPtr = NULL;
bool convert = true;
while (1) {
while (true) {
int next;
JumpList *newJump;
if (nodePtr->mark == MARK_LEFT) {
next = nodePtr->left;
if (nodePtr->lexeme == QUESTION) {
|
| ︙ | | |
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
|
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
|
-
+
|
case COLON:
CLANG_ASSERT(jumpPtr);
if (jumpPtr->jump.jumpType == TCL_TRUE_JUMP) {
jumpPtr->jump.jumpType = TCL_UNCONDITIONAL_JUMP;
convert = true;
}
Tcl_Size target = jumpPtr->jump.codeOffset + 5;
TclFixupForwardJumpToHere(envPtr, &jumpPtr->jump);
FixupForwardJumpToHere(&jumpPtr->jump);
{
JumpList *freePtr = jumpPtr;
jumpPtr = jumpPtr->next;
TclStackFree(interp, freePtr);
TclFixupForwardJump(envPtr, &jumpPtr->jump,
target - jumpPtr->jump.codeOffset);
|
| ︙ | | |
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
|
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
|
-
+
|
} else {
FWDJUMP( JUMP_TRUE, pc1);
}
PUSH_STRING( (nodePtr->lexeme == AND) ? "1" : "0");
FWDJUMP( JUMP, pc2);
STKDELTA(-1);
FWDLABEL(pc1);
TclFixupForwardJumpToHere(envPtr, &jumpPtr->jump);
FixupForwardJumpToHere(&jumpPtr->jump);
PUSH_STRING( (nodePtr->lexeme == AND) ? "0" : "1");
FWDLABEL(pc2);
convert = false;
{
JumpList *freePtr = jumpPtr;
jumpPtr = jumpPtr->next;
TclStackFree(interp, freePtr);
|
| ︙ | | |
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
|
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
|
-
+
|
PUSH_OBJ( literal);
}
(*litObjvPtr)++;
break;
}
case OT_TOKENS:
CompileTokens(envPtr, tokenPtr, interp);
CompileTokens(tokenPtr);
tokenPtr += tokenPtr->numComponents + 1;
break;
default:
if (optimize && nodes[next].constant) {
Tcl_InterpState save = Tcl_SaveInterpState(interp, TCL_OK);
if (ExecConstantExprTree(interp, nodes, next, litObjvPtr)
|
| ︙ | | |
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
|
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
|
-
+
|
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
int code = TCL_OK;
if (objc < 3) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1));
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(true));
} else {
TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
Tcl_Obj **litObjv = (Tcl_Obj **)TclStackAlloc(interp,
2 * (objc-2) * sizeof(Tcl_Obj *));
OpNode *nodes = (OpNode *)TclStackAlloc(interp,
2 * (objc-2) * sizeof(OpNode));
unsigned char lexeme;
|
| ︙ | | |