/* A Bison parser, made from hoc.y by GNU bison 1.35. */ #define YYBISON 1 /* Identify Bison output. */ # define EXIT 257 # define BREAK 258 # define CONT 259 # define DEBUG 260 # define LEVEL 261 # define MOD 262 # define PRCALLS 263 # define IGNOREUNDEF 264 # define LOCALCMD 265 # define STRING 266 # define PRINT 267 # define VAR 268 # define BLTIN 269 # define UNDEF 270 # define WHILE 271 # define IF 272 # define ELSE 273 # define FOR 274 # define PRNAMES 275 # define INCLUDE 276 # define FUNCTION 277 # define PROCEDURE 278 # define RETURN 279 # define FUNC 280 # define PROC 281 # define READ 282 # define SYSTEM 283 # define LOCAL 284 # define SET 285 # define CONSTCMD 286 # define CONST 287 # define VERSION 288 # define TYPE 289 # define CALLFUNC 290 # define CALLPROC 291 # define ABORT 292 # define DOEOF 293 # define CHDIR 294 # define ARG 295 # define ARGCNT 296 # define NUMBER 297 # define ADDEQ 298 # define SUBEQ 299 # define MULEQ 300 # define DIVEQ 301 # define POWEQ 302 # define REMEQ 303 # define OR 304 # define AND 305 # define GT 306 # define GE 307 # define LT 308 # define LE 309 # define EQ 310 # define NE 311 # define APPROXEQ 312 # define NOTAPPROXEQ 313 # define UNARYMINUS 314 # define NOT 315 # define INCR 316 # define DECR 317 #line 1 "hoc.y" #include #include #ifdef STDC_HEADERS #include #include #include #else char *malloc(); char *strchr(); #endif #include "hoc.h" #define code2(c1,c2) code(c1);code(c2) #define code3(c1,c2,c3) code(c1);code(c2);code(c3) #define code4(c1,c2,c3,c4) code(c1);code(c2);code(c3);code(c4) #if YYDEBUG extern int yydebug; #endif static Constant zero; /* zero.d=0 because it's statically allocated (which has nothing to do with the "static" keyword) */ /* Default definitions of an empty function or procedure */ Inst deffunc[] = { /* a function that does nothing but returns 0 */ constpush, (Inst)&zero, funcret, STOP }; Inst defproc[] = { /* procedure that does nothing */ procret, STOP }; static char *atstring=""; int indef; static int showprompt; /* what the next yylex should show: 0: no prompt, 1: new statement prompt */ /* functions which will be defined below */ static void defnonly _PROTO((char *s)); static int skipc _PROTO((void)); static int backslash _PROTO((int c)); static char lookahead _PROTO((void)); static RETSIGTYPE fpecatch _PROTO((int sig)); static RETSIGTYPE intcatch _PROTO((int sig)); static int moreinput _PROTO((void)); static int yylex(); static void yyerror(); #line 55 "hoc.y" #ifndef YYSTYPE typedef union { Symbol *sym; /* symbol table pointer */ Inst *inst; /* machine instruction */ int narg; /* number of arguments */ Constant *Const;/* constant number */ } yystype; # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif #ifndef YYDEBUG # define YYDEBUG 0 #endif #define YYFINAL 275 #define YYFLAG -32768 #define YYNTBASE 81 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ #define YYTRANSLATE(x) ((unsigned)(x) <= 317 ? yytranslate[x] : 108) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 80, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 2, 74, 2, 2, 3, 4, 72, 70, 9, 71, 2, 73, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 51, 2, 58, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 59, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 75, 76, 77, 78 }; #if YYDEBUG static const short yyprhs[] = { 0, 0, 1, 4, 8, 12, 16, 20, 25, 29, 31, 33, 35, 39, 43, 47, 51, 55, 59, 63, 66, 69, 72, 75, 79, 83, 87, 91, 95, 99, 103, 106, 109, 112, 115, 120, 123, 128, 130, 133, 135, 137, 140, 142, 145, 147, 150, 153, 155, 157, 160, 163, 169, 176, 179, 182, 186, 191, 196, 204, 215, 219, 221, 223, 227, 229, 231, 233, 234, 235, 236, 238, 241, 245, 246, 248, 249, 251, 253, 255, 257, 259, 261, 263, 266, 272, 279, 284, 289, 293, 297, 301, 305, 309, 313, 317, 321, 324, 328, 332, 336, 340, 344, 348, 352, 356, 360, 364, 367, 373, 378, 380, 382, 386, 390, 391, 398, 399, 406, 408, 410, 412, 414, 416, 417, 419, 420, 423, 425, 429, 431, 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 469, 471, 473, 475, 477, 479, 481, 483, 485, 487, 489, 491, 493, 495 }; static const short yyrhs[] = { -1, 81, 82, 0, 81, 99, 82, 0, 81, 84, 82, 0, 81, 85, 82, 0, 81, 97, 82, 0, 81, 29, 19, 82, 0, 81, 1, 82, 0, 83, 0, 80, 0, 5, 0, 21, 51, 97, 0, 21, 52, 97, 0, 21, 53, 97, 0, 21, 54, 97, 0, 21, 55, 97, 0, 21, 56, 97, 0, 21, 57, 97, 0, 77, 21, 0, 21, 77, 0, 78, 21, 0, 21, 78, 0, 48, 51, 97, 0, 48, 52, 97, 0, 48, 53, 97, 0, 48, 54, 97, 0, 48, 55, 97, 0, 48, 56, 97, 0, 48, 57, 97, 0, 77, 48, 0, 48, 77, 0, 78, 48, 0, 48, 78, 0, 18, 21, 51, 97, 0, 18, 21, 0, 39, 103, 51, 97, 0, 97, 0, 10, 95, 0, 45, 0, 46, 0, 47, 19, 0, 38, 0, 38, 19, 0, 14, 0, 11, 95, 0, 12, 95, 0, 28, 0, 41, 0, 32, 95, 0, 31, 92, 0, 31, 92, 3, 104, 4, 0, 44, 92, 3, 107, 105, 4, 0, 20, 98, 0, 36, 19, 0, 6, 50, 19, 0, 89, 88, 85, 93, 0, 90, 88, 85, 93, 0, 90, 88, 85, 93, 26, 85, 93, 0, 91, 3, 96, 86, 95, 86, 96, 87, 85, 93, 0, 7, 94, 8, 0, 5, 0, 4, 0, 3, 97, 4, 0, 24, 0, 25, 0, 27, 0, 0, 0, 0, 85, 0, 94, 83, 0, 94, 83, 85, 0, 0, 97, 0, 0, 85, 0, 50, 0, 40, 0, 21, 0, 48, 0, 49, 0, 84, 0, 30, 92, 0, 30, 92, 3, 104, 4, 0, 43, 92, 3, 107, 105, 4, 0, 35, 3, 21, 4, 0, 22, 3, 97, 4, 0, 3, 97, 4, 0, 97, 70, 97, 0, 97, 71, 97, 0, 97, 72, 97, 0, 97, 73, 97, 0, 97, 74, 97, 0, 97, 15, 97, 0, 97, 79, 97, 0, 71, 97, 0, 97, 62, 97, 0, 97, 63, 97, 0, 97, 64, 97, 0, 97, 65, 97, 0, 97, 66, 97, 0, 97, 68, 97, 0, 97, 69, 97, 0, 97, 67, 97, 0, 97, 61, 97, 0, 97, 60, 97, 0, 76, 97, 0, 97, 58, 97, 59, 97, 0, 42, 3, 107, 4, 0, 97, 0, 19, 0, 98, 9, 97, 0, 98, 9, 19, 0, 0, 33, 102, 100, 3, 4, 85, 0, 0, 34, 102, 101, 3, 4, 85, 0, 21, 0, 30, 0, 31, 0, 21, 0, 40, 0, 0, 106, 0, 0, 9, 106, 0, 97, 0, 106, 9, 97, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 18, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0 }; #endif #if YYDEBUG /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { 0, 88, 89, 90, 91, 92, 93, 94, 100, 102, 104, 105, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 133, 136, 138, 139, 140, 141, 142, 143, 144, 189, 190, 191, 192, 193, 194, 196, 199, 202, 205, 206, 207, 208, 211, 215, 219, 226, 228, 230, 232, 234, 236, 238, 241, 243, 245, 246, 247, 248, 250, 251, 253, 254, 256, 257, 258, 259, 261, 263, 264, 266, 269, 272, 273, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 301, 310, 311, 323, 325, 326, 327, 328, 330, 330, 333, 333, 337, 339, 340, 342, 344, 346, 347, 349, 350, 352, 353, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 358, 358, 358, 358, 358 }; #endif #if (YYDEBUG) || defined YYERROR_VERBOSE /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ static const char *const yytname[] = { "$", "error", "$undefined.", "'('", "')'", "';'", "'#'", "'{'", "'}'", "','", "EXIT", "BREAK", "CONT", "DEBUG", "LEVEL", "MOD", "PRCALLS", "IGNOREUNDEF", "LOCALCMD", "STRING", "PRINT", "VAR", "BLTIN", "UNDEF", "WHILE", "IF", "ELSE", "FOR", "PRNAMES", "INCLUDE", "FUNCTION", "PROCEDURE", "RETURN", "FUNC", "PROC", "READ", "SYSTEM", "LOCAL", "SET", "CONSTCMD", "CONST", "VERSION", "TYPE", "CALLFUNC", "CALLPROC", "ABORT", "DOEOF", "CHDIR", "ARG", "ARGCNT", "NUMBER", "'='", "ADDEQ", "SUBEQ", "MULEQ", "DIVEQ", "POWEQ", "REMEQ", "'?'", "'|'", "OR", "AND", "GT", "GE", "LT", "LE", "EQ", "NE", "APPROXEQ", "NOTAPPROXEQ", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARYMINUS", "NOT", "INCR", "DECR", "'^'", "'\\n'", "list", "newp", "newl", "asgn", "stmt", "fsc", "frp", "cond", "while", "if", "for", "begin", "end", "stmtlist", "opt_expr", "opt_stmt", "expr", "prlist", "defn", "@1", "@2", "procname", "constname", "opt_arglist", "opt_arglist1", "arglist", "identifier", 0 }; #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { 0, 81, 81, 81, 81, 81, 81, 81, 81, 82, 83, 83, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 94, 94, 95, 95, 96, 96, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 100, 99, 101, 99, 102, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { 0, 0, 2, 3, 3, 3, 3, 4, 3, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 4, 2, 4, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 5, 6, 2, 2, 3, 4, 4, 7, 10, 3, 1, 1, 3, 1, 1, 1, 0, 0, 0, 1, 2, 3, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 5, 6, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 4, 1, 1, 3, 3, 0, 6, 0, 6, 1, 1, 1, 1, 1, 0, 1, 0, 2, 1, 3, 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 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const short yydefact[] = { 1, 0, 0, 0, 11, 0, 69, 73, 73, 73, 44, 0, 0, 79, 0, 64, 65, 66, 47, 0, 67, 67, 73, 0, 0, 0, 0, 42, 0, 78, 48, 0, 67, 67, 39, 40, 0, 80, 81, 77, 0, 0, 0, 0, 10, 2, 9, 82, 0, 0, 0, 0, 0, 0, 8, 82, 0, 0, 70, 0, 37, 38, 74, 45, 46, 35, 111, 110, 53, 0, 0, 0, 0, 0, 0, 0, 20, 22, 0, 0, 83, 50, 49, 118, 119, 120, 114, 116, 0, 54, 43, 121, 122, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 31, 33, 96, 107, 19, 30, 21, 32, 4, 5, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 3, 88, 55, 60, 71, 0, 0, 12, 13, 14, 15, 16, 17, 18, 0, 7, 123, 123, 0, 0, 0, 0, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, 0, 23, 24, 25, 26, 27, 28, 29, 0, 68, 68, 76, 0, 94, 0, 106, 105, 97, 98, 99, 100, 101, 104, 102, 103, 89, 90, 91, 92, 93, 95, 72, 34, 113, 112, 87, 127, 0, 124, 0, 0, 0, 86, 36, 109, 125, 125, 63, 56, 57, 61, 73, 0, 84, 0, 51, 0, 0, 0, 0, 0, 0, 0, 108, 128, 115, 117, 126, 85, 52, 68, 75, 58, 0, 62, 0, 68, 59, 0, 0 }; static const short yydefgoto[] = { 1, 45, 46, 55, 207, 247, 271, 116, 49, 50, 51, 80, 244, 59, 61, 208, 60, 68, 53, 156, 157, 86, 93, 233, 255, 234, 194 }; static const short yypact[] = { -32768, 170, 3, 508,-32768, -36, 255, 508, 508, 508, -32768, 5, 420, -35, 26,-32768,-32768,-32768,-32768, 11, -32768,-32768, 508, 14, 14, 31, 22, 28, -12,-32768, -32768, 34,-32768,-32768,-32768,-32768, 36, 33,-32768,-32768, 508, 508, -10, -8,-32768,-32768,-32768, 3, 3, 49, 49, 53, 248, 3,-32768,-32768, 277, 38,-32768, 2, 529,-32768, 529,-32768,-32768, 7,-32768, 529, 58, 508, 508, 508, 508, 508, 508, 508,-32768,-32768, 508, 3, 70, 71,-32768,-32768,-32768,-32768,-32768,-32768, 54,-32768, -32768,-32768,-32768, 27, 631, 74, 76,-32768, 508, 508, 508, 508, 508, 508, 508,-32768,-32768, 12, 12,-32768, -32768,-32768,-32768,-32768,-32768, 508, 255, 255, 255, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, 508,-32768,-32768,-32768, -32768,-32768, 255, 508, 464, 529, 529, 529, 529, 529, 529, 529, 319,-32768, 508, 508, 78, 89, 96, 508, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768, 97, 631, 631, 529, 529, 529, 529, 529, 529, 529, 348,-32768,-32768,-32768, 98, 12, 501, 561, 159, -11, -11, -11, -11, -11, -11, -11, -11, -3, -3, 12, 12, 12, 12,-32768, 529,-32768, 529,-32768, 529, 100, 99, 101, 102, 103,-32768, 529, -32768, 104, 104,-32768,-32768, 83,-32768, 508, 508,-32768, 508,-32768, 255, 255, 508, 108, 110, 255, 98, 529, 529,-32768,-32768, 99,-32768,-32768,-32768, 255,-32768, 113, -32768, 255,-32768,-32768, 118,-32768 }; static const short yypgoto[] = { -32768, 1, 60, 119, -1, -137,-32768, 79,-32768,-32768, -32768, 18, -200,-32768, -7, -136, 24,-32768,-32768,-32768, -32768, 106,-32768, -23, -109, -120, -172 }; #define YYLAST 678 static const short yytable[] = { 48, 63, 64, 54, 119, 58, 245, 4, 4, 91, 141, 109, 119, 111, 57, 82, 69, 70, 71, 72, 73, 74, 75, 241, 242, 52, 65, 56, 92, 78, 79, 62, 62, 62, 88, 83, 67, 94, 110, 81, 112, 89, 76, 77, 84, 85, 62, 90, 113, 114, 95, 96, 115, 137, 138, 97, 118, 140, 143, 131, 132, 133, 134, 135, 107, 108, 268, 144, 136, 133, 134, 135, 273, 154, 155, 158, 136, 195, 159, 196, 153, 236, 44, 44, 98, 99, 100, 101, 102, 103, 104, 136, 237, 145, 146, 147, 148, 149, 150, 151, 238, 240, 152, 246, 249, 251, 252, 253, 250, 257, 105, 106, 264, 254, 265, 205, 206, 270, 275, 142, 47, 267, 197, 198, 199, 200, 201, 202, 203, 117, 87, 269, 235, 256, 263, 0, 0, 0, 0, 204, 0, 227, 0, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 0, 0, 0, 0, 0, 0, 228, 230, 0, 274, 2, 0, 3, 119, 4, 5, 6, 232, 232, 7, 8, 9, 239, 10, 0, 0, 0, 11, 0, 12, 13, 14, 0, 15, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 0, 0, 0, 0, 136, 0, 258, 40, 0, 0, 0, 0, 41, 42, 43, 0, 44, 261, 262, 4, 0, 0, 266, 0, 3, 0, 0, 5, 6, 119, 0, 7, 8, 9, 0, 10, 272, 62, 259, 11, 260, 12, 13, 14, 232, 15, 16, 139, 17, 18, 0, 20, 21, 22, 0, 0, 25, 26, 119, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 120, 0, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 231, 0, 0, 40, 136, 44, 0, 0, 41, 42, 43, 119, 120, 0, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 243, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 120, 0, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 3, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 66, 0, 13, 14, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 25, 0, 0, 0, 28, 29, 0, 31, 32, 0, 0, 0, 3, 37, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 229, 0, 13, 14, 0, 0, 0, 0, 40, 0, 0, 20, 0, 41, 42, 43, 25, 0, 0, 0, 28, 29, 0, 31, 32, 0, 0, 0, 3, 37, 38, 39, 0, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 13, 14, 0, 0, 0, 0, 40, 0, 0, 20, 0, 41, 42, 43, 25, 119, 0, 0, 28, 29, 0, 31, 32, 0, 0, 0, 0, 37, 38, 39, 120, 248, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 119, 0, 0, 40, 136, 0, 0, 0, 41, 42, 43, 120, 0, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 0, 0, 0, 0, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 0, 0, 0, 0, 136, 160, 161, 162, 163, 164, 0, 0, 0, 165, 0, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193 }; static const short yycheck[] = { 1, 8, 9, 2, 15, 6, 206, 5, 5, 21, 8, 21, 15, 21, 50, 22, 51, 52, 53, 54, 55, 56, 57, 195, 196, 1, 21, 3, 40, 3, 19, 7, 8, 9, 3, 21, 12, 3, 48, 21, 48, 19, 77, 78, 30, 31, 22, 19, 47, 48, 32, 33, 3, 52, 53, 19, 3, 19, 51, 70, 71, 72, 73, 74, 40, 41, 266, 9, 79, 72, 73, 74, 272, 3, 3, 21, 79, 3, 51, 3, 79, 3, 80, 80, 51, 52, 53, 54, 55, 56, 57, 79, 3, 69, 70, 71, 72, 73, 74, 75, 4, 4, 78, 5, 4, 4, 4, 4, 9, 26, 77, 78, 4, 9, 4, 116, 117, 4, 0, 59, 1, 258, 98, 99, 100, 101, 102, 103, 104, 50, 24, 267, 155, 242, 254, -1, -1, -1, -1, 115, -1, 142, -1, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, -1, -1, -1, -1, -1, -1, 143, 144, -1, 0, 1, -1, 3, 15, 5, 6, 7, 154, 155, 10, 11, 12, 159, 14, -1, -1, -1, 18, -1, 20, 21, 22, -1, 24, 25, -1, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, -1, -1, -1, 79, -1, 247, 71, -1, -1, -1, -1, 76, 77, 78, -1, 80, 252, 253, 5, -1, -1, 257, -1, 3, -1, -1, 6, 7, 15, -1, 10, 11, 12, -1, 14, 271, 247, 248, 18, 250, 20, 21, 22, 254, 24, 25, 4, 27, 28, -1, 30, 31, 32, -1, -1, 35, 36, 15, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 4, -1, -1, 71, 79, 80, -1, -1, 76, 77, 78, 15, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 4, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 3, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 19, -1, 21, 22, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, 35, -1, -1, -1, 39, 40, -1, 42, 43, -1, -1, -1, 3, 48, 49, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 19, -1, 21, 22, -1, -1, -1, -1, 71, -1, -1, 30, -1, 76, 77, 78, 35, -1, -1, -1, 39, 40, -1, 42, 43, -1, -1, -1, 3, 48, 49, 50, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, 21, 22, -1, -1, -1, -1, 71, -1, -1, 30, -1, 76, 77, 78, 35, 15, -1, -1, 39, 40, -1, 42, 43, -1, -1, -1, -1, 48, 49, 50, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 15, -1, -1, 71, 79, -1, -1, -1, 76, 77, 78, 58, -1, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, -1, -1, -1, 79, 10, 11, 12, 13, 14, -1, -1, -1, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/local/share/bison/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; # if YYLSP_NEEDED YYLTYPE yyls; # endif }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # if YYLSP_NEEDED # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAX) # else # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAX) # endif /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). When YYLLOC_DEFAULT is run, CURRENT is set the location of the first token. By default, to implement support for ranges, extend its range to the last symbol. */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ #if YYPURE # if YYLSP_NEEDED # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) # else # define YYLEX yylex (&yylval, &yylloc) # endif # else /* !YYLSP_NEEDED */ # ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) # else # define YYLEX yylex (&yylval) # endif # endif /* !YYLSP_NEEDED */ #else /* !YYPURE */ # define YYLEX yylex () #endif /* !YYPURE */ /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #ifdef YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif #line 315 "/usr/local/share/bison/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM # define YYPARSE_PARAM_DECL # else # define YYPARSE_PARAM_ARG YYPARSE_PARAM # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; # endif #else /* !YYPARSE_PARAM */ # define YYPARSE_PARAM_ARG # define YYPARSE_PARAM_DECL #endif /* !YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ # ifdef YYPARSE_PARAM int yyparse (void *); # else int yyparse (void); # endif #endif /* YY_DECL_VARIABLES -- depending whether we use a pure parser, variables are global, or local to YYPARSE. */ #define YY_DECL_NON_LSP_VARIABLES \ /* The lookahead symbol. */ \ int yychar; \ \ /* The semantic value of the lookahead symbol. */ \ YYSTYPE yylval; \ \ /* Number of parse errors so far. */ \ int yynerrs; #if YYLSP_NEEDED # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES \ \ /* Location data for the lookahead symbol. */ \ YYLTYPE yylloc; #else # define YY_DECL_VARIABLES \ YY_DECL_NON_LSP_VARIABLES #endif /* If nonreentrant, generate the variables here. */ #if !YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ int yyparse (YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL { /* If reentrant, generate the variables here. */ #if YYPURE YY_DECL_VARIABLES #endif /* !YYPURE */ register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yychar1 = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #if YYLSP_NEEDED /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; #endif #if YYLSP_NEEDED # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else # define YYPOPSTACK (yyvsp--, yyssp--) #endif YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYLSP_NEEDED YYLTYPE yyloc; #endif /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; #if YYLSP_NEEDED yylsp = yyls; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ # if YYLSP_NEEDED YYLTYPE *yyls1 = yyls; /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; # else yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); # endif yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) goto yyoverflowlab; yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # if YYLSP_NEEDED YYSTACK_RELOCATE (yyls); # endif # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; #if YYLSP_NEEDED yylsp = yyls + yysize - 1; #endif YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyssp >= yyss + yystacksize - 1) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yychar1 = YYTRANSLATE (yychar); #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { YYFPRINTF (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ # ifdef YYPRINT YYPRINT (stderr, yychar, yylval); # endif YYFPRINTF (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to the semantic value of the lookahead token. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; #if YYLSP_NEEDED /* Similarly for the default location. Let the user run additional commands if for instance locations are ranges. */ yyloc = yylsp[1-yylen]; YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); #endif #if YYDEBUG /* We have to keep this `#if YYDEBUG', since we use variables which are defined only if `YYDEBUG' is set. */ if (yydebug) { int yyi; YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 1: #line 88 "hoc.y" {showprompt=1;} break; case 4: #line 91 "hoc.y" {code2(popandforget,STOP);return 1;} break; case 5: #line 92 "hoc.y" {code(STOP);return 1;} break; case 6: #line 93 "hoc.y" {code2(print,STOP);return 1;} break; case 7: #line 94 "hoc.y" {code3(Include,(Inst)yyvsp[-1].sym,STOP);return 1;} break; case 8: #line 100 "hoc.y" {yyerrok;} break; case 9: #line 102 "hoc.y" {showprompt=1;} break; case 12: #line 107 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,assign);yyval.inst=yyvsp[0].inst;} break; case 13: #line 108 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,addeq);yyval.inst=yyvsp[0].inst;} break; case 14: #line 109 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,subeq);yyval.inst=yyvsp[0].inst;} break; case 15: #line 110 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,muleq);yyval.inst=yyvsp[0].inst;} break; case 16: #line 111 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,diveq);yyval.inst=yyvsp[0].inst;} break; case 17: #line 112 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,poweq);yyval.inst=yyvsp[0].inst;} break; case 18: #line 113 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,modeq);yyval.inst=yyvsp[0].inst;} break; case 19: #line 114 "hoc.y" {yyval.inst=code3(varpush,(Inst)yyvsp[0].sym,preinc);} break; case 20: #line 115 "hoc.y" {yyval.inst=code3(varpush,(Inst)yyvsp[-1].sym,postinc);} break; case 21: #line 116 "hoc.y" {yyval.inst=code3(varpush,(Inst)yyvsp[0].sym,predec);} break; case 22: #line 117 "hoc.y" {yyval.inst=code3(varpush,(Inst)yyvsp[-1].sym,postdec);} break; case 23: #line 119 "hoc.y" {defnonly("$"); code2(argassign,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 24: #line 121 "hoc.y" {defnonly("$");code2(argaddeq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 25: #line 122 "hoc.y" {defnonly("$");code2(argsubeq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 26: #line 123 "hoc.y" {defnonly("$");code2(argmuleq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 27: #line 124 "hoc.y" {defnonly("$");code2(argdiveq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 28: #line 125 "hoc.y" {defnonly("$");code2(argpoweq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 29: #line 126 "hoc.y" {defnonly("$");code2(argmodeq,(Inst)yyvsp[-2].narg);yyval.inst=yyvsp[0].inst;} break; case 30: #line 127 "hoc.y" {defnonly("$");yyval.inst=code2(argpreinc,(Inst)yyvsp[0].narg);} break; case 31: #line 128 "hoc.y" {defnonly("$");yyval.inst=code2(argpostinc,(Inst)yyvsp[-1].narg);} break; case 32: #line 129 "hoc.y" {defnonly("$");yyval.inst=code2(argpredec,(Inst)yyvsp[0].narg);} break; case 33: #line 130 "hoc.y" {defnonly("$");yyval.inst=code2(argpostdec,(Inst)yyvsp[-1].narg);} break; case 34: #line 131 "hoc.y" {defnonly("local"); code3(varpush,(Inst)yyvsp[-2].sym,makelocal);yyval.inst=yyvsp[0].inst;} break; case 35: #line 133 "hoc.y" {defnonly("local"); yyval.inst=code2(constpush,(Inst)&zero); code3(varpush,(Inst)yyvsp[0].sym,makelocal);} break; case 36: #line 136 "hoc.y" {code3(varpush,(Inst)yyvsp[-2].sym,makeconst);yyval.inst=yyvsp[0].inst;} break; case 37: #line 138 "hoc.y" {code(popandforget);} break; case 38: #line 139 "hoc.y" {if(yyval.inst=yyvsp[0].inst)code(exitn);else yyval.inst=code(exit0);} break; case 39: #line 140 "hoc.y" {yyval.inst=code(Abort);} break; case 40: #line 141 "hoc.y" {yyval.inst=code(Doeof);} break; case 41: #line 142 "hoc.y" {yyval.inst=code2(Chdir,(Inst)yyvsp[0].sym);} break; case 42: #line 143 "hoc.y" {yyval.inst=code2(Set,(Inst)0);} break; case 43: #line 144 "hoc.y" {int sign=1;char *save2=(char *)yyvsp[0].sym; if(((char *)yyvsp[0].sym)[0]=='n' && ((char *)yyvsp[0].sym)[1]=='o'){ sign= -1; yyvsp[0].sym=(Symbol *) (((char *)yyvsp[0].sym)+2); } if(!strcmp((char *)yyvsp[0].sym,"ignoreundef")){ yyval.inst=code2(Set,(Inst)(sign*S_IGNOREUNDEF)); free(save2); } else if(!strcmp((char *)yyvsp[0].sym,"tracecalls")){ yyval.inst=code2(Set,(Inst)(sign*S_TRACECALLS)); free(save2); } else if(!strcmp((char *)yyvsp[0].sym,"allnames")){ yyval.inst=code2(Set,(Inst)(sign*S_ALLNAMES)); free(save2); } #if YYDEBUG else if(!strncmp((char *)yyvsp[0].sym,"debug",5)){ if((*(((char *)yyvsp[0].sym)+5))=='\0'&&sign!=-1) goto SETERROR; if(sign==-1){ if((*(((char*)yyvsp[0].sym)+5))!='\0') goto SETERROR; yydebug=0; } else { yydebug=atoi(((char *)yyvsp[0].sym)+5); free(save2); } yyval.inst=progp; } #endif else if(!strcmp((char *)yyvsp[0].sym,"all")){ if(sign==-1) goto SETERROR; yyval.inst=code2(Set,(Inst)S_ALL); free(save2); } else if(!strcmp((char *)yyvsp[0].sym,"default")){ if(sign==-1) goto SETERROR; yyval.inst=code2(Set,(Inst)S_DEFAULT); free(save2); } else if(!strncmp((char *)yyvsp[0].sym,"@=",2)){ if(sign==-1) goto SETERROR; atstring=(char *)yyvsp[0].sym + 2; yyval.inst=progp; } else { SETERROR: free(save2);execerror("bad set option",(char *)0); }} break; case 44: #line 189 "hoc.y" {yyval.inst=code(Free);} break; case 45: #line 190 "hoc.y" {if(yyval.inst=yyvsp[0].inst)code(Breakn);else yyval.inst=code(Break);} break; case 46: #line 191 "hoc.y" {if(yyval.inst=yyvsp[0].inst)code(contn);else yyval.inst=code(cont);} break; case 47: #line 192 "hoc.y" {yyval.inst=code(printnames);} break; case 48: #line 193 "hoc.y" {yyval.inst=code(printversion);} break; case 49: #line 194 "hoc.y" {defnonly("return");if(yyval.inst=yyvsp[0].inst)code(funcret); else yyval.inst=code(procret);} break; case 50: #line 197 "hoc.y" {yyval.inst=yyvsp[0].inst; code4(call,(Inst)yyvsp[-1].sym,(Inst)0,(Inst)PROCEDURE);} break; case 51: #line 200 "hoc.y" {yyval.inst=yyvsp[-3].inst; code4(call,(Inst)yyvsp[-4].sym,(Inst)yyvsp[-1].narg,(Inst)PROCEDURE);} break; case 52: #line 203 "hoc.y" {yyval.inst=yyvsp[-4].inst; code4(call,(Inst)yyvsp[-2].sym,(Inst)yyvsp[-1].narg,(Inst)PROCEDURE);} break; case 53: #line 205 "hoc.y" {yyval.inst=yyvsp[0].inst;code(doflush);} break; case 54: #line 206 "hoc.y" {yyval.inst=code2(System,(Inst)yyvsp[0].sym);} break; case 55: #line 207 "hoc.y" {Line((Inst)yyvsp[-1].Const,(Inst)yyvsp[0].sym);yyval.inst=progp;} break; case 56: #line 208 "hoc.y" { (yyvsp[-3].inst)[1] = (Inst)(yyvsp[-1].inst-(yyvsp[-3].inst+1)); /* body of loop */ (yyvsp[-3].inst)[2] = (Inst)(yyvsp[0].inst-(yyvsp[-3].inst+1));} break; case 57: #line 211 "hoc.y" { /* else-less if */ (yyvsp[-3].inst)[1] = (Inst)(yyvsp[-1].inst-(yyvsp[-3].inst+1)); /* thenpart */ (yyvsp[-3].inst)[2] = (Inst)0; /* no elsepart */ (yyvsp[-3].inst)[3] = (Inst)(yyvsp[0].inst-(yyvsp[-3].inst+1));} break; case 58: #line 215 "hoc.y" { /* if with else */ (yyvsp[-6].inst)[1] = (Inst)(yyvsp[-4].inst-(yyvsp[-6].inst+1)); /* thenpart */ (yyvsp[-6].inst)[2] = (Inst)(yyvsp[-1].inst-(yyvsp[-6].inst+1)); /* elsepart */ (yyvsp[-6].inst)[3] = (Inst)(yyvsp[0].inst-(yyvsp[-6].inst+1));} break; case 59: #line 219 "hoc.y" { if(yyvsp[-7].inst) (yyvsp[-9].inst)[1]=(Inst)(yyvsp[-7].inst-(yyvsp[-9].inst+1)); else (yyvsp[-9].inst)[1]=(Inst)0;/*1st*/ if(yyvsp[-5].inst) (yyvsp[-9].inst)[2]=(Inst)(yyvsp[-5].inst-(yyvsp[-9].inst+1)); else (yyvsp[-9].inst)[2]=(Inst)0;/*2nd*/ if(yyvsp[-3].inst) (yyvsp[-9].inst)[3]=(Inst)(yyvsp[-3].inst-(yyvsp[-9].inst+1)); else (yyvsp[-9].inst)[3]=(Inst)0;/*3rd*/ (yyvsp[-9].inst)[4]=(Inst)(yyvsp[-1].inst-(yyvsp[-9].inst+1));/*stmt*/ (yyvsp[-9].inst)[5]=(Inst)(yyvsp[0].inst-(yyvsp[-9].inst+1));/*end*/ } break; case 60: #line 226 "hoc.y" {yyval.inst=yyvsp[-1].inst;} break; case 61: #line 228 "hoc.y" {code(STOP); /*for's semi-colon*/} break; case 62: #line 230 "hoc.y" {code(STOP); /*for's right parenthesis*/} break; case 63: #line 232 "hoc.y" {code(STOP);yyval.inst=yyvsp[-1].inst;} break; case 64: #line 234 "hoc.y" {yyval.inst=code3(whilecode,STOP,STOP);} break; case 65: #line 236 "hoc.y" {yyval.inst=code(ifcode);code3(STOP,STOP,STOP);} break; case 66: #line 238 "hoc.y" {yyval.inst=code3(forcode,STOP,STOP); code3(STOP,STOP,STOP);} break; case 67: #line 241 "hoc.y" {yyval.inst=progp;} break; case 68: #line 243 "hoc.y" {code(STOP);yyval.inst=progp;} break; case 69: #line 245 "hoc.y" {yyval.inst=progp;} break; case 73: #line 250 "hoc.y" {yyval.inst=0;} break; case 75: #line 253 "hoc.y" {yyval.inst=0;} break; case 77: #line 256 "hoc.y" {yyval.inst=code2(constpush,(Inst)yyvsp[0].Const);} break; case 78: #line 257 "hoc.y" {yyval.inst=code2(constpush,(Inst)yyvsp[0].sym->u.Const);} break; case 79: #line 258 "hoc.y" {yyval.inst=code3(varpush,(Inst)yyvsp[0].sym,eval);} break; case 80: #line 259 "hoc.y" {defnonly("$"); yyval.inst=code2(arg,(Inst)yyvsp[0].narg);} break; case 81: #line 261 "hoc.y" {defnonly("$"); yyval.inst=code(argcnt);} break; case 83: #line 265 "hoc.y" {yyval.inst=yyvsp[0].inst; code4(call,(Inst)yyvsp[-1].sym,(Inst)0,(Inst)FUNCTION);} break; case 84: #line 267 "hoc.y" {yyval.inst=yyvsp[-3].inst; code4(call,(Inst)yyvsp[-4].sym,(Inst)yyvsp[-1].narg,(Inst)FUNCTION);} break; case 85: #line 270 "hoc.y" {yyval.inst=yyvsp[-4].inst; code4(call,(Inst)yyvsp[-2].sym,(Inst)yyvsp[-1].narg,(Inst)FUNCTION);} break; case 86: #line 272 "hoc.y" {yyval.inst=code2(varread,(Inst)yyvsp[-1].sym);} break; case 87: #line 273 "hoc.y" {yyval.inst=yyvsp[-1].inst; code2(bltin,(Inst)yyvsp[-3].sym->u.ptr);} break; case 88: #line 275 "hoc.y" {yyval.inst=yyvsp[-1].inst;} break; case 89: #line 276 "hoc.y" {code(add);} break; case 90: #line 277 "hoc.y" {code(sub);} break; case 91: #line 278 "hoc.y" {code(mul);} break; case 92: #line 279 "hoc.y" {code(Div);} break; case 93: #line 280 "hoc.y" {code(mod);} break; case 94: #line 281 "hoc.y" {code(Mod);} break; case 95: #line 282 "hoc.y" {code(power);} break; case 96: #line 283 "hoc.y" {yyval.inst=yyvsp[0].inst;code(negate);} break; case 97: #line 284 "hoc.y" {code(gt);} break; case 98: #line 285 "hoc.y" {code(ge);} break; case 99: #line 286 "hoc.y" {code(lt);} break; case 100: #line 287 "hoc.y" {code(le);} break; case 101: #line 288 "hoc.y" {code(eq);} break; case 102: #line 289 "hoc.y" {code(approxeq);} break; case 103: #line 290 "hoc.y" {code(notapproxeq);} break; case 104: #line 291 "hoc.y" {code(ne);} break; case 105: #line 292 "hoc.y" { move(yyval.inst=yyvsp[-2].inst,3); move(yyvsp[0].inst+3,1); code(STOP); (yyvsp[-2].inst)[0]=(Inst)and; (yyvsp[-2].inst)[1]=(Inst)(3+yyvsp[0].inst-yyvsp[-2].inst); (yyvsp[-2].inst)[2]=(Inst)(progp-yyvsp[-2].inst-1); (yyvsp[0].inst)[3]=STOP; } break; case 106: #line 301 "hoc.y" { move(yyval.inst=yyvsp[-2].inst,3); move(yyvsp[0].inst+3,1); code(STOP); (yyvsp[-2].inst)[0]=(Inst)or; (yyvsp[-2].inst)[1]=(Inst)(3+yyvsp[0].inst-yyvsp[-2].inst); (yyvsp[-2].inst)[2]=(Inst)(progp-yyvsp[-2].inst-1); (yyvsp[0].inst)[3]=STOP; } break; case 107: #line 310 "hoc.y" {yyval.inst=yyvsp[0].inst;code(not);} break; case 108: #line 311 "hoc.y" { move(yyval.inst=yyvsp[-4].inst,4); move(yyvsp[-2].inst+4,1); move(yyvsp[0].inst+5,1); code(STOP); (yyvsp[-4].inst)[0]=(Inst)conditional; (yyvsp[-4].inst)[1]=(Inst)(4+yyvsp[-2].inst-yyvsp[-4].inst); (yyvsp[-4].inst)[2]=(Inst)(5+yyvsp[0].inst-yyvsp[-4].inst); (yyvsp[-4].inst)[3]=(Inst)(progp-yyvsp[-4].inst-1); (yyvsp[-2].inst)[4]=STOP; (yyvsp[0].inst)[5]=STOP; } break; case 109: #line 323 "hoc.y" {yyval.inst=code2(findtype,(Inst)yyvsp[-1].sym);} break; case 110: #line 325 "hoc.y" {code(prexpr);} break; case 111: #line 326 "hoc.y" {yyval.inst=code2(prstr,(Inst)yyvsp[0].sym);} break; case 112: #line 327 "hoc.y" {code(prexpr);} break; case 113: #line 328 "hoc.y" {code2(prstr,(Inst)yyvsp[0].sym);} break; case 114: #line 330 "hoc.y" {if(!yyvsp[0].sym->u.defn)yyvsp[0].sym->u.defn=(Inst)deffunc; yyvsp[0].sym->type=FUNCTION;indef=1;} break; case 115: #line 332 "hoc.y" {code(procret);define(yyvsp[-4].sym);indef=0;} break; case 116: #line 333 "hoc.y" {if(!yyvsp[0].sym->u.defn)yyvsp[0].sym->u.defn=(Inst)defproc; yyvsp[0].sym->type=PROCEDURE;indef=1;} break; case 117: #line 335 "hoc.y" {code(procret);define(yyvsp[-4].sym);indef=0;} break; case 118: #line 337 "hoc.y" {if(yyvsp[0].sym->type==VAR) execerror("attempt to make func/proc with a variable name",yyvsp[0].sym->name);} break; case 121: #line 342 "hoc.y" {if(yyvsp[0].sym->type==VAR) execerror("attempt to make constant with a variable name",yyvsp[0].sym->name);} break; case 123: #line 346 "hoc.y" {yyval.narg=0;} break; case 124: #line 347 "hoc.y" {yyval.narg=yyvsp[0].narg;} break; case 125: #line 349 "hoc.y" {yyval.narg=0;} break; case 126: #line 350 "hoc.y" {yyval.narg=yyvsp[0].narg;} break; case 127: #line 352 "hoc.y" {yyval.narg=1;} break; case 128: #line 353 "hoc.y" {yyval.narg=yyvsp[-2].narg+1;} break; } #line 705 "/usr/local/share/bison/bison.simple" yyvsp -= yylen; yyssp -= yylen; #if YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif *++yyvsp = yyval; #if YYLSP_NEEDED *++yylsp = yyloc; #endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else #endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1; /*--------------------------------------------------. | yyerrlab1 -- error raised explicitly by an action | `--------------------------------------------------*/ yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; /*-------------------------------------------------------------------. | yyerrdefault -- current state does not do anything special for the | | error token. | `-------------------------------------------------------------------*/ yyerrdefault: #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault; #endif /*---------------------------------------------------------------. | yyerrpop -- pop the current state because it cannot handle the | | error token | `---------------------------------------------------------------*/ yyerrpop: if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #if YYLSP_NEEDED yylsp--; #endif #if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); } #endif /*--------------. | yyerrhandle. | `--------------*/ yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; #if YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; /*---------------------------------------------. | yyoverflowab -- parser overflow comes here. | `---------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; } #line 359 "hoc.y" #include #include jmp_buf begin; char **gargv; int gargc; char *progname; int lineno=1; char *infile; FILE *fin; int c,nlstate=1; static int endfile=0; int interactive; static char *SCCSID="@(#)NYH HOC - by Brian Kernighan, Rob Pike, Nadav Har'El"; static int yylex() { /* On interactive sessions (read file is stdin, and it is connected to a terminal, we show a prompt on new lines. If this is the first lexical symbol in a complete statement, showprompt is still 1 (see yacc code above) and we show a "hoc>" prompt. Otherwise, we output a tab if currently defining a func or proc, or output a ">" otherwise (e.g., in the middle of a stmtlist). */ if(interactive && nlstate){ if(showprompt) fprintf(stderr,"hoc> "); else if(indef) fprintf(stderr,"\t"); else fprintf(stderr,"> "); showprompt=0; } BEGYYLEX: #ifdef MSDOS /* if in MSDOS there may be junk cr's and ^Z's (eof) */ while((c=getc(fin))==' '||c=='\t'||c=='\r'||c=='\032')nlstate=0; #else /* there is no need to set nlstate=0 for each and every space character, but we don't care since this such a fast operation */ while((c=getc(fin))==' '||c=='\t')nlstate=0; #endif ; if(c==EOF) return 0; if ((c == '/') && lookahead() == '*'){ getc(fin); /*throw out the * */ if(!skipc()){nlstate=0; return 0;} nlstate=0; goto BEGYYLEX; } /* If we see a backward slash followed by a \n or \r then we discard the backward slash and all \n or \r's that follow it. Note that \ can not be used to continue, for example, an identifier name on the next line - it can only be used between two different lexical symbols. */ if(c == '\\'){ int z; if((z=lookahead())=='\r' || z=='\n'){ z=getc(fin); while(z=='\r'||z=='\n'){ if(z=='\n'){ lineno++; nlstate=1; } z=getc(fin); } if(z==EOF) return 0; else ungetc(z,fin); goto BEGYYLEX; } } /* support for nroff commands inside a hoc file is there for historic reasons. at least when in interactive mode we don't have to support it. */ if(c=='.' && nlstate && !interactive){ while((c=getc(fin))!='\n'&&c!=EOF) ; lineno++; goto BEGYYLEX; } if( (c=='.' && isdigit(lookahead())) || isdigit(c)){ double d; ungetc(c,fin); /* the condition above should guarantee that the following fscanf succeed. However, in the future I should probably check that it indeed succeeds and else print a sanity check error otherwise. */ fscanf(fin,"%lf",&d); yylval.Const=installd(d); nlstate=0;return NUMBER; } if(c=='_'){ int z; if((z=lookahead())!='_'&&!isalnum(z)){ extern double last; yylval.sym=install("_",VAR,last); nlstate=0;return VAR; } } if(isalpha(c)||c=='_'|| (c=='@'&&(lookahead()=='_'||isalnum(lookahead()))) ){ Symbol *s; char sbuf[100], *p = sbuf; if(c=='@'){ int i; for(i=0;atstring[i];i++){ if(p>=sbuf+sizeof(sbuf)-1){ *p='\0'; execerror("@ string too long", sbuf); } *p++=atstring[i]; } c=getc(fin); } do { if (p>=sbuf+sizeof(sbuf)-1){ *p = '\0'; execerror("name too long", sbuf); } *p++=c; } while ((c=getc(fin))!=EOF&&(isalnum(c)||c=='_')); ungetc(c,fin); *p='\0'; if((s=lookup(sbuf))==0) s=install(sbuf,UNDEF,0.0); yylval.sym=s; nlstate=0;return s->type==UNDEF?VAR:s->type; } if(c=='$'){ int n=0; c=getc(fin); if(c=='#'){ nlstate=0;return ARGCNT; } else ungetc(c,fin); while (isdigit(c=getc(fin))) n=10*n+c-'0'; ungetc(c,fin); /* $0 is invalid. also, if n is large enough it may even become negative (since n is a twos-complement integer), and that is invalid too. */ if (n<=0) execerror("strange $...",(char *)0); yylval.narg=n; nlstate=0;return ARG; } if(c=='"'){ char sbuf[100],*p; for(p=sbuf;(c=getc(fin)) != '"'; p++){ if(c=='\n'||c==EOF) execerror("missing quote", (char *)0); if(p>=sbuf+sizeof(sbuf)-1){ *p='\0'; execerror("string too long", sbuf); } *p=backslash(c); } *p=0; yylval.sym=(Symbol *)emalloc(strlen(sbuf)+1); strcpy((char*)yylval.sym,sbuf); nlstate=0;return STRING; } switch(c){ case '>': nlstate=0; switch(c=getc(fin)){ case '=': return GE; case EOF: return GT; default: ungetc(c,fin); return GT; } case '<': nlstate=0; switch(c=getc(fin)){ case '=': return LE; case EOF: return LT; default: ungetc(c,fin); return LT; } case '=': nlstate=0; switch(c=getc(fin)){ case '=': return EQ; case EOF: return '='; default: ungetc(c,fin); return '='; } case '!': nlstate=0; switch(c=getc(fin)){ case '=': return NE; case '~': return NOTAPPROXEQ; case EOF: return NOT; default: ungetc(c,fin); return NOT; } case '|': nlstate=0; switch(c=getc(fin)){ case '|': return OR; case EOF: return '|'; default: ungetc(c,fin); return '|'; } case '&': nlstate=0; switch(c=getc(fin)){ case '&': return AND; case EOF: return '&'; default: ungetc(c,fin); return '&'; } case '+': nlstate=0; switch(c=getc(fin)){ case '+': return INCR; case '=': return ADDEQ; case EOF: return '+'; default: ungetc(c,fin); return '+'; } case '-': nlstate=0; switch(c=getc(fin)){ case '-': return DECR; case '=': return SUBEQ; case EOF: return '-'; default: ungetc(c,fin); return '-'; } case '*': nlstate=0; switch(c=getc(fin)){ case '=': return MULEQ; case EOF: return '*'; default: ungetc(c,fin); return '*'; } case '/': nlstate=0; switch(c=getc(fin)){ case '=': return DIVEQ; case EOF: return '/'; default: ungetc(c,fin); return '/'; } case '^': nlstate=0; switch(c=getc(fin)){ case '=': return POWEQ; case EOF: return '^'; default: ungetc(c,fin); return '^'; } case '~': nlstate=0; switch(c=getc(fin)){ case '~': return APPROXEQ; case EOF: return '~'; default: ungetc(c,fin); return '~'; } case '%': nlstate=0; switch(c=getc(fin)){ case '=': return REMEQ; case EOF: return '%'; default: ungetc(c,fin); return '%'; } case '\n': nlstate=1;lineno++;return '\n'; default: nlstate=0;return c; } } static int backslash(c) int c; { static char transtab[]="b\bf\fn\nr\rt\t"; if(c!='\\') return c; c=getc(fin); if(c>='0' && c<='7'){ int tmp; ungetc(c,fin); fscanf(fin,"%3o",&tmp); return tmp; } if(islower(c)&&strchr(transtab,c)) return strchr(transtab,c)[1]; return c; } static void defnonly(s) char *s; { if(!indef) execerror(s,"used outside definition"); } static void #ifdef RESEARCH yyerror(s,t) char *s, *t; #else yyerror(s) char *s; #endif { initcode(); *progbase=STOP; #ifndef RESEARCH warning(s,(char *)0); #else fprintf(stderr,"%s: ",progname); if(infile) fprintf(stderr, "%s: ", infile); fprintf(stderr, "%d: ", lineno); fprintf(stderr,s,t); #endif } void execerror(s,t) char *s,*t; { Frame *efp; for(efp=fp;efp>frame;efp--){ if(efp->locals){ /* free all local variables of current function */ /* same code as in ret() */ Local *tmp=efp->locals, *tmp1; while(tmp1=tmp){ tmp=tmp1->nextlocal; if(!tmp1->nextdef->nextdef){ /* next one is global/undef */ tmp1->real->u.val= tmp1->nextdef->val; tmp1->real->type= tmp1->nextdef->p.type; FREELOCAL(tmp1->nextdef); FREELOCAL(tmp1); continue; } tmp1->real->u.localptr=tmp1->nextdef; FREELOCAL(tmp1); } } } if(s){ /* regular call */ warning(s,t); } else { /* call by 'eof' */ endfile=1; } fseek(fin,0L,2); longjmp(begin,0); } /* Signal handlers. RETSIGTYPE, defined by configure, is usually void. */ /* Actually, the signal handler normally has an integer parameter, but we ignore it. */ static RETSIGTYPE fpecatch(sig) { execerror("floating point exception",(char *)0); } static RETSIGTYPE intcatch(sig) { execerror("interruped",(char *)0); } int main(argc,argv) char *argv[]; { #ifdef ALWAYSPRVER /* If ALWAYSPRVER, we show the version information every time hoc runs. If it is not defined (the default), we show version information only in interactive hoc sessions. */ versioninfo(); #endif progname=argv[0]; if(argc==1){ static char *stdinonly[]={ "-" }; gargv=stdinonly; gargc=1; } else { gargv=argv+1; gargc=argc-1; } init(); while(moreinput()) run(); /*nalloc_memory_show_fp(stdout);*/ exit(0); } static int moreinput() { MOREINPUT: if(gargc--<=0) return 0; if(fin&&fin!=stdin) fclose(fin); infile= *gargv++; lineno=1; interactive=0; if(strcmp(infile,"-")==0){ fin=stdin; infile=0; /* this is an interactive hoc if we're taking input from stdin, and stdin is connected to a terminal */ interactive=isatty(fileno(fin)); #ifndef ALWAYSPRVER if(interactive) versioninfo(); #endif return 1; } if(infile[0]=='-'&&infile[1]=='l'){ char *tmp; #ifdef NOLIBS fprintf(stderr,"%s: libraries not available on this system\n",progname); goto MOREINPUT; #else #ifndef LIBPREFIX #define LIBPREFIX "/usr/lib/hoclibs/LIB" #endif tmp=malloc(strlen(infile+2)+strlen(LIBPREFIX)+1); tmp[0]='\0'; strcat(tmp,LIBPREFIX); strcat(tmp,infile+2); infile=tmp; #endif } if((fin=fopen(infile,"r"))==NULL){ fprintf(stderr,"%s: can't open %s\n",progname,infile); goto MOREINPUT; } return 1; } void run() { setjmp(begin); if(endfile){ /* if 'eof' was called */ endfile=0; return; } nlstate=1; signal(SIGFPE,fpecatch); signal(SIGINT,intcatch); for(initcode();yyparse();initcode()) execute(progbase); } void warning(s,t) char *s,*t; { fprintf(stderr,"%s: %s",progname,s); if(t) fprintf(stderr, " %s",t); if(infile) fprintf(stderr, " in %s", infile); fprintf(stderr, " near line %d\n", lineno); } static int skipc() { /* this function RECURSIVELY skips all characters until a * / is matched */ char z; /* current character read */ while(1){ z=getc(fin); if((z=='/')&&(lookahead()=='*')){ /* recursive skipping of imbedded comments*/ getc(fin); /* throw out the * */ if(!skipc()) return 0; continue; } if((z=='*')&&(lookahead()=='/')){ /* end of comment */ z=getc(fin); /* throw out the / */ return 1; } if (z=='\n') ++lineno; if (z==EOF) return 0; } } static char lookahead() { int z; z=getc(fin); if(z==EOF) return 0; ungetc(z,fin); return((char)z); } /* versioninfo() shows version information suitable to be displayed when hoc starts running. Above, if ALWAYSPRVER, we show the version information every time hoc runs. If it is not defined (which is the default), we show version information only in interactive hoc sessions. */ void versioninfo(){ fprintf(stderr,"Welcome to the NYH HOC interpreter.\n"); fprintf(stderr,"By Brian Kernighan and Rob Pike 1984, Nadav Har'El 1986-1997.\n\n"); /* fprintf(stderr,"%s, %s.\n\n", version_array[0]+4,version_array[1]+4);*/ }