#ifdef __cplusplus #include extern "C" { extern void yyerror(char *); extern int yylex(); } #endif /* __cplusplus */ # line 2 "asm65.y" /* ---------------------------------------------------------------------- */ /* Copyright (C) 1992 by Natrlich! */ /* This file is copyrighted! */ /* Refer to the documentation for details. */ /* ---------------------------------------------------------------------- */ /*#define YYDEBUG*/ #include #include "defines.h" #undef DEBUG #include "structs.h" #include "nasm.h" #include "labels.h" #include "code.h" #include "buffer.h" #include "exprfast.h" #include "op.h" #if DEBUG #define bputchar( c) putchar( c) #define dbprintf( s) puts( s) #else #define dbputchar( c) #define dbprintf( s) #endif #ifdef NIL #undef NIL #endif #define NIL ((char *) 0) #define ENIL ((expr *) 0) extern int _in_instr, _in_doteq, _call_macro, wasstrlen, state, fully_mac65; extern buffer huge *bp; extern word __pc; static char undefined[] = { 9, 0, 'u','n','d','e','f','i','n','e','d' }, *lastident; static int footok; static lword fooval; #define adrmod footok /* screws the debugger of course (har har) */ typedef union { lword u; byte *b; char *c; expr *e; lexpr *l; } YYSTYPE; #define _ul lword # define T_DOTEQ 257 # define T_IF 258 # define T_ELSE 259 # define T_LOCAL 260 # define T_EOL 261 # define T_NUMBER 262 # define T_ZEXT 263 # define T_ENDIF 264 # define T_ORG 265 # define T_DS 266 # define T_WORD 267 # define T_BYTE 268 # define T_SBYTE 269 # define T_OPT 270 # define T_MACRO 271 # define T_ENDM 272 # define T_END 273 # define T_NUM 274 # define T_OBJ 275 # define T_MLIST 276 # define T_INCLUDE 277 # define T_ERROR 278 # define T_TITLE 279 # define T_DBYTE 280 # define T_TAB 281 # define T_FLOAT 282 # define T_CBYTE 283 # define T_XREF 284 # define T_SET 285 # define T_LIST 286 # define T_ERR 287 # define T_ACCU 288 # define T_CHAR 289 # define T_NOT 290 # define T_DEF 291 # define T_REF 292 # define T_CLIST 293 # define T_EJECT 294 # define T_PAGE 295 # define T_XFLOAT 296 # define T_UNDEF 297 # define T_WARN 298 # define T_REPT 299 # define T_CALL 300 # define T_IDENT 301 # define T_STRING 302 # define T_LABEL 303 # define T_FILE 304 # define T_EXPR 305 # define T_INSTR 306 # define T_NO 307 # define T_OR 308 # define T_AND 309 # define T_LEQ 310 # define T_GEQ 311 # define T_NEQ 312 # define MIDDLE 313 # define HIGHEST 314 # define T_MPARA 315 # define T_MSPARA 316 # define T_MLPARA 317 # define T_MLSPARA 318 # define T_PARA 319 # define REALHIGH 320 #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 extern int yychar; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif /* __YYSCLASS defines the scoping/storage class for global objects * that are NOT renamed by the -p option. By default these names * are going to be 'static' so that multi-definition errors * will not occur with multiple parsers. * If you want (unsupported) access to internal names you need * to define this to be null so it implies 'extern' scope. * This should not be used in conjunction with -p. */ #ifndef __YYSCLASS # define __YYSCLASS static #endif YYSTYPE yylval; __YYSCLASS YYSTYPE yyval; typedef int yytabelem; # define YYERRCODE 256 __YYSCLASS yytabelem yyexca[] ={ -1, 0, 0, 4, 258, 4, 259, 4, 260, 4, 261, 4, 263, 4, 264, 4, 265, 4, 266, 4, 267, 4, 268, 4, 269, 4, 270, 4, 271, 4, 273, 4, 277, 4, 278, 4, 279, 4, 280, 4, 281, 4, 282, 4, 283, 4, 285, 4, 295, 4, 297, 4, 298, 4, 299, 4, 300, 4, 301, 4, 303, 4, 306, 4, -2, 0, -1, 1, 0, -1, -2, 0, -1, 6, 0, 14, 261, 14, -2, 8, -1, 153, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 68, -1, 154, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 69, -1, 155, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 70, -1, 156, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 71, -1, 157, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 72, -1, 166, 310, 0, 311, 0, 61, 0, 312, 0, 62, 0, 60, 0, -2, 81, }; # define YYNPROD 117 # define YYLAST 598 __YYSCLASS yytabelem yyact[]={ 10, 11, 32, 8, 145, 20, 12, 13, 14, 15, 17, 19, 26, 29, 94, 31, 93, 92, 91, 30, 35, 33, 16, 25, 21, 18, 102, 27, 141, 126, 125, 101, 89, 53, 88, 71, 46, 34, 68, 28, 36, 24, 22, 23, 171, 6, 70, 37, 9, 3, 39, 48, 187, 47, 10, 11, 32, 137, 136, 20, 12, 13, 14, 15, 17, 19, 26, 29, 53, 31, 183, 46, 76, 30, 35, 33, 16, 25, 21, 18, 77, 27, 44, 184, 60, 128, 48, 53, 47, 179, 46, 34, 178, 28, 36, 24, 22, 23, 114, 176, 177, 63, 9, 113, 172, 48, 53, 47, 65, 46, 74, 170, 53, 169, 186, 46, 148, 44, 114, 111, 90, 112, 144, 113, 48, 96, 47, 142, 135, 117, 48, 127, 47, 7, 116, 117, 44, 181, 114, 111, 116, 112, 75, 113, 114, 111, 64, 112, 115, 113, 173, 72, 133, 134, 69, 44, 109, 119, 110, 143, 41, 44, 109, 119, 110, 66, 67, 98, 115, 38, 117, 5, 95, 4, 2, 116, 61, 138, 129, 114, 111, 49, 112, 99, 113, 1, 0, 0, 115, 167, 118, 0, 0, 0, 115, 117, 118, 109, 119, 110, 116, 86, 79, 81, 114, 111, 0, 112, 0, 113, 0, 83, 168, 80, 84, 174, 0, 0, 0, 0, 82, 85, 109, 119, 110, 86, 79, 81, 0, 115, 0, 118, 182, 0, 78, 83, 0, 80, 84, 185, 0, 0, 0, 0, 82, 85, 40, 0, 0, 0, 0, 0, 117, 50, 115, 180, 118, 116, 0, 0, 0, 114, 111, 0, 112, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 54, 45, 55, 56, 0, 0, 0, 0, 50, 0, 0, 0, 51, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 57, 115, 0, 118, 0, 54, 45, 55, 56, 0, 0, 0, 0, 0, 0, 0, 50, 51, 139, 0, 0, 52, 50, 0, 54, 45, 55, 56, 0, 0, 0, 0, 0, 0, 0, 57, 51, 130, 0, 0, 52, 0, 0, 54, 45, 55, 56, 0, 0, 54, 45, 55, 56, 0, 57, 51, 0, 0, 0, 52, 0, 51, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 43, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 104, 108, 107, 106, 0, 105, 104, 108, 107, 106, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 58, 59, 120, 121, 122, 123, 124, 0, 0, 0, 0, 73, 0, 0, 87, 0, 0, 104, 108, 107, 106, 0, 0, 0, 0, 0, 97, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 107, 106, 0, 0, 0, 0, 0, 131, 132, 131, 131, 0, 0, 0, 0, 140, 0, 0, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 0, 0, 0, 0, 0, 146, 0, 147, 0, 0, 149, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 140, 0, 0, 0, 0, 0, 0, 0, 140 }; __YYSCLASS yytabelem yypact[]={ -207, -3000, -258, -3000, -214, -3000, -11, -3000, -3000, -3000, 70, -3000, -3000, 70, 70, 70, 70, 65, 65, 65, -263, -250, -266, -3000, 70, 70, -73, 70, -267, -269, 85, -3000, -3000, -284, -285, -286, -288, -3000, -204, 64, -3000, -9, -3000, 102, 70, 70, 70, 70, 70, -3000, -3000, -3000, -3000, -3000, -3000, -271, -272, -3000, -3000, -3000, -3000, 87, -3000, -3000, 45, 70, 45, 45, -3000, 84, -3000, -3000, 26, -273, -3000, 83, -3000, -3000, -49, -3000, -3000, -3000, -3000, -3000, -3000, -3000, -3000, 78, -3000, -3000, -300, -3000, -3000, -3000, -3000, -3000, 70, -3000, 70, -3000, 72, 70, 70, -3000, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 96, -3000, -3000, 219, 219, -3000, -3000, 70, -3000, 69, -3000, -3000, 67, -3000, -3000, -252, -3000, -3000, 60, -3000, -3000, -3000, -73, -3000, 70, -3000, -3000, -3000, 11, 48, -3000, 162, 137, 219, 219, 219, 219, 219, 56, 56, -3000, -3000, -3000, 76, 76, 76, 219, -3000, -3000, 45, -3000, -3000, -3000, 26, -3000, -3000, -3000, -3000, -18, 39, -3000, 26, -3000, 73, -37, -3000, -3000, -3000 }; __YYSCLASS yytabelem yypgo[]={ 0, 185, 183, 386, 181, 146, 415, 178, 177, 85, 57, 84, 176, 58, 174, 173, 171, 169, 133, 167, 160, 154, 151, 150, 142, 137, 72, 80 }; __YYSCLASS yytabelem yyr1[]={ 0, 1, 1, 14, 14, 14, 16, 16, 17, 15, 15, 15, 19, 15, 15, 15, 20, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 22, 18, 23, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 12, 11, 11, 5, 5, 7, 7, 9, 9, 8, 8, 10, 25, 10, 13, 13, 21, 21, 24, 24, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27 }; __YYSCLASS yytabelem yyr2[]={ 0, 4, 2, 5, 0, 3, 4, 2, 1, 7, 9, 7, 1, 9, 3, 3, 1, 7, 5, 3, 3, 5, 5, 5, 5, 7, 7, 7, 5, 4, 5, 1, 7, 1, 11, 5, 5, 9, 5, 5, 7, 3, 3, 5, 5, 5, 5, 7, 7, 11, 11, 5, 7, 3, 3, 1, 3, 3, 2, 3, 3, 5, 5, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 2, 3, 2, 7, 7, 1, 3, 3, 2, 7, 3, 3, 2, 1, 9, 1, 3, 2, 6, 2, 6, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2 }; __YYSCLASS yytabelem yychk[]={ -3000, -1, -14, 256, -15, -16, 303, -18, 261, 306, 258, 259, 264, 265, 266, 267, 280, 268, 283, 269, 263, 282, 300, 301, 299, 281, 270, 285, 297, 271, 277, 273, 260, 279, 295, 278, 298, 261, -17, 61, 257, -20, -6, -3, 91, 290, 45, 62, 60, -4, 262, 301, 305, 42, 289, 291, 292, 319, -6, -6, -11, -12, -6, -11, -5, 43, -5, -5, 301, -21, 296, 301, -22, -6, -11, -24, -26, -27, 307, 275, 286, 276, 293, 284, 287, 294, 274, -6, 301, 301, 35, 302, 302, 302, 302, -18, 61, -6, -19, -2, -6, 40, 35, 288, 309, 308, 312, 311, 310, 60, 62, 43, 45, 47, 42, 92, 38, 33, 94, 61, -3, -3, -3, -3, -3, 301, 301, 44, -9, -7, 302, -6, -6, -9, -9, 44, -13, -10, -8, 302, -6, 301, 44, -27, 44, 304, -6, -6, 44, -6, -6, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 93, -11, 44, 44, 296, 44, -23, -26, -6, 88, 89, 44, 41, -9, -25, -13, 88, 44, -10, 41, 89 }; __YYSCLASS yytabelem yydef[]={ -2, -2, 2, 5, 1, 3, -2, 15, 7, 16, 0, 19, 20, 0, 0, 0, 0, 91, 91, 91, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 41, 42, 0, 0, 0, 0, 6, 0, 0, 12, 55, 18, 64, 0, 0, 0, 0, 0, 86, 56, 57, 58, 59, 60, 0, 0, 63, 21, 22, 23, 88, 87, 24, 0, 0, 0, 0, 28, 29, 103, 30, 101, 0, 35, 36, 105, 107, 0, 109, 110, 111, 112, 113, 114, 115, 116, 0, 38, 39, 0, 43, 44, 45, 46, 9, 0, 11, 0, 17, 53, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 83, 84, 85, 61, 62, 0, 25, 94, 92, 93, 0, 26, 27, 0, 32, 102, 98, 96, 97, 33, 0, 108, 0, 40, 10, 13, 0, 0, 51, 66, 67, -2, -2, -2, -2, -2, 73, 74, 75, 76, 77, 78, 79, 80, -2, 65, 89, 0, 90, 104, 99, 101, 106, 37, 47, 48, 0, 52, 95, 0, 34, 0, 0, 100, 49, 50 }; typedef struct { char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG __YYSCLASS yytoktype yytoks[] = { "T_DOTEQ", 257, "T_IF", 258, "T_ELSE", 259, "T_LOCAL", 260, "T_EOL", 261, "T_NUMBER", 262, "T_ZEXT", 263, "T_ENDIF", 264, "T_ORG", 265, "T_DS", 266, "T_WORD", 267, "T_BYTE", 268, "T_SBYTE", 269, "T_OPT", 270, "T_MACRO", 271, "T_ENDM", 272, "T_END", 273, "T_NUM", 274, "T_OBJ", 275, "T_MLIST", 276, "T_INCLUDE", 277, "T_ERROR", 278, "T_TITLE", 279, "T_DBYTE", 280, "T_TAB", 281, "T_FLOAT", 282, "T_CBYTE", 283, "T_XREF", 284, "T_SET", 285, "T_LIST", 286, "T_ERR", 287, "T_ACCU", 288, "T_CHAR", 289, "T_NOT", 290, "T_DEF", 291, "T_REF", 292, "T_CLIST", 293, "T_EJECT", 294, "T_PAGE", 295, "T_XFLOAT", 296, "T_UNDEF", 297, "T_WARN", 298, "T_REPT", 299, "T_CALL", 300, "T_IDENT", 301, "T_STRING", 302, "T_LABEL", 303, "T_FILE", 304, "T_EXPR", 305, "T_INSTR", 306, ",", 44, "T_NO", 307, "T_OR", 308, "T_AND", 309, "T_LEQ", 310, "T_GEQ", 311, "=", 61, "T_NEQ", 312, ">", 62, "<", 60, "MIDDLE", 313, "!", 33, "^", 94, "&", 38, "+", 43, "-", 45, "*", 42, "/", 47, "\\", 92, "HIGHEST", 314, "T_MPARA", 315, "T_MSPARA", 316, "T_MLPARA", 317, "T_MLSPARA", 318, "T_PARA", 319, "REALHIGH", 320, "-unknown-", -1 /* ends search */ }; __YYSCLASS char * yyreds[] = { "-no such reduction-", "file : source line", "file : source", "source : source sline", "source : /* empty */", "source : error", "sline : line T_EOL", "sline : T_EOL", "line : T_LABEL", "line : T_LABEL nline", "line : T_LABEL '=' '=' __expr", "line : T_LABEL '=' __expr", "line : T_LABEL T_DOTEQ", "line : T_LABEL T_DOTEQ __expr", "line : T_LABEL", "line : nline", "nline : T_INSTR", "nline : T_INSTR irest", "nline : T_IF __expr", "nline : T_ELSE", "nline : T_ENDIF", "nline : T_ORG __expr", "nline : T_DS __expr", "nline : T_WORD i_expr", "nline : T_DBYTE i_expr", "nline : T_BYTE modif si_expr", "nline : T_CBYTE modif si_expr", "nline : T_SBYTE modif si_expr", "nline : T_ZEXT T_IDENT", "nline : T_FLOAT f_expr", "nline : T_CALL T_IDENT", "nline : T_IDENT", "nline : T_IDENT ei_expr", "nline : T_REPT __expr T_IDENT", "nline : T_REPT __expr T_IDENT ei_expr", "nline : T_TAB i_expr", "nline : T_OPT o_expr", "nline : T_SET __expr ',' __expr", "nline : T_UNDEF T_IDENT", "nline : T_MACRO T_IDENT", "nline : T_INCLUDE '#' T_FILE", "nline : T_END", "nline : T_LOCAL", "nline : T_TITLE T_STRING", "nline : T_PAGE T_STRING", "nline : T_ERROR T_STRING", "nline : T_WARN T_STRING", "irest : __expr ',' 'X'", "irest : __expr ',' 'Y'", "irest : '(' __expr ',' 'X' ')'", "irest : '(' __expr ')' ',' 'Y'", "irest : '#' __expr", "irest : '(' __expr ')'", "irest : __expr", "irest : T_ACCU", "irest : /* empty */", "a_expr : T_NUMBER", "a_expr : T_IDENT", "a_expr : T_EXPR", "a_expr : '*'", "a_expr : T_CHAR", "a_expr : T_DEF T_IDENT", "a_expr : T_REF T_IDENT", "a_expr : T_PARA", "__expr : s_expr", "s_expr : '[' s_expr ']'", "s_expr : s_expr T_AND s_expr", "s_expr : s_expr T_OR s_expr", "s_expr : s_expr T_NEQ s_expr", "s_expr : s_expr T_GEQ s_expr", "s_expr : s_expr T_LEQ s_expr", "s_expr : s_expr '<' s_expr", "s_expr : s_expr '>' s_expr", "s_expr : s_expr '+' s_expr", "s_expr : s_expr '-' s_expr", "s_expr : s_expr '/' s_expr", "s_expr : s_expr '*' s_expr", "s_expr : s_expr '\\' s_expr", "s_expr : s_expr '&' s_expr", "s_expr : s_expr '!' s_expr", "s_expr : s_expr '^' s_expr", "s_expr : s_expr '=' s_expr", "s_expr : T_NOT s_expr", "s_expr : '-' s_expr", "s_expr : '>' s_expr", "s_expr : '<' s_expr", "s_expr : a_expr", "fubar : __expr", "i_expr : fubar", "i_expr : fubar ',' i_expr", "modif : '+' __expr ','", "modif : /* empty */", "t_expr : T_STRING", "t_expr : __expr", "si_expr : t_expr", "si_expr : t_expr ',' si_expr", "u_expr : T_STRING", "u_expr : __expr", "mi_expr : u_expr", "mi_expr : u_expr ','", "mi_expr : u_expr ',' mi_expr", "ei_expr : /* empty */", "ei_expr : mi_expr", "f_expr : T_XFLOAT", "f_expr : f_expr ',' T_XFLOAT", "o_expr : op2", "o_expr : o_expr ',' op2", "op2 : option", "op2 : T_NO option", "option : T_OBJ", "option : T_LIST", "option : T_MLIST", "option : T_CLIST", "option : T_XREF", "option : T_ERR", "option : T_EJECT", "option : T_NUM", }; #endif /* YYDEBUG */ #define YYFLAG (-3000) /* @(#) $Revision: 66.3 $ */ /* ** Skeleton parser driver for yacc output */ #if defined(NLS) && !defined(NL_SETN) #include #endif #ifndef nl_msg #define nl_msg(i,s) (s) #endif /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #ifndef __RUNTIME_YYMAXDEPTH #define YYACCEPT return(0) #define YYABORT return(1) #else #define YYACCEPT {free_stacks(); return(0);} #define YYABORT {free_stacks(); return(1);} #endif #define YYBACKUP( newtoken, newvalue )\ {\ if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( (nl_msg(30001,"syntax error - cannot backup")) );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ /* define for YYFLAG now generated by yacc program. */ /*#define YYFLAG (FLAGVAL)*/ /* ** global variables used by the parser */ # ifndef __RUNTIME_YYMAXDEPTH __YYSCLASS YYSTYPE yyv[ YYMAXDEPTH ]; /* value stack */ __YYSCLASS int yys[ YYMAXDEPTH ]; /* state stack */ # else __YYSCLASS YYSTYPE *yyv; /* pointer to malloc'ed value stack */ __YYSCLASS int *yys; /* pointer to malloc'ed stack stack */ #ifdef __cplusplus extern char *malloc(int); extern char *realloc(char *, int); extern void free(); # else extern char *malloc(); extern char *realloc(); extern void free(); # endif /* __cplusplus */ static int allocate_stacks(); static void free_stacks(); # ifndef YYINCREMENT # define YYINCREMENT (YYMAXDEPTH/2) + 10 # endif # endif /* __RUNTIME_YYMAXDEPTH */ long yymaxdepth = YYMAXDEPTH; __YYSCLASS YYSTYPE *yypv; /* top of value stack */ __YYSCLASS int *yyps; /* top of state stack */ __YYSCLASS int yystate; /* current state */ __YYSCLASS int yytmp; /* extra var (lasts between blocks) */ int yynerrs; /* number of errors */ __YYSCLASS int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ /* ** yyparse - return 0 if worked, 1 if syntax error not recovered from */ int yyparse() { register YYSTYPE *yypvt; /* top of value stack for $vars */ /* ** Initialize externals - yyparse may be called more than once */ # ifdef __RUNTIME_YYMAXDEPTH if (allocate_stacks()) YYABORT; # endif yypv = &yyv[-1]; yyps = &yys[-1]; yystate = 0; yytmp = 0; yynerrs = 0; yyerrflag = 0; yychar = -1; goto yystack; { register YYSTYPE *yy_pv; /* top of value stack */ register int *yy_ps; /* top of state stack */ register int yy_state; /* current state */ register int yy_n; /* internal state number info */ /* ** get globals into registers. ** branch to here only if YYBACKUP was called. */ yynewstate: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; goto yy_newstate; /* ** get globals into registers. ** either we just started, or we just finished a reduction */ yystack: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; /* ** top of for (;;) loop while no reductions done */ yy_stack: /* ** put a state and value onto the stacks */ #if YYDEBUG /* ** if debugging, look up token value in list of value vs. ** name pairs. 0 and negative (-1) are special values. ** Note: linear search is used since time is not a real ** consideration while debugging. */ if ( yydebug ) { register int yy_i; printf( "State %d, token ", yy_state ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ { # ifndef __RUNTIME_YYMAXDEPTH yyerror( (nl_msg(30002,"yacc stack overflow")) ); YYABORT; # else /* save old stack bases to recalculate pointers */ YYSTYPE * yyv_old = yyv; int * yys_old = yys; yymaxdepth += YYINCREMENT; yys = (int *) realloc(yys, yymaxdepth * sizeof(int)); yyv = (YYSTYPE *) realloc(yyv, yymaxdepth * sizeof(YYSTYPE)); if (yys==0 || yyv==0) { yyerror( (nl_msg(30002,"yacc stack overflow")) ); YYABORT; } /* Reset pointers into stack */ yy_ps = (yy_ps - yys_old) + yys; yyps = (yyps - yys_old) + yys; yy_pv = (yy_pv - yyv_old) + yyv; yypv = (yypv - yyv_old) + yyv; # endif } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( (nl_msg(30003,"syntax error")) ); yynerrs++; goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; yynerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; printf( "Error recovery discards " ); if ( yychar == 0 ) printf( "token end-of-file\n" ); else if ( yychar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 3: # line 105 "asm65.y" { inc_line(); _in_instr = 0; dbputchar( '\n'); } break; case 5: # line 112 "asm65.y" { nterror("unwanted token appeared", yychar); while( (yychar = yylex()) && yychar != T_EOL); inc_line(); if( ! yychar) return; yyerrok; yyclearin; } break; case 8: # line 129 "asm65.y" { enter_pclabel( yypvt[-0].c); } break; case 9: # line 133 "asm65.y" { dbprintf("T_LABEL nline [done with line]\n\n"); } break; case 10: # line 137 "asm65.y" { enter_elabel( yypvt[-3].c, yypvt[-0].e, L_ZERO | L_LINKZERO); dbprintf("T_LABEL == s_expr [done with line]\n\n"); } break; case 11: # line 142 "asm65.y" { enter_elabel( yypvt[-2].c, yypvt[-0].e, L_NORMAL); dbprintf("T_LABEL = s_expr [done with line]\n\n"); } break; case 12: # line 146 "asm65.y" { _in_doteq = 1; } break; case 13: # line 148 "asm65.y" { _in_doteq = 0; enter_elabel( yypvt[-3].c, yypvt[-0].e, L_EQU); dbprintf("T_LABEL .= s_expr [done with line]\n\n"); } break; case 14: # line 153 "asm65.y" { enter_pclabel( yypvt[-0].c); dbprintf("T_LABEL [done with line]\n\n"); } break; case 15: # line 157 "asm65.y" { dbprintf("regular line [done]\n\n"); } break; case 16: # line 163 "asm65.y" { _in_instr = 1; } break; case 17: # line 164 "asm65.y" { generate( yypvt[-2].b,adrmod,yypvt[-0].e);} break; case 18: # line 165 "asm65.y" { if_treat( yypvt[-0].e); } break; case 19: # line 166 "asm65.y" { else_treat(); } break; case 20: # line 167 "asm65.y" { endif_treat(); } break; case 21: # line 168 "asm65.y" { setorg( yypvt[-0].e, 0); } break; case 22: # line 169 "asm65.y" { reserve( yypvt[-0].e); } break; case 23: # line 170 "asm65.y" { dropwords( yypvt[-0].l); } break; case 24: # line 171 "asm65.y" { dropdbytes( yypvt[-0].l); } break; case 25: # line 172 "asm65.y" { dropbytes( yypvt[-1].e, yypvt[-0].l, 0); } break; case 26: # line 173 "asm65.y" { dropbytes( yypvt[-1].e, yypvt[-0].l, 1); } break; case 27: # line 174 "asm65.y" { dropsbytes( yypvt[-1].e, yypvt[-0].l); } break; case 28: # line 175 "asm65.y" { page0decl( yypvt[-0].c); } break; case 30: # line 177 "asm65.y" { call_macro( yypvt[-0].c); } break; case 31: # line 178 "asm65.y" { lastident = NIL; _call_macro = 1; } break; case 32: # line 180 "asm65.y" { _call_macro = 0; do_macro( yypvt[-2].c, yypvt[-0].l); } break; case 33: # line 182 "asm65.y" { lastident = NIL; _call_macro = 1; } break; case 34: # line 184 "asm65.y" { _call_macro = 0; rept_macro( yypvt[-3].e, yypvt[-2].c, yypvt[-0].l);} break; case 35: # line 186 "asm65.y" { dbprintf("T_TAB"); } break; case 36: # line 187 "asm65.y" { dbprintf("T_OPT"); } break; case 37: # line 188 "asm65.y" { dbprintf("T_SET"); } break; case 38: # line 189 "asm65.y" { undefine( yypvt[-0].c); } break; case 39: # line 190 "asm65.y" { load_macro( yypvt[-0].c); dbprintf("*** DONE WITH .MACRO ***"); } break; case 40: # line 194 "asm65.y" { footok = yylex(); fooval = yylval.u; include( yypvt[-0].c, ".h65"); fix_include( footok, fooval); } break; case 41: # line 200 "asm65.y" { return( 0); } break; case 42: # line 201 "asm65.y" { do_local(); } break; case 43: # line 202 "asm65.y" { dbprintf("TITLE\n"); } break; case 44: # line 203 "asm65.y" { dbprintf("PAGE\n"); } break; case 45: # line 204 "asm65.y" { nerror( yypvt[-0].c + 2); } break; case 46: # line 205 "asm65.y" { nwarning( yypvt[-0].c + 2); } break; case 47: # line 209 "asm65.y" { adrmod = C_RELX; } break; case 48: # line 210 "asm65.y" { adrmod = C_RELY; } break; case 49: # line 211 "asm65.y" { adrmod = C_INDX; yyval.e = yypvt[-3].e; } break; case 50: # line 212 "asm65.y" { adrmod = C_INDY; yyval.e = yypvt[-3].e; } break; case 51: # line 213 "asm65.y" { adrmod = C_IMM; yyval.e = yypvt[-0].e; } break; case 52: # line 214 "asm65.y" { adrmod = C_IND; yyval.e = yypvt[-1].e; } break; case 53: # line 215 "asm65.y" { adrmod = C_ABS; } break; case 54: # line 216 "asm65.y" { adrmod = C_ACCU; yyval.e = ENIL; } break; case 55: # line 217 "asm65.y" { adrmod = C_IMPL; yyval.e = ENIL; } break; case 56: # line 220 "asm65.y" { yyval.e = ival_pl( (word) yypvt[-0].u); } break; case 57: # line 221 "asm65.y" { yyval.e = lval_pl( lastident = yypvt[-0].c); } break; case 59: # line 223 "asm65.y" {(yyval.e = ival_pl( __pc))->op = O_PCREL;} break; case 60: # line 224 "asm65.y" { yyval.e = ival_pl( (word) yypvt[-0].u); } break; case 61: # line 225 "asm65.y" { yyval.e = ival_pl( is_def( yypvt[-0].c)); } break; case 62: # line 226 "asm65.y" { yyval.e = ival_pl( is_ref( yypvt[-0].c)); } break; case 63: # line 227 "asm65.y" { expr *he; lastident = yypvt[-0].l->string + 2; he = copyexpr( yypvt[-0].l->expr); he->fix = 0; yyval.e = he; } break; case 64: # line 237 "asm65.y" { yypvt[-0].e->fix = FIX_NOTHING; } break; case 65: # line 239 "asm65.y" { yyval.e = yypvt[-1].e; } break; case 66: # line 240 "asm65.y" { yyval.e = op_pl( O_BAND, yypvt[-2].e, yypvt[-0].e); } break; case 67: # line 241 "asm65.y" { yyval.e = op_pl( O_BOR, yypvt[-2].e, yypvt[-0].e); } break; case 68: # line 242 "asm65.y" { yyval.e = op_pl( O_NEQ, yypvt[-2].e, yypvt[-0].e); } break; case 69: # line 243 "asm65.y" { yyval.e = op_pl( O_GEQ, yypvt[-2].e, yypvt[-0].e); } break; case 70: # line 244 "asm65.y" { yyval.e = op_pl( O_LEQ, yypvt[-2].e, yypvt[-0].e); } break; case 71: # line 245 "asm65.y" { yyval.e = op_pl( O_LT, yypvt[-2].e, yypvt[-0].e); } break; case 72: # line 246 "asm65.y" { yyval.e = op_pl( O_GT, yypvt[-2].e, yypvt[-0].e); } break; case 73: # line 247 "asm65.y" { yyval.e = op_pl( O_ADD, yypvt[-2].e, yypvt[-0].e); } break; case 74: # line 248 "asm65.y" { yyval.e = op_pl( O_SUB, yypvt[-2].e, yypvt[-0].e); } break; case 75: # line 249 "asm65.y" { yyval.e = op_pl( O_DIV, yypvt[-2].e, yypvt[-0].e); } break; case 76: # line 250 "asm65.y" { yyval.e = op_pl( O_MUL, yypvt[-2].e, yypvt[-0].e); } break; case 77: # line 251 "asm65.y" { yyval.e = op_pl( O_MOD, yypvt[-2].e, yypvt[-0].e); } break; case 78: # line 252 "asm65.y" { yyval.e = op_pl( O_AND, yypvt[-2].e, yypvt[-0].e); } break; case 79: # line 253 "asm65.y" { yyval.e = op_pl( O_OR, yypvt[-2].e, yypvt[-0].e); } break; case 80: # line 254 "asm65.y" { yyval.e = op_pl( O_EOR, yypvt[-2].e, yypvt[-0].e); } break; case 81: # line 255 "asm65.y" { yyval.e = op_pl( O_EQ, yypvt[-2].e, yypvt[-0].e); } break; case 82: # line 256 "asm65.y" { yyval.e = op_pl( O_BNOT,yypvt[-0].e, ENIL); } break; case 83: # line 257 "asm65.y" { yyval.e = op_pl( O_MIN, yypvt[-0].e, ENIL); } break; case 84: # line 258 "asm65.y" { yyval.e = op_pl( O_MSB, yypvt[-0].e, ENIL); } break; case 85: # line 259 "asm65.y" { yyval.e = op_pl( O_LSB, yypvt[-0].e, ENIL); } break; case 87: # line 263 "asm65.y" { yyval.l = lex_pl( NIL, yypvt[-0].e); } break; case 89: # line 267 "asm65.y" { yyval.l = lex_ch( yypvt[-2].l, yypvt[-0].l); } break; case 90: # line 271 "asm65.y" { yyval.e = yypvt[-1].e; } break; case 91: # line 272 "asm65.y" { yyval.e = ENIL; } break; case 92: # line 275 "asm65.y" { yyval.l = lex_pl( yypvt[-0].c, ENIL); } break; case 93: # line 276 "asm65.y" { yyval.l = lex_pl( NIL, yypvt[-0].e); } break; case 95: # line 281 "asm65.y" { yyval.l = lex_ch( yypvt[-2].l, yypvt[-0].l); } break; case 96: # line 284 "asm65.y" { yyval.l = lex_pl( yypvt[-0].c, ival_pl( wasstrlen)); } break; case 97: # line 285 "asm65.y" { yyval.l = lex_pl( lastident ? make_string( lastident) : undefined, yypvt[-0].e); } break; case 99: # line 291 "asm65.y" { lastident = NIL; } break; case 100: # line 292 "asm65.y" { yyval.l = lex_ch( yypvt[-3].l, yypvt[-0].l); } break; case 101: # line 295 "asm65.y" { yyval.l = lex_pl( NIL, ival_pl( 0)); } break; case 102: # line 297 "asm65.y" { yyval.l = slex_ch( lex_pl( NIL, ival_pl( lex_cnt( yypvt[-0].l))), yypvt[-0].l); } break; } goto yystack; /* reset registers in driver code */ } # ifdef __RUNTIME_YYMAXDEPTH static int allocate_stacks() { /* allocate the yys and yyv stacks */ yys = (int *) malloc(yymaxdepth * sizeof(int)); yyv = (YYSTYPE *) malloc(yymaxdepth * sizeof(YYSTYPE)); if (yys==0 || yyv==0) { yyerror( (nl_msg(30004,"unable to allocate space for yacc stacks")) ); return(1); } else return(0); } static void free_stacks() { if (yys!=0) free((char *) yys); if (yyv!=0) free((char *) yyv); } # endif /* defined(__RUNTIME_YYMAXDEPTH) */