2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * 31 28 24 20 16 12 8 4 0 2N/A * +-----+-----+-----+-----+-----+-----+-----+-----+ 2N/A * |opnum| priority | operator | 2N/A * +-----+-----+-----+-----+-----+-----+-----+-----+ 2N/A 0x00000000,
/* NULL */ 2N/A 0x00000001,
/* INIT */ 2N/A 0x00100002,
/* EXP */ 2N/A 0x00200003,
/* NUM */ 2N/A 0x00300004,
/* VAR */ 2N/A 0x30400005,
/* CONDC */ 2N/A 0x30500006,
/* CONDQ */ 2N/A 0x20600007,
/* OR */ 2N/A 0x20700008,
/* AND */ 2N/A 0x20800009,
/* EQ */ 2N/A 0x2080000a,
/* NEQ */ 2N/A 0x2090000b,
/* GT */ 2N/A 0x2090000c,
/* LT */ 2N/A 0x2090000d,
/* GE */ 2N/A 0x2090000e,
/* LE */ 2N/A 0x20a0000f,
/* ADD */ 2N/A 0x20a00010,
/* SUB */ 2N/A 0x20b00011,
/* MUL */ 2N/A 0x20b00012,
/* DIV */ 2N/A 0x20b00013,
/* MOD */ 2N/A 0x10c00014,
/* NOT */ 2N/A 0x00d00015,
/* LPAR */ 2N/A 0x00e00016,
/* RPAR */ 2N/A 0x00000017 /* ERR */ 2N/A "T_INIT",
"T_EXP",
"T_NUM",
"T_VAR",
"T_CONDC",
"T_CONDQ",
2N/A "T_LOR",
"T_LAND",
"T_EQ",
"T_NEQ",
"T_GT",
"T_LT",
"T_GE",
"T_LE",
2N/A "T_ADD",
"T_SUB",
"T_MUL",
"T_DIV",
"T_MOD",
"T_LNOT",
"T_LPAR",
2N/A /* unary operator */ 2N/A /* binary operator */ 2N/A /* trinary operator: conditional */ 2N/A return (0);
/* keep gcc happy */ 2N/A while (*
sp && ((*
sp ==
' ') || (*
sp ==
'\t')))
2N/A }
else if ((*
sp ==
'\n') || (*
sp ==
';')) {
2N/A * str: string to parse 2N/A * e: parsed expression 2N/A * -1: Error happend (malloc failed) 2N/A * 1: Parse failed (invalid expression) 2N/A * 0: Parse succeeded 2N/A /* binary operation */ 2N/A continue;
/* while-loop */ 2N/A /* conditional operation: '?' */ 2N/A continue;
/* while-loop */ 2N/A /* conditional operation: ':' */ 2N/A continue;
/* while-loop */ 2N/A /* left parenthesis */ 2N/A continue;
/* while-loop */ 2N/A /* right parenthesis */ 2N/A printf(
"======================== RPAR for loop in\n");
2N/A break;
/* break from for-loop */ 2N/A continue;
/* for-loop */ 2N/Aprintf(
"========================= RPAR for loop out\n");
2N/A * Needs to check if exp can be reduced or not 2N/A continue;
/* while-loop */ 2N/A continue;
/* while-loop */ 2N/A break;
/* exit from for-loop */ 2N/A /* LNOT is the strongest */ 2N/A continue;
/* for-loop */ 2N/A * T_MUL, T_ADD, T_CMP, 2N/A * T_EQ, T_LAND, T_LOR 2N/A continue;
/* for-loop */ 2N/A break;
/* exit from for loop */ 2N/A * CONDQ is the weakest 2N/A break;
/* exit from for loop */ 2N/A continue;
/* for-loop */ 2N/A break;
/* exit from for-loop */ 2N/A continue;
/* while-loop */ 2N/A printf(
"ERR: flag for the result is not T_INIT\n");
2N/A * exp still remains in stack. 2N/A /* parse succeeded */ 2N/A (
void)
printf(
"*************** plural_eval(%p, %d)\n",
2N/A /* optimization for T_LOR and T_LAND */ 2N/A /* should not be here */