📄 m2-exp.tab.c
字号:
/* The token "if" terminates the expression and is NOT removed from the input stream. */ if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') { return 0; } lexptr += namelen; /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) and $$digits (equivalent to $<-digits> if you could type that). Make token type LAST, and put the number (the digits) in yylval. */ if (*tokstart == '$') { register int negate = 0; c = 1; /* Double dollar means negate the number and add -1 as well. Thus $$ alone means -1. */ if (namelen >= 2 && tokstart[1] == '$') { negate = 1; c = 2; } if (c == namelen) { /* Just dollars (one or two) */ yylval.lval = - negate; return LAST; } /* Is the rest of the token digits? */ for (; c < namelen; c++) if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) break; if (c == namelen) { yylval.lval = atoi (tokstart + 1 + negate); if (negate) yylval.lval = - yylval.lval; return LAST; } } /* Handle tokens that refer to machine registers: $ followed by a register name. */ if (*tokstart == '$') { for (c = 0; c < NUM_REGS; c++) if (namelen - 1 == strlen (reg_names[c]) && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) { yylval.lval = c; return REGNAME; } for (c = 0; c < num_std_regs; c++) if (namelen - 1 == strlen (std_regs[c].name) && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) { yylval.lval = std_regs[c].regnum; return REGNAME; } } /* Lookup special keywords */ for(i = 0 ; i < sizeof(keytab) / sizeof(keytab[0]) ; i++) if(namelen == strlen(keytab[i].keyw) && !strncmp(tokstart,keytab[i].keyw,namelen)) return keytab[i].token; yylval.sval.ptr = tokstart; yylval.sval.length = namelen; /* Any other names starting in $ are debugger internal variables. */ if (*tokstart == '$') { yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1); return INTERNAL_VAR; } /* Use token-type BLOCKNAME for symbols that happen to be defined as functions. If this is not so, then ... Use token-type TYPENAME for symbols that happen to be defined currently as names of types; NAME for other symbols. The caller is not constrained to care about the distinction. */ { char *tmp = copy_name (yylval.sval); struct symbol *sym; if (lookup_partial_symtab (tmp)) return BLOCKNAME; sym = lookup_symbol (tmp, expression_context_block, VAR_NAMESPACE, 0, NULL); if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) return BLOCKNAME; if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1)) return TYPENAME; if(sym) { switch(sym->class) { case LOC_STATIC: case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: case LOC_REGPARM: case LOC_LOCAL: case LOC_LOCAL_ARG: case LOC_CONST: case LOC_CONST_BYTES: return NAME; case LOC_TYPEDEF: return TYPENAME; case LOC_BLOCK: return BLOCKNAME; case LOC_UNDEF: error("internal: Undefined class in m2lex()"); case LOC_LABEL: error("internal: Unforseen case in m2lex()"); } } else { /* Built-in BOOLEAN type. This is sort of a hack. */ if(!strncmp(tokstart,"TRUE",4)) { yylval.ulval = 1; return M2_TRUE; } else if(!strncmp(tokstart,"FALSE",5)) { yylval.ulval = 0; return M2_FALSE; } } /* Must be another type of name... */ return NAME; }}#if 0 /* Unused */static char *make_qualname(mod,ident) char *mod, *ident;{ char *new = xmalloc(strlen(mod)+strlen(ident)+2); strcpy(new,mod); strcat(new,"."); strcat(new,ident); return new;}#endif /* 0 */static voidyyerror(msg) char *msg; /* unused */{ printf("Parsing: %s\n",lexptr); if (yychar < 256) error("Invalid syntax in expression near character '%c'.",yychar); else error("Invalid syntax in expression");}/* Table of operators and their precedences for printing expressions. */const static struct op_print m2_op_print_tab[] = { {"+", BINOP_ADD, PREC_ADD, 0}, {"+", UNOP_PLUS, PREC_PREFIX, 0}, {"-", BINOP_SUB, PREC_ADD, 0}, {"-", UNOP_NEG, PREC_PREFIX, 0}, {"*", BINOP_MUL, PREC_MUL, 0}, {"/", BINOP_DIV, PREC_MUL, 0}, {"DIV", BINOP_INTDIV, PREC_MUL, 0}, {"MOD", BINOP_REM, PREC_MUL, 0}, {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, {"OR", BINOP_OR, PREC_OR, 0}, {"AND", BINOP_AND, PREC_AND, 0}, {"NOT", UNOP_ZEROP, PREC_PREFIX, 0}, {"=", BINOP_EQUAL, PREC_EQUAL, 0}, {"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0}, {"<=", BINOP_LEQ, PREC_ORDER, 0}, {">=", BINOP_GEQ, PREC_ORDER, 0}, {">", BINOP_GTR, PREC_ORDER, 0}, {"<", BINOP_LESS, PREC_ORDER, 0}, {"^", UNOP_IND, PREC_PREFIX, 0}, {"@", BINOP_REPEAT, PREC_REPEAT, 0},};/* The built-in types of Modula-2. */struct type *builtin_type_m2_char;struct type *builtin_type_m2_int;struct type *builtin_type_m2_card;struct type *builtin_type_m2_real;struct type *builtin_type_m2_bool;struct type ** const (m2_builtin_types[]) = { &builtin_type_m2_char, &builtin_type_m2_int, &builtin_type_m2_card, &builtin_type_m2_real, &builtin_type_m2_bool, 0};const struct language_defn m2_language_defn = { "modula-2", language_m2, m2_builtin_types, range_check_on, type_check_on, m2_parse, /* parser */ m2_error, /* parser error function */ &builtin_type_m2_int, /* longest signed integral type */ &builtin_type_m2_card, /* longest unsigned integral type */ &builtin_type_m2_real, /* longest floating point type */ "0%XH", "0%", "XH", /* Hex format string, prefix, suffix */ "%oB", "%", "oB", /* Octal format string, prefix, suffix */ m2_op_print_tab, /* expression operators for printing */ LANG_MAGIC};/* Initialization for Modula-2 */void_initialize_m2_exp (){ /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */ builtin_type_m2_int = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "INTEGER", (struct objfile *) NULL); builtin_type_m2_card = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "CARDINAL", (struct objfile *) NULL); builtin_type_m2_real = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0, "REAL", (struct objfile *) NULL); builtin_type_m2_char = init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "CHAR", (struct objfile *) NULL); builtin_type_m2_bool = init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "BOOLEAN", (struct objfile *) NULL); TYPE_NFIELDS(builtin_type_m2_bool) = 2; TYPE_FIELDS(builtin_type_m2_bool) = (struct field *) malloc (sizeof (struct field) * 2); TYPE_FIELD_BITPOS(builtin_type_m2_bool,0) = 0; TYPE_FIELD_NAME(builtin_type_m2_bool,0) = (char *)malloc(6); strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,0),"FALSE"); TYPE_FIELD_BITPOS(builtin_type_m2_bool,1) = 1; TYPE_FIELD_NAME(builtin_type_m2_bool,1) = (char *)malloc(5); strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,1),"TRUE"); add_language (&m2_language_defn);}int yyexca[] ={-1, 1, 0, -1, -2, 0,-1, 40, 287, 75, -2, 78,-1, 119, 292, 0, -2, 63, };# define YYNPROD 83# define YYLAST 1409int yyact[]={ 26, 95, 98, 5, 39, 4, 144, 143, 96, 93, 138, 92, 138, 89, 171, 155, 93, 159, 93, 101, 172, 21, 153, 138, 152, 88, 87, 86, 85, 82, 81, 80, 79, 49, 84, 51, 55, 5, 56, 4, 52, 59, 78, 77, 65, 76, 49, 162, 51, 55, 163, 56, 59, 52, 75, 65, 49, 49, 160, 51, 55, 161, 56, 170, 52, 74, 62, 57, 63, 97, 50, 73, 72, 145, 100, 6, 68, 62, 57, 63, 40, 50, 42, 24, 48, 33, 38, 45, 1, 3, 0, 168, 92, 137, 139, 0, 49, 48, 51, 92, 45, 92, 0, 52, 0, 0, 140, 48, 48, 0, 45, 45, 0, 0, 0, 147, 59, 24, 0, 65, 38, 49, 183, 51, 55, 0, 56, 59, 52, 0, 65, 0, 49, 182, 51, 55, 0, 56, 0, 52, 0, 62, 57, 63, 0, 50, 0, 48, 0, 39, 45, 0, 62, 57, 63, 59, 50, 0, 65, 0, 49, 181, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 48, 0, 0, 45, 0, 0, 0, 0, 62, 57, 63, 48, 50, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 45, 0, 0, 29, 0, 0, 30, 27, 28, 31, 32, 36, 43, 44, 0, 0, 39, 18, 7, 8, 10, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 0, 34, 35, 41, 29, 0, 0, 30, 27, 28, 31, 32, 36, 43, 44, 0, 37, 39, 18, 7, 8, 10, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 0, 34, 35, 41, 0, 0, 0, 0, 0, 0, 0, 53, 54, 0, 46, 0, 37, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 67, 60, 61, 58, 47, 66, 64, 53, 54, 46, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0, 0, 65, 0, 49, 180, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 53, 54, 0, 46, 0, 0, 0, 62, 57, 63, 0, 50, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 67, 60, 61, 58, 47, 66, 64, 53, 54, 48, 46, 0, 45, 0, 59, 0, 0, 65, 0, 49, 179, 51, 55, 0, 56, 0, 52, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 62, 57, 63, 59, 50, 0, 65, 0, 49, 169, 51, 55, 0, 56, 59, 52, 0, 65, 0, 49, 0, 51, 55, 165, 56, 0, 52, 0, 62, 57, 63, 48, 50, 0, 45, 0, 0, 0, 0, 62, 57, 63, 59, 50, 0, 65, 0, 49, 0, 51, 55, 164, 56, 0, 52, 0, 0, 0, 0, 48, 0, 0, 45, 0, 0, 0, 0, 62, 57, 63, 48, 50, 0, 45, 0, 0, 0, 59, 0, 0, 65, 0, 49, 158, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 45, 62, 57, 63, 59, 50, 0, 65, 0, 49, 157, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 57, 63, 48, 50, 0, 45, 0, 70, 25, 59, 0, 0, 65, 0, 49, 156, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 90, 45, 62, 57, 63, 0, 50, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 59, 99, 0, 65, 0, 49, 154, 51, 55, 0, 56, 48, 52, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 57, 63, 0, 50, 125, 126, 0, 128, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 48, 46, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0, 0, 65, 0, 49, 151, 51, 55, 0, 56, 0, 52, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 62, 57, 63, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 48, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 59, 46, 0, 65, 0, 49, 150, 51, 55, 65, 56, 49, 52, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 62, 57, 63, 0, 50, 0, 0, 0, 0, 0, 50, 67, 60, 61, 58, 47, 66, 64, 53, 54, 59, 46, 0, 65, 0, 49, 149, 51, 55, 0, 56, 48, 52, 0, 45, 0, 0, 48, 0, 0, 45, 0, 0, 0, 0, 62, 57, 63, 59, 50, 0, 65, 0, 49, 148, 51, 55, 0, 56, 59, 52, 0, 65, 0, 49, 142, 51, 55, 0, 56, 0, 52, 0, 62, 57, 63, 48, 50, 0, 45, 0, 0, 0, 0, 62, 57, 63, 65, 50, 49, 0, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 45, 0, 59, 0, 0, 65, 50, 49, 48, 51, 55, 45, 56, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 57, 63, 0, 50, 0, 48, 0, 0, 45, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 59, 0, 0, 65, 0, 49, 48, 51, 55, 45, 56, 49, 52, 51, 55, 0, 56, 0, 52, 0, 0, 0, 0, 0, 0, 62, 57, 63, 0, 50, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 45, 0, 0, 48, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 0, 0, 0, 91, 2, 0, 0, 0, 0, 69, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, 0, 0, 0, 0, 0, 60, 61, 58, 47, 66, 64, 53, 54, 0, 46, 0, 0, 53, 54, 0, 46, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 0, 0, 0, 121, 122, 123, 124, 0, 0, 127, 0, 129, 130, 131, 0, 94, 133, 134, 135, 136, 0, 0, 0, 0, 141, 0, 0, 0, 0, 0, 0, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, 0, 174, 0, 175, 176, 177, 0, 0, 0, 0, 0, 178 };int yypact[]={ -40, -1000, 928, -1000, -1000, -40, -40, 32, 31, 25, 14, 5, 3, 2, -8, -9, -10, -11, -6, -12, -13, -1000, -14, -15, -40, -22, -40, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -286, -1000, -1000, -1000, -258, -121, -1000, -1000, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, 16, -22, 16, -40, -40, -40, -40, -266, -266, -40, -266, -40, -40, -40, 16, -40, -40, -40, -40, -40, -32, -31, 928, -40, -40, 878, -260, -1000, -1000, -40, -112, -40, -40, -7, 16, 16, 16, 16, 56, 56, 800, 800, 800, 800, 800, 800, 800, 984, 984, 903, 978, 16, 867, 839, 794, 708, -17, -19, 573, -29, 528, 493, 465, -24, 17, 6, 430, 402, -1000, -40, -40, -34, 391, -1000, -1000, -1000, -30, 928, -21, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -40, -1000, -1000, -1000, -1000, -1000, -40, -1000, -40, -40, -40, 928, 16, -1000, -1000, -1000, -40, -1000, 363, 302, 120, 92, 81, 928, -1000, -1000, -1000, -1000, -1000 };int yypgo[]={ 0, 1236, 89, 88, 21, 85, 561, 82, 80, 76, 75, 13, 74, 73, 19 };int yyr1[]={ 0, 3, 3, 2, 1, 9, 1, 1, 1, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 12, 1, 14, 1, 11, 11, 11, 13, 13, 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, 7, 8, 8, 5, 5, 5, 5, 6 };int yyr2[]={ 0, 2, 2, 3, 5, 1, 7, 5, 5, 2, 2, 9, 9, 9, 9, 9, 9, 9, 13, 9, 9, 9, 5, 9, 13, 9, 13, 7, 2, 7, 13, 13, 7, 9, 1, 11, 1, 11, 0, 3, 7, 3, 7, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 3, 2, 3, 3, 9, 3, 3, 3, 7, 3, 3, 7, 3, 3 };int yychk[]={ -1000, -3, -1, -2, 45, 43, -10, 272, 273, 275, 274, 276, 277, 278, 279, 280, 281, 282, 271, 283, 284, -4, 285, 286, 123, -6, 40, 261, 262, 257, 260, 263, 264, -5, 288, 289, 265, 303, 126, 270, -8, 290, -7, 266, 267, 94, 302, 296, 91, 40, 64, 42, 47, 299, 300, 43, 45, 61, 295, 35, 293, 294, 60, 62, 298, 38, 297, 292, -9, -1, -6, -1, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, -1, 40, 40, 40, 40, 40, -11, -6, -1, 123, 40, -1, 287, 266, -4, 123, -6, -12, -14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -6, -1, -6, -1, -1, -1, -6, -1, -1, -1, -1, 125, 44, 125, -11, -1, 41, 267, 266, -13, -1, -11, 41, 41, 41, 41, 41, 41, 41, 44, 41, 41, 41, 41, 41, 44, 41, 44, 44, 44, -1, -1, 125, 41, 93, 44, 41, -1, -1, -1, -1, -1, -1, 41, 41, 41, 41, 41 };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -