diff options
Diffstat (limited to 'es_2_0/EvalParse.c')
-rwxr-xr-x | es_2_0/EvalParse.c | 760 |
1 files changed, 760 insertions, 0 deletions
diff --git a/es_2_0/EvalParse.c b/es_2_0/EvalParse.c new file mode 100755 index 0000000..a80c304 --- /dev/null +++ b/es_2_0/EvalParse.c @@ -0,0 +1,760 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef lint +static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif + +#include <stdlib.h> +#include <string.h> + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYPATCH 20070509 + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING (yyerrflag != 0) + +extern int yyparse(void); + +static int yygrowstack(void); +#define yyparse hazelEvalparse +#define yylex hazelEvallex +#define yyerror hazelEvalerror +#define yychar hazelEvalchar +#define yyval hazelEvalval +#define yylval hazelEvallval +#define yydebug hazelEvaldebug +#define yynerrs hazelEvalnerrs +#define yyerrflag hazelEvalerrflag +#define yyss hazelEvalss +#define yyssp hazelEvalssp +#define yyvs hazelEvalvs +#define yyvsp hazelEvalvsp +#define yylhs hazelEvallhs +#define yylen hazelEvallen +#define yydefred hazelEvaldefred +#define yydgoto hazelEvaldgoto +#define yysindex hazelEvalsindex +#define yyrindex hazelEvalrindex +#define yygindex hazelEvalgindex +#define yytable hazelEvaltable +#define yycheck hazelEvalcheck +#define yyname hazelEvalname +#define yyrule hazelEvalrule +#define YYPREFIX "hazelEval" + +#include "es2front.h" + +extern int hazelEvallex(void); +extern int hazelEvallex_destroy(void); + +static int hazelNumEval = 0; +static int hazelEvalValueA = 0; +static int hazelEvalValueB = 0; + +int hazelEvalGetResult(int* pEvalA, int* pEvalB) { + if (hazelNumEval >= 1) *pEvalA = hazelEvalValueA; + if (hazelNumEval >= 2) *pEvalB = hazelEvalValueB; + return hazelNumEval; +} + +void hazelEvalTerminate(void) { + hazelEvallex_destroy(); +} + +int yyerror(char* s) { + /* just ignore the YACC error message */ + return 1; +} + +#define IDENTIFIER 257 +#define NUMBER 258 +#define DEFINED 259 +#define LEFT_OP 260 +#define RIGHT_OP 261 +#define LE_OP 262 +#define GE_OP 263 +#define EQ_OP 264 +#define NE_OP 265 +#define AND_OP 266 +#define OR_OP 267 +#define UPLUS 268 +#define UMINUS 269 +#define YYERRCODE 256 +short hazelEvallhs[] = { -1, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, +}; +short hazelEvallen[] = { 2, + 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 4, 2, 2, 2, 2, 1, +}; +short hazelEvaldefred[] = { 0, + 28, 0, 0, 0, 0, 0, 0, 0, 0, 22, + 0, 24, 25, 26, 27, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 20, 21, 23, 0, 0, +}; +short hazelEvaldgoto[] = { 8, + 9, +}; +short hazelEvalsindex[] = { -26, + 0, -27, -26, -26, -26, -26, -26, 0, 436, 0, + -255, 0, 0, 0, 0, 447, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, 473, -38, -26, -26, 0, -22, + -22, -37, -37, 681, 681, 582, 541, 527, 630, 497, + -37, -37, 0, 0, 0, 0, 0, 0, -11, -11, +}; +short hazelEvalrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 0, 79, + 102, 114, 157, 27, 393, 194, 204, 181, 403, 397, + 288, 351, 1, 12, 0, 0, 0, 0, 37, 51, +}; +short hazelEvalgindex[] = { 0, + 746, +}; +#define YYTABLESIZE 944 +short hazelEvaltable[] = { 34, + 17, 36, 58, 1, 32, 37, 6, 38, 2, 33, + 0, 18, 11, 7, 34, 0, 3, 0, 4, 32, + 37, 0, 38, 0, 33, 34, 9, 0, 0, 0, + 32, 0, 0, 17, 0, 33, 17, 24, 17, 0, + 17, 0, 24, 17, 18, 17, 0, 24, 25, 18, + 18, 18, 0, 25, 18, 0, 18, 0, 25, 9, + 17, 0, 17, 0, 9, 0, 9, 9, 0, 17, + 0, 18, 0, 18, 17, 0, 17, 17, 15, 17, + 0, 17, 0, 18, 0, 0, 0, 0, 18, 0, + 18, 18, 0, 18, 17, 18, 17, 0, 17, 5, + 0, 16, 0, 0, 0, 18, 0, 0, 0, 0, + 18, 15, 18, 13, 0, 0, 15, 0, 15, 15, + 9, 0, 0, 0, 17, 0, 17, 0, 0, 0, + 17, 0, 0, 0, 16, 18, 0, 18, 15, 16, + 15, 16, 16, 0, 18, 0, 13, 0, 0, 0, + 9, 13, 9, 13, 13, 0, 14, 0, 0, 0, + 17, 16, 17, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 15, 13, 18, 13, 18, 0, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 14, + 0, 0, 0, 5, 14, 16, 14, 14, 0, 0, + 0, 0, 15, 4, 15, 0, 0, 13, 0, 0, + 0, 0, 0, 6, 0, 0, 14, 0, 14, 0, + 6, 6, 17, 18, 0, 16, 5, 16, 0, 10, + 0, 1, 2, 5, 5, 0, 4, 13, 0, 13, + 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 0, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, + 14, 0, 14, 0, 9, 9, 0, 11, 0, 0, + 9, 9, 9, 9, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 6, 0, 6, 0, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 0, 5, + 11, 0, 0, 0, 0, 11, 0, 11, 11, 4, + 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 0, 11, 0, 11, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, + 0, 13, 13, 0, 0, 13, 13, 13, 13, 13, + 13, 11, 0, 12, 0, 0, 0, 0, 12, 0, + 12, 12, 10, 0, 0, 0, 8, 0, 0, 0, + 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, + 12, 11, 12, 11, 14, 14, 0, 0, 14, 14, + 14, 14, 14, 14, 0, 10, 0, 0, 0, 8, + 10, 0, 10, 10, 8, 7, 8, 8, 6, 6, + 0, 0, 7, 7, 12, 0, 6, 6, 0, 0, + 0, 5, 5, 0, 0, 0, 0, 0, 0, 5, + 5, 4, 4, 0, 0, 0, 0, 0, 6, 0, + 4, 0, 34, 27, 12, 7, 12, 32, 30, 0, + 31, 0, 33, 34, 27, 0, 10, 39, 32, 37, + 8, 38, 0, 33, 0, 28, 7, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 0, 29, 34, + 27, 0, 0, 0, 32, 37, 10, 38, 10, 33, + 8, 0, 8, 0, 0, 0, 7, 0, 7, 26, + 0, 0, 28, 34, 29, 0, 0, 0, 32, 37, + 26, 38, 0, 33, 0, 11, 11, 0, 0, 11, + 11, 11, 11, 11, 11, 0, 28, 0, 29, 25, + 0, 5, 0, 34, 27, 0, 26, 0, 32, 37, + 25, 38, 0, 33, 0, 0, 0, 34, 27, 0, + 0, 0, 32, 37, 0, 38, 28, 33, 29, 0, + 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 28, 0, 29, 0, 0, 0, 0, 0, 12, 12, + 0, 0, 12, 12, 12, 12, 12, 12, 34, 27, + 26, 0, 0, 32, 37, 0, 38, 0, 33, 0, + 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, + 0, 28, 0, 29, 0, 0, 0, 0, 0, 0, + 10, 10, 0, 0, 8, 8, 10, 10, 10, 10, + 7, 7, 8, 8, 25, 0, 34, 27, 7, 7, + 0, 32, 37, 0, 38, 26, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, + 0, 29, 0, 1, 2, 17, 18, 19, 20, 21, + 22, 23, 24, 0, 0, 25, 17, 18, 19, 20, + 21, 22, 23, 24, 0, 0, 0, 34, 0, 0, + 0, 0, 32, 37, 0, 38, 0, 33, 0, 0, + 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, + 28, 0, 29, 0, 0, 0, 0, 0, 12, 13, + 14, 15, 16, 0, 35, 0, 17, 18, 19, 20, + 21, 22, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 0, 0, 59, 60, 0, 0, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, 21, 22, 23, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, + 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, +}; +short hazelEvalcheck[] = { 37, + 0, 257, 41, 0, 42, 43, 33, 45, 0, 47, + -1, 0, 40, 40, 37, -1, 43, -1, 45, 42, + 43, -1, 45, -1, 47, 37, 0, -1, -1, -1, + 42, -1, -1, 33, -1, 47, 0, 37, 38, -1, + 40, -1, 42, 43, 33, 45, -1, 47, 37, 38, + 0, 40, -1, 42, 43, -1, 45, -1, 47, 33, + 60, -1, 62, -1, 38, -1, 40, 41, -1, 33, + -1, 60, -1, 62, 38, -1, 40, 41, 0, 43, + -1, 45, -1, 33, -1, -1, -1, -1, 38, -1, + 40, 41, -1, 43, 94, 45, 60, -1, 62, 126, + -1, 0, -1, -1, -1, 94, -1, -1, -1, -1, + 60, 33, 62, 0, -1, -1, 38, -1, 40, 41, + 94, -1, -1, -1, 124, -1, 126, -1, -1, -1, + 94, -1, -1, -1, 33, 124, -1, 126, 60, 38, + 62, 40, 41, -1, 94, -1, 33, -1, -1, -1, + 124, 38, 126, 40, 41, -1, 0, -1, -1, -1, + 124, 60, 126, 62, -1, -1, -1, -1, -1, -1, + -1, -1, 94, 60, 124, 62, 126, -1, -1, -1, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 33, + -1, -1, -1, 0, 38, 94, 40, 41, -1, -1, + -1, -1, 124, 0, 126, -1, -1, 94, -1, -1, + -1, -1, -1, 33, -1, -1, 60, -1, 62, -1, + 40, 41, 260, 261, -1, 124, 33, 126, -1, 257, + -1, 258, 259, 40, 41, -1, 33, 124, -1, 126, + -1, -1, -1, 40, 41, -1, -1, -1, -1, -1, + 94, -1, -1, -1, -1, -1, -1, -1, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, -1, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, -1, + 124, -1, 126, -1, 258, 259, -1, 0, -1, -1, + 264, 265, 266, 267, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 124, -1, 126, -1, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, -1, 126, + 33, -1, -1, -1, -1, 38, -1, 40, 41, 126, + -1, -1, -1, -1, -1, -1, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, -1, 60, -1, 62, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, -1, + -1, 258, 259, -1, -1, 262, 263, 264, 265, 266, + 267, 94, -1, 33, -1, -1, -1, -1, 38, -1, + 40, 41, 0, -1, -1, -1, 0, -1, -1, -1, + -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, + 60, 124, 62, 126, 258, 259, -1, -1, 262, 263, + 264, 265, 266, 267, -1, 33, -1, -1, -1, 33, + 38, -1, 40, 41, 38, 33, 40, 41, 258, 259, + -1, -1, 40, 41, 94, -1, 266, 267, -1, -1, + -1, 258, 259, -1, -1, -1, -1, -1, -1, 266, + 267, 258, 259, -1, -1, -1, -1, -1, 33, -1, + 267, -1, 37, 38, 124, 40, 126, 42, 43, -1, + 45, -1, 47, 37, 38, -1, 94, 41, 42, 43, + 94, 45, -1, 47, -1, 60, 94, 62, -1, -1, + -1, -1, -1, -1, -1, -1, 60, -1, 62, 37, + 38, -1, -1, -1, 42, 43, 124, 45, 126, 47, + 124, -1, 126, -1, -1, -1, 124, -1, 126, 94, + -1, -1, 60, 37, 62, -1, -1, -1, 42, 43, + 94, 45, -1, 47, -1, 258, 259, -1, -1, 262, + 263, 264, 265, 266, 267, -1, 60, -1, 62, 124, + -1, 126, -1, 37, 38, -1, 94, -1, 42, 43, + 124, 45, -1, 47, -1, -1, -1, 37, 38, -1, + -1, -1, 42, 43, -1, 45, 60, 47, 62, -1, + -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, + 60, -1, 62, -1, -1, -1, -1, -1, 258, 259, + -1, -1, 262, 263, 264, 265, 266, 267, 37, 38, + 94, -1, -1, 42, 43, -1, 45, -1, 47, -1, + -1, -1, -1, -1, 94, -1, -1, -1, -1, -1, + -1, 60, -1, 62, -1, -1, -1, -1, -1, -1, + 258, 259, -1, -1, 258, 259, 264, 265, 266, 267, + 258, 259, 266, 267, 124, -1, 37, 38, 266, 267, + -1, 42, 43, -1, 45, 94, 47, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, + -1, 62, -1, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, -1, -1, 124, 260, 261, 262, 263, + 264, 265, 266, 267, -1, -1, -1, 37, -1, -1, + -1, -1, 42, 43, -1, 45, -1, 47, -1, -1, + -1, -1, 260, 261, 262, 263, 264, 265, 266, 267, + 60, -1, 62, -1, -1, -1, -1, -1, 3, 4, + 5, 6, 7, -1, 9, -1, 260, 261, 262, 263, + 264, 265, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, -1, 37, 38, -1, -1, 260, 261, 262, 263, + 264, 265, -1, -1, -1, -1, -1, -1, -1, -1, + 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 260, 261, 262, 263, 264, 265, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 260, + 261, 262, 263, 264, 265, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 260, 261, 262, 263, +}; +#define YYFINAL 8 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 269 +#if YYDEBUG +char *hazelEvalname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,"'<'",0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0, +"'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,"IDENTIFIER","NUMBER","DEFINED","LEFT_OP","RIGHT_OP", +"LE_OP","GE_OP","EQ_OP","NE_OP","AND_OP","OR_OP","UPLUS","UMINUS", +}; +char *hazelEvalrule[] = { +"$accept : goal", +"goal : expr", +"goal : expr expr", +"expr : '(' expr ')'", +"expr : expr OR_OP expr", +"expr : expr AND_OP expr", +"expr : expr '|' expr", +"expr : expr '^' expr", +"expr : expr '&' expr", +"expr : expr EQ_OP expr", +"expr : expr NE_OP expr", +"expr : expr '<' expr", +"expr : expr '>' expr", +"expr : expr LE_OP expr", +"expr : expr GE_OP expr", +"expr : expr LEFT_OP expr", +"expr : expr RIGHT_OP expr", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : DEFINED IDENTIFIER", +"expr : DEFINED '(' IDENTIFIER ')'", +"expr : '+' expr", +"expr : '-' expr", +"expr : '~' expr", +"expr : '!' expr", +"expr : NUMBER", +}; +#endif +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif +#if YYDEBUG +#include <stdio.h> +#endif + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif + +#define YYINITSTACKSIZE 500 + +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; + +/* variables for the parser stack */ +static short *yyss; +static short *yysslim; +static YYSTYPE *yyvs; +static int yystacksize; + +#include "EvalLex.inl" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack(void) +{ + int newsize, i; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = yyssp - yyss; + newss = (yyss != 0) + ? (short *)realloc(yyss, newsize * sizeof(*newss)) + : (short *)malloc(newsize * sizeof(*newss)); + if (newss == 0) + return -1; + + yyss = newss; + yyssp = newss + i; + newvs = (yyvs != 0) + ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs)) + : (YYSTYPE *)malloc(newsize * sizeof(*newvs)); + if (newvs == 0) + return -1; + + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse(void) +{ + register int yym, yyn, yystate; +#if YYDEBUG + register const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + yyerror("syntax error"); + +#ifdef lint + goto yyerrlab; +#endif + +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym) + yyval = yyvsp[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + switch (yyn) + { +case 1: +{ hazelNumEval = 1; hazelEvalValueA = yyvsp[0]; } +break; +case 2: +{ hazelNumEval = 2; hazelEvalValueA = yyvsp[-1]; hazelEvalValueB = yyvsp[0]; } +break; +case 3: +{ yyval = yyvsp[-1]; } +break; +case 4: +{ yyval = (yyvsp[-2] || yyvsp[0]); } +break; +case 5: +{ yyval = (yyvsp[-2] && yyvsp[0]); } +break; +case 6: +{ yyval = (yyvsp[-2] | yyvsp[0]); } +break; +case 7: +{ yyval = (yyvsp[-2] ^ yyvsp[0]); } +break; +case 8: +{ yyval = (yyvsp[-2] & yyvsp[0]); } +break; +case 9: +{ yyval = (yyvsp[-2] == yyvsp[0]); } +break; +case 10: +{ yyval = (yyvsp[-2] != yyvsp[0]); } +break; +case 11: +{ yyval = (yyvsp[-2] < yyvsp[0]); } +break; +case 12: +{ yyval = (yyvsp[-2] > yyvsp[0]); } +break; +case 13: +{ yyval = (yyvsp[-2] <= yyvsp[0]); } +break; +case 14: +{ yyval = (yyvsp[-2] >= yyvsp[0]); } +break; +case 15: +{ yyval = (yyvsp[-2] << yyvsp[0]); } +break; +case 16: +{ yyval = (yyvsp[-2] >> yyvsp[0]); } +break; +case 17: +{ yyval = (yyvsp[-2] + yyvsp[0]); } +break; +case 18: +{ yyval = (yyvsp[-2] - yyvsp[0]); } +break; +case 19: +{ yyval = (yyvsp[-2] * yyvsp[0]); } +break; +case 20: +{ yyval = (yyvsp[-2] / yyvsp[0]); } +break; +case 21: +{ yyval = (yyvsp[-2] % yyvsp[0]); } +break; +case 22: +{ yyval = (yyvsp[0] != (int)(NULL)); } +break; +case 23: +{ yyval = (yyvsp[-1] != (int)(NULL)); } +break; +case 24: +{ yyval = (yyvsp[0]); } +break; +case 25: +{ yyval = (- yyvsp[0]); } +break; +case 26: +{ yyval = (~ yyvsp[0]); } +break; +case 27: +{ yyval = (! yyvsp[0]); } +break; +case 28: +{ yyval = yyvsp[0]; } +break; + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; + +yyoverflow: + yyerror("yacc stack overflow"); + +yyabort: + return (1); + +yyaccept: + return (0); +} |