/// <summary>Method with the actual generated action code. /// </summary> public Symbol CUP_parser_do_action(int CUP_parser_act_num, lr_parser CUP_parser_parser, CUP.runtime.SymbolStack CUP_parser_stack, int CUP_parser_top) { /* Symbol object for return from actions */ Symbol CUP_parser_result; /* select the action based on the action number */ switch (CUP_parser_act_num) { case 106: // empty ::= { System.Object RESULT = null; CUP_parser_result = new Symbol(29, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 105: // opt_semi ::= SEMI { System.Object RESULT = null; CUP_parser_result = new Symbol(7, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 104: // opt_semi ::= { System.Object RESULT = null; CUP_parser_result = new Symbol(7, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 103: // non_terminal ::= NONTERMINAL { System.Object RESULT = null; CUP_parser_result = new Symbol(8, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 102: // non_terminal ::= NON TERMINAL { System.Object RESULT = null; CUP_parser_result = new Symbol(8, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 101: // robust_id ::= error { System.String RESULT = null; lexer.emit_error("Illegal use of reserved word"); RESULT = "ILLEGAL"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 100: // robust_id ::= NONASSOC { System.String RESULT = null; RESULT = "nonassoc"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 99: // robust_id ::= RIGHT { System.String RESULT = null; RESULT = "right"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 98: // robust_id ::= LEFT { System.String RESULT = null; RESULT = "left"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 97: // robust_id ::= PRECEDENCE { System.String RESULT = null; RESULT = "precedence"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 96: // robust_id ::= START { System.String RESULT = null; RESULT = "start"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 95: // robust_id ::= WITH { System.String RESULT = null; RESULT = "with"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 94: // robust_id ::= SCAN { System.String RESULT = null; RESULT = "scan"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 93: // robust_id ::= INIT { System.String RESULT = null; RESULT = "init"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 92: // robust_id ::= NONTERMINAL { System.String RESULT = null; RESULT = "nonterminal"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 91: // robust_id ::= NON { System.String RESULT = null; RESULT = "non"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 90: // robust_id ::= TERMINAL { System.String RESULT = null; RESULT = "terminal"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 89: // robust_id ::= PARSER { System.String RESULT = null; RESULT = "parser"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 88: // robust_id ::= ACTION { System.String RESULT = null; RESULT = "action"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 87: // robust_id ::= CODE { System.String RESULT = null; RESULT = "code"; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 86: // robust_id ::= ID { System.String RESULT = null; int the_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int the_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String the_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; RESULT = the_id; CUP_parser_result = new Symbol(42, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 85: // label_id ::= robust_id { System.String RESULT = null; int the_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int the_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String the_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; RESULT = the_id; CUP_parser_result = new Symbol(38, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 84: // symbol_id ::= error { System.String RESULT = null; lexer.emit_error("Illegal use of reserved word"); RESULT = "ILLEGAL"; CUP_parser_result = new Symbol(37, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 83: // symbol_id ::= ID { System.String RESULT = null; int the_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int the_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String the_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; RESULT = the_id; CUP_parser_result = new Symbol(37, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 82: // nt_id ::= error { System.String RESULT = null; lexer.emit_error("Illegal use of reserved word"); RESULT = "ILLEGAL"; CUP_parser_result = new Symbol(36, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 81: // nt_id ::= ID { System.String RESULT = null; int the_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int the_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String the_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; RESULT = the_id; CUP_parser_result = new Symbol(36, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 80: // new_non_term_id ::= ID { System.Object RESULT = null; int non_term_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int non_term_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String non_term_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* see if this non terminal has been declared before */ if (symbols[non_term_id] != null) { /* issue a message */ lexer.emit_error("CUP.runtime.Symbol \"" + non_term_id + "\" has already been declared"); } else { if (multipart_name.Equals("")) { append_multipart("Object"); } /* build the non terminal object */ non_terminal this_nt = new non_terminal(non_term_id, multipart_name); /* put it in the non_terms table */ SupportClass.PutElement(non_terms, non_term_id, this_nt); /* build a production_part and put it in the symbols table */ SupportClass.PutElement(symbols, non_term_id, new symbol_part(this_nt)); } CUP_parser_result = new Symbol(26, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 79: // new_term_id ::= ID { System.Object RESULT = null; int term_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int term_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String term_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* see if this terminal has been declared before */ if (symbols[term_id] != null) { /* issue a message */ lexer.emit_error("CUP.runtime.Symbol \"" + term_id + "\" has already been declared"); } else { /* if no type declared, declare one */ if (multipart_name.Equals("")) { append_multipart("Object"); } /* build a production_part and put it in the table */ SupportClass.PutElement(symbols, term_id, new symbol_part(new terminal(term_id, multipart_name))); } CUP_parser_result = new Symbol(25, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 78: // type_id ::= type_id LBRACK RBRACK { System.Object RESULT = null; multipart_name = string.Concat(multipart_name, "[]"); CUP_parser_result = new Symbol(19, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 77: // type_id ::= multipart_id { System.Object RESULT = null; CUP_parser_result = new Symbol(19, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 76: // import_id ::= multipart_id { System.Object RESULT = null; CUP_parser_result = new Symbol(15, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 75: // import_id ::= multipart_id DOT STAR { System.Object RESULT = null; append_multipart("*"); CUP_parser_result = new Symbol(15, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 74: // multipart_id ::= robust_id { System.Object RESULT = null; int an_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int an_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String an_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; append_multipart(an_id); CUP_parser_result = new Symbol(13, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 73: // multipart_id ::= multipart_id DOT robust_id { System.Object RESULT = null; int another_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int another_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String another_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; append_multipart(another_id); CUP_parser_result = new Symbol(13, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 72: // opt_label ::= empty { System.String RESULT = null; RESULT = null; CUP_parser_result = new Symbol(39, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 71: // opt_label ::= COLON label_id { System.String RESULT = null; int labidleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int labidright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String labid = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; RESULT = labid; CUP_parser_result = new Symbol(39, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 70: // prod_part ::= CODE_STRING { System.Object RESULT = null; int code_strleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int code_strright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String code_str = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* add a new production part */ add_rhs_part(new action_part(code_str)); CUP_parser_result = new Symbol(24, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 69: // prod_part ::= symbol_id opt_label { System.Object RESULT = null; int symidleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int symidright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.String symid = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; int labidleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int labidright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String labid = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* try to look up the id */ production_part symb = (production_part) symbols[symid]; /* if that fails, symbol is undeclared */ if (symb == null) { if (lexer.error_count == 0) lexer.emit_error("CUP.runtime.Symbol \"" + symid + "\" has not been declared"); } else { /* add a labeled production part */ add_rhs_part(add_lab(symb, labid)); } CUP_parser_result = new Symbol(24, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 68: // prod_part_list ::= empty { System.Object RESULT = null; CUP_parser_result = new Symbol(23, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 67: // prod_part_list ::= prod_part_list prod_part { System.Object RESULT = null; CUP_parser_result = new Symbol(23, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 66: // rhs ::= prod_part_list { System.Object RESULT = null; if (lhs_nt != null) { /* build the production */ production p = new production(lhs_nt, rhs_parts, rhs_pos); /* if we have no start non-terminal declared and this is the first production, make its lhs nt the start_nt and build a special start production for it. */ if (start_nt == null) { start_nt = lhs_nt; /* build a special start production */ new_rhs(); add_rhs_part(add_lab(new symbol_part(start_nt), "start_val")); add_rhs_part(new symbol_part(terminal.EOF)); add_rhs_part(new action_part("RESULT = start_val;")); emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos); new_rhs(); } } /* reset the rhs accumulation in any case */ new_rhs(); CUP_parser_result = new Symbol(28, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 65: // rhs ::= prod_part_list PERCENT_PREC term_id { System.Object RESULT = null; int term_nameleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int term_nameright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String term_name = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; CUP.symbol sym = null; if (lhs_nt != null) { /* Find the precedence symbol */ if (term_name == null) { System.Console.Error.WriteLine("No terminal for contextual precedence"); sym = null; } else { sym = ((symbol_part) symbols[term_name]).the_symbol(); } /* build the production */ production p; if ((sym != null) && (sym is terminal)) { p = new production(lhs_nt, rhs_parts, rhs_pos, ((terminal) sym).precedence_num(), ((terminal) sym).precedence_side()); ((symbol_part) symbols[term_name]).the_symbol().note_use(); } else { System.Console.Error.WriteLine("Invalid terminal " + term_name + " for contextual precedence assignment"); p = new production(lhs_nt, rhs_parts, rhs_pos); } /* if we have no start non-terminal declared and this is the first production, make its lhs nt the start_nt and build a special start production for it. */ if (start_nt == null) { start_nt = lhs_nt; /* build a special start production */ new_rhs(); add_rhs_part(add_lab(new symbol_part(start_nt), "start_val")); add_rhs_part(new symbol_part(terminal.EOF)); add_rhs_part(new action_part("RESULT = start_val;")); if ((sym != null) && (sym is terminal)) { emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos, ((terminal) sym).precedence_num(), ((terminal) sym).precedence_side()); } else { emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos); } new_rhs(); } } /* reset the rhs accumulation in any case */ new_rhs(); CUP_parser_result = new Symbol(28, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 64: // rhs_list ::= rhs { System.Object RESULT = null; CUP_parser_result = new Symbol(27, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 63: // rhs_list ::= rhs_list BAR rhs { System.Object RESULT = null; CUP_parser_result = new Symbol(27, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 62: // production ::= error NT_13 SEMI { System.Object RESULT = null; // propagate RESULT from NT_13 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(22, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 61: // NT_13 ::= { System.Object RESULT = null; lexer.emit_error("Syntax Error"); CUP_parser_result = new Symbol(56, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 60: // production ::= nt_id NT_11 COLON_COLON_EQUALS NT_12 rhs_list SEMI { System.Object RESULT = null; // propagate RESULT from NT_11 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).value_Renamed; // propagate RESULT from NT_12 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; int lhs_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 5)).left; int lhs_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 5)).right; System.String lhs_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 5)).value_Renamed; CUP_parser_result = new Symbol(22, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 5)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 59: // NT_12 ::= { System.Object RESULT = null; int lhs_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int lhs_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).right; System.String lhs_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; CUP_parser_result = new Symbol(55, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 58: // NT_11 ::= { System.Object RESULT = null; int lhs_idleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int lhs_idright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String lhs_id = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* lookup the lhs nt */ lhs_nt = (non_terminal) non_terms[lhs_id]; /* if it wasn't declared, emit a message */ if (lhs_nt == null) { if (lexer.error_count == 0) lexer.emit_error("LHS non terminal \"" + lhs_id + "\" has not been declared"); } /* reset the rhs accumulation */ new_rhs(); CUP_parser_result = new Symbol(54, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 57: // production_list ::= production { System.Object RESULT = null; CUP_parser_result = new Symbol(12, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 56: // production_list ::= production_list production { System.Object RESULT = null; CUP_parser_result = new Symbol(12, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 55: // start_spec ::= empty { System.Object RESULT = null; CUP_parser_result = new Symbol(11, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 54: // start_spec ::= START WITH nt_id NT_10 SEMI { System.Object RESULT = null; // propagate RESULT from NT_10 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; int start_nameleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int start_nameright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).right; System.String start_name = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; CUP_parser_result = new Symbol(11, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 53: // NT_10 ::= { System.Object RESULT = null; int start_nameleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int start_nameright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String start_name = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* verify that the name has been declared as a non terminal */ non_terminal nt = (non_terminal) non_terms[start_name]; if (nt == null) { lexer.emit_error("Start non terminal \"" + start_name + "\" has not been declared"); } else { /* remember the non-terminal for later */ start_nt = nt; /* build a special start production */ new_rhs(); add_rhs_part(add_lab(new symbol_part(start_nt), "start_val")); add_rhs_part(new symbol_part(terminal.EOF)); add_rhs_part(new action_part("RESULT = start_val;")); emit.start_production = new production(non_terminal.START_nt, rhs_parts, rhs_pos); new_rhs(); } CUP_parser_result = new Symbol(53, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 52: // term_id ::= symbol_id { System.String RESULT = null; int symleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int symright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String sym = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; /* check that the symbol_id is a terminal */ if (symbols[sym] == null) { /* issue a message */ lexer.emit_error("Terminal \"" + sym + "\" has not been declared"); } RESULT = sym; CUP_parser_result = new Symbol(41, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 51: // terminal_id ::= term_id { System.String RESULT = null; int symleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int symright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right; System.String sym = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).value_Renamed; add_precedence(sym); RESULT = sym; CUP_parser_result = new Symbol(40, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 50: // terminal_list ::= terminal_id { System.Object RESULT = null; CUP_parser_result = new Symbol(32, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 49: // terminal_list ::= terminal_list COMMA terminal_id { System.Object RESULT = null; CUP_parser_result = new Symbol(32, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 48: // preced ::= PRECEDENCE NONASSOC NT_9 terminal_list SEMI { System.Object RESULT = null; // propagate RESULT from NT_9 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; CUP_parser_result = new Symbol(31, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 47: // NT_9 ::= { System.Object RESULT = null; update_precedence(assoc.nonassoc); CUP_parser_result = new Symbol(52, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 46: // preced ::= PRECEDENCE RIGHT NT_8 terminal_list SEMI { System.Object RESULT = null; // propagate RESULT from NT_8 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; CUP_parser_result = new Symbol(31, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 45: // NT_8 ::= { System.Object RESULT = null; update_precedence(assoc.right); CUP_parser_result = new Symbol(51, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 44: // preced ::= PRECEDENCE LEFT NT_7 terminal_list SEMI { System.Object RESULT = null; // propagate RESULT from NT_7 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).value_Renamed; CUP_parser_result = new Symbol(31, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 43: // NT_7 ::= { System.Object RESULT = null; update_precedence(assoc.left); CUP_parser_result = new Symbol(50, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 42: // precedence_l ::= preced { System.Object RESULT = null; CUP_parser_result = new Symbol(33, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 41: // precedence_l ::= precedence_l preced { System.Object RESULT = null; CUP_parser_result = new Symbol(33, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 40: // precedence_list ::= empty { System.Object RESULT = null; CUP_parser_result = new Symbol(30, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 39: // precedence_list ::= precedence_l { System.Object RESULT = null; CUP_parser_result = new Symbol(30, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 38: // non_term_name_list ::= new_non_term_id { System.Object RESULT = null; CUP_parser_result = new Symbol(21, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 37: // non_term_name_list ::= non_term_name_list COMMA new_non_term_id { System.Object RESULT = null; CUP_parser_result = new Symbol(21, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 36: // term_name_list ::= new_term_id { System.Object RESULT = null; CUP_parser_result = new Symbol(20, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 35: // term_name_list ::= term_name_list COMMA new_term_id { System.Object RESULT = null; CUP_parser_result = new Symbol(20, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 34: // declares_non_term ::= non_term_name_list NT_6 SEMI { System.Object RESULT = null; // propagate RESULT from NT_6 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(35, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 33: // NT_6 ::= { System.Object RESULT = null; /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(49, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 32: // declares_term ::= term_name_list NT_5 SEMI { System.Object RESULT = null; // propagate RESULT from NT_5 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(34, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 31: // NT_5 ::= { System.Object RESULT = null; /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(48, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 30: // symbol ::= non_terminal error NT_4 SEMI { System.Object RESULT = null; // propagate RESULT from NT_4 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 29: // NT_4 ::= { System.Object RESULT = null; /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(47, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 28: // symbol ::= TERMINAL error NT_3 SEMI { System.Object RESULT = null; // propagate RESULT from NT_3 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 27: // NT_3 ::= { System.Object RESULT = null; /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(46, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 26: // symbol ::= non_terminal declares_non_term { System.Object RESULT = null; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 25: // symbol ::= non_terminal type_id declares_non_term { System.Object RESULT = null; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 24: // symbol ::= TERMINAL declares_term { System.Object RESULT = null; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 23: // symbol ::= TERMINAL type_id declares_term { System.Object RESULT = null; CUP_parser_result = new Symbol(18, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 22: // symbol_list ::= symbol { System.Object RESULT = null; CUP_parser_result = new Symbol(10, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 21: // symbol_list ::= symbol_list symbol { System.Object RESULT = null; CUP_parser_result = new Symbol(10, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 20: // scan_code ::= SCAN WITH CODE_STRING opt_semi { System.Object RESULT = null; int user_codeleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int user_coderight = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.String user_code = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; if (emit.scan_code != null) lexer.emit_error("Redundant scan code (skipping)"); else emit.scan_code = user_code; CUP_parser_result = new Symbol(17, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 19: // init_code ::= INIT WITH CODE_STRING opt_semi { System.Object RESULT = null; int user_codeleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int user_coderight = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.String user_code = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; if (emit.init_code != null) lexer.emit_error("Redundant init code (skipping)"); else emit.init_code = user_code; CUP_parser_result = new Symbol(16, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 18: // parser_code_part ::= PARSER CODE CODE_STRING opt_semi { System.Object RESULT = null; int user_codeleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int user_coderight = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.String user_code = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; if (emit.parser_code != null) lexer.emit_error("Redundant parser code (skipping)"); else emit.parser_code = user_code; CUP_parser_result = new Symbol(9, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 17: // action_code_part ::= ACTION CODE CODE_STRING opt_semi { System.Object RESULT = null; int user_codeleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int user_coderight = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.String user_code = (string) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; if (emit.action_code != null) lexer.emit_error("Redundant action code (skipping)"); else emit.action_code = user_code; CUP_parser_result = new Symbol(4, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 16: // code_parts ::= code_parts code_part { System.Object RESULT = null; CUP_parser_result = new Symbol(5, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 15: // code_parts ::= { System.Object RESULT = null; CUP_parser_result = new Symbol(5, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 14: // code_part ::= scan_code { System.Object RESULT = null; CUP_parser_result = new Symbol(6, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 13: // code_part ::= init_code { System.Object RESULT = null; CUP_parser_result = new Symbol(6, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 12: // code_part ::= parser_code_part { System.Object RESULT = null; CUP_parser_result = new Symbol(6, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 11: // code_part ::= action_code_part { System.Object RESULT = null; CUP_parser_result = new Symbol(6, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 10: // import_spec ::= IMPORT import_id NT_2 SEMI { System.Object RESULT = null; // propagate RESULT from NT_2 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(14, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 9: // NT_2 ::= { System.Object RESULT = null; /* save this import on the imports list */ emit.import_list.Push(multipart_name); /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(45, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 8: // import_list ::= empty { System.Object RESULT = null; CUP_parser_result = new Symbol(3, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 7: // import_list ::= import_list import_spec { System.Object RESULT = null; CUP_parser_result = new Symbol(3, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 6: // package_spec ::= empty { System.Object RESULT = null; CUP_parser_result = new Symbol(2, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 5: // package_spec ::= PACKAGE multipart_id NT_1 SEMI { System.Object RESULT = null; // propagate RESULT from NT_1 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; CUP_parser_result = new Symbol(2, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 3)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 4: // NT_1 ::= { System.Object RESULT = null; /* save the package name */ emit.namespace_name = multipart_name; /* reset the accumulated multipart name */ multipart_name = new string("".ToCharArray()); CUP_parser_result = new Symbol(44, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 3: // spec ::= error symbol_list precedence_list start_spec production_list { System.Object RESULT = null; CUP_parser_result = new Symbol(1, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 4)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 2: // spec ::= NT_0 package_spec import_list code_parts symbol_list precedence_list start_spec production_list { System.Object RESULT = null; // propagate RESULT from NT_0 if (((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 7)).value_Renamed != null) RESULT = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 7)).value_Renamed; CUP_parser_result = new Symbol(1, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 7)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 1: // NT_0 ::= { System.Object RESULT = null; /* declare "error" as a terminal */ SupportClass.PutElement(symbols, "error", new symbol_part(terminal.error)); /* declare start non terminal */ SupportClass.PutElement(non_terms, "_START", non_terminal.START_nt); CUP_parser_result = new Symbol(43, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 0: // _START ::= spec EOF { System.Object RESULT = null; int start_valleft = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int start_valright = ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).right; System.Object start_val = (object) ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).value_Renamed; RESULT = start_val; CUP_parser_result = new Symbol(0, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((Symbol) CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } /* ACCEPT */ CUP_parser_parser.done_parsing(); return CUP_parser_result; /* . . . . . .*/ default: throw new System.Exception("Invalid action number found in internal parse table"); } }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Put the (real) parse stack into error recovery configuration by /// popping the stack down to a state that can shift on the special /// error Symbol, then doing the shift. If no suitable state exists on /// the stack we return false /// * /// </summary> /// <param name="debug">should we produce debugging messages as we parse. /// /// </param> protected virtual bool find_recovery_config(bool debug) { Symbol error_token; int act; if (debug) debug_message("# Finding recovery state on stack"); /* Remember the right-position of the top symbol on the stack */ int right_pos = ((Symbol) stack.Peek()).right; int left_pos = ((Symbol) stack.Peek()).left; /* pop down until we can shift under error Symbol */ while (!shift_under_error()) { /* pop the stack */ if (debug) debug_message("# Pop stack by one, state was # " + ((Symbol) stack.Peek()).parse_state); left_pos = ((Symbol) stack.Pop()).left; tos--; /* if we have hit bottom, we fail */ if ((stack.Count == 0)) { if (debug) debug_message("# No recovery state found on stack"); return false; } } /* state on top of the stack can shift under error, find the shift */ act = get_action(((Symbol) stack.Peek()).parse_state, error_sym()); if (debug) { debug_message("# Recover state found (#" + ((Symbol) stack.Peek()).parse_state + ")"); debug_message("# Shifting on error to state #" + (act - 1)); } /* build and shift a special error Symbol */ error_token = new Symbol(error_sym(), left_pos, right_pos); error_token.parse_state = act - 1; error_token.used_by_parser = true; System.Object temp_object; temp_object = error_token; System.Object generatedAux = temp_object; stack.Push(temp_object); tos++; return true; }
/** Method with the actual generated action code. */ public CUP.runtime.Symbol CUP_parser_do_action( int CUP_parser_act_num, CUP.runtime.lr_parser CUP_parser_parser, CUP.runtime.SymbolStack CUP_parser_stack, int CUP_parser_top) { /* Symbol object for return from actions */ CUP.runtime.Symbol CUP_parser_result; /* select the action based on the action number */ switch (CUP_parser_act_num) { /*. . . . . . . . . . . . . . . . . . . .*/ case 13: // expr ::= LPAREN expr RPAREN { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).right; decimal e = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-1)).Value; RESULT = e; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 12: // expr ::= MINUS expr { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = -e; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 11: // expr ::= REAL { decimal RESULT = decimal.Zero; int nleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int nright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal n = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = n; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 10: // expr ::= INTEGER { decimal RESULT = decimal.Zero; int nleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int nright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; int n = (int)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = n; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 9: // expr ::= expr MOD expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = (decimal)((int)e1 % (int)e2); CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 8: // expr ::= expr DIVIDE expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e1 / e2; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 7: // expr ::= expr TIMES expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e1 * e2; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 6: // expr ::= expr MINUS expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e1 - e2; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 5: // expr ::= expr PLUS expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e1 + e2; CUP_parser_result = new CUP.runtime.Symbol(3/*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 4: // expr_part ::= expr NT$0 SEMI { decimal RESULT = decimal.Zero; // propagate RESULT from NT$0 if ( ((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-1)).Value != null ) RESULT = (decimal) ((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-1)).Value; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).right; decimal e = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-2)).Value; CUP_parser_result = new CUP.runtime.Symbol(2/*expr_part*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 3: // NT$0 ::= { Object RESULT = null; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e; Console.WriteLine("= " + e); CUP_parser_result = new CUP.runtime.Symbol(4/*NT$0*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 2: // expr_list ::= expr_part { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right; decimal e = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-0)).Value; RESULT = e; CUP_parser_result = new CUP.runtime.Symbol(1/*expr_list*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 1: // $START ::= expr_list EOF { Object RESULT = null; int start_valleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).left; int start_valright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).right; decimal start_val = (decimal)((CUP.runtime.Symbol) CUP_parser_stack.Peek(CUP_parser_top-1)).Value; RESULT = start_val; CUP_parser_result = new CUP.runtime.Symbol(0/*$START*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } /* ACCEPT */ CUP_parser_parser.done_parsing(); return CUP_parser_result; /*. . . . . . . . . . . . . . . . . . . .*/ case 0: // expr_list ::= expr_list expr_part { decimal RESULT = decimal.Zero; CUP_parser_result = new CUP.runtime.Symbol(1/*expr_list*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top-0)).right, RESULT); } return CUP_parser_result; /* . . . . . .*/ default: throw new Exception( "Invalid action number found in internal parse table"); } }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>This method is called when a syntax error has been detected and recovery /// is about to be invoked. Here in the base class we just emit a /// "Syntax error" error message. /// * /// </summary> /// <param name="cur_token">the current lookahead Symbol. /// /// </param> public virtual void syntax_error(Symbol cur_token) { report_error("Syntax error", cur_token); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>This method is called if it is determined that syntax error recovery /// has been unsuccessful. Here in the base class we report a fatal error. /// * /// </summary> /// <param name="cur_token">the current lookahead Symbol. /// /// </param> public virtual void unrecovered_syntax_error(Symbol cur_token) { report_fatal_error("Couldn't repair and continue parse", cur_token); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>This method provides the main parsing routine. It returns only when /// done_parsing() has been called (typically because the parser has /// accepted, or a fatal error has been reported). See the header /// documentation for the class regarding how shift/reduce parsers operate /// and how the various tables are used. /// </summary> public virtual Symbol parse() { /* the current action code */ int act; /* the Symbol/stack element returned by a reduce */ Symbol lhs_sym = null; /* information about production being reduced with */ short handle_size, lhs_sym_num; /* set up direct reference to tables to drive the parser */ production_tab = production_table(); action_tab = action_table(); reduce_tab = reduce_table(); /* initialize the action encapsulation object */ init_actions(); /* do user initialization */ user_init(); /* get the first token */ cur_token = scan(); /* push dummy Symbol with start state to get us underway */ stack.Clear(); System.Object temp_object; temp_object = new Symbol(0, start_state()); System.Object generatedAux = temp_object; stack.Push(temp_object); tos = 0; /* continue until we are told to stop */ for (_done_parsing = false; !_done_parsing; ) { /* Check current token for freshness. */ if (cur_token.used_by_parser) throw new System.ApplicationException("Symbol recycling detected (fix your scanner)."); /* current state is always on the top of the stack */ /* look up action out of the current state with the current input */ act = get_action(((Symbol) stack.Peek()).parse_state, cur_token.sym); /* decode the action -- > 0 encodes shift */ if (act > 0) { /* shift to the encoded state by pushing it on the stack */ cur_token.parse_state = act - 1; cur_token.used_by_parser = true; System.Object temp_object2; temp_object2 = cur_token; System.Object generatedAux2 = temp_object2; stack.Push(temp_object2); tos++; /* advance to the next Symbol */ cur_token = scan(); } else if (act < 0) { /* perform the action for the reduce */ lhs_sym = do_action((- act) - 1, this, stack, tos); /* look up information about the production */ lhs_sym_num = production_tab[(- act) - 1][0]; handle_size = production_tab[(- act) - 1][1]; /* pop the handle off the stack */ for (int i = 0; i < handle_size; i++) { stack.Pop(); tos--; } /* look up the state to go to from the one popped back to */ act = get_reduce(((Symbol) stack.Peek()).parse_state, lhs_sym_num); /* shift to that state */ lhs_sym.parse_state = act; lhs_sym.used_by_parser = true; System.Object temp_object3; temp_object3 = lhs_sym; System.Object generatedAux3 = temp_object3; stack.Push(temp_object3); tos++; } else if (act == 0) { /* call user syntax error reporting routine */ syntax_error(cur_token); /* try to error recover */ if (!error_recovery(false)) { /* if that fails give up with a fatal syntax error */ unrecovered_syntax_error(cur_token); /* just in case that wasn't fatal enough, end parse */ done_parsing(); } else { lhs_sym = (Symbol) stack.Peek(); } } } return lhs_sym; }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Do debug output for shift. /// * /// </summary> /// <param name="shift_tkn">the Symbol being shifted onto the stack. /// /// </param> public virtual void debug_shift(Symbol shift_tkn) { debug_message("# Shift under term #" + shift_tkn.sym + " to state #" + shift_tkn.parse_state); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Reset the parse ahead input to one Symbol past where we started error /// recovery (this consumes one new Symbol from the real input). /// </summary> protected virtual void restart_lookahead() { /* move all the existing input over */ for (int i = 1; i < error_sync_size(); i++) lookahead[i - 1] = lookahead[i]; /* read a new Symbol into the last spot */ // BUG Fix by Bruce Hutton // Computer Science Department, University of Auckland, // Auckland, New Zealand. [applied 5-sep-1999 by csa] // The following two lines were out of order!! lookahead[error_sync_size() - 1] = cur_token; cur_token = scan(); /* reset our internal position marker */ lookahead_pos = 0; }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Read from input to establish our buffer of "parse ahead" lookahead /// Symbols. /// </summary> protected virtual void read_lookahead() { /* create the lookahead array */ lookahead = new Symbol[error_sync_size()]; /* fill in the array */ for (int i = 0; i < error_sync_size(); i++) { lookahead[i] = cur_token; cur_token = scan(); } /* start at the beginning */ lookahead_pos = 0; }
/** Method with the actual generated action code. */ public CUP.runtime.Symbol CUP_parser_do_action( int CUP_parser_act_num, CUP.runtime.lr_parser CUP_parser_parser, CUP.runtime.SymbolStack CUP_parser_stack, int CUP_parser_top) { /* Symbol object for return from actions */ CUP.runtime.Symbol CUP_parser_result; /* select the action based on the action number */ switch (CUP_parser_act_num) { /*. . . . . . . . . . . . . . . . . . . .*/ case 13: // expr ::= LPAREN expr RPAREN { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).right; decimal e = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).Value; RESULT = e; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 12: // expr ::= MINUS expr { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = -e; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 11: // expr ::= REAL { decimal RESULT = decimal.Zero; int nleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int nright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal n = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = n; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 10: // expr ::= INTEGER { decimal RESULT = decimal.Zero; int nleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int nright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; int n = (int)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = n; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 9: // expr ::= expr MOD expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = (decimal)((int)e1 % (int)e2); CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 8: // expr ::= expr DIVIDE expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e1 / e2; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 7: // expr ::= expr TIMES expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e1 * e2; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 6: // expr ::= expr MINUS expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e1 - e2; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 5: // expr ::= expr PLUS expr { decimal RESULT = decimal.Zero; int e1left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int e1right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e1 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; int e2left = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int e2right = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e2 = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e1 + e2; CUP_parser_result = new CUP.runtime.Symbol(3 /*expr*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 4: // expr_part ::= expr NT$0 SEMI { decimal RESULT = decimal.Zero; // propagate RESULT from NT$0 if (((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).Value != null) { RESULT = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).Value; } int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).right; decimal e = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).Value; CUP_parser_result = new CUP.runtime.Symbol(2 /*expr_part*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 2)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 3: // NT$0 ::= { Object RESULT = null; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e; Console.WriteLine("= " + e); CUP_parser_result = new CUP.runtime.Symbol(4 /*NT$0*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 2: // expr_list ::= expr_part { decimal RESULT = decimal.Zero; int eleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left; int eright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right; decimal e = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).Value; RESULT = e; CUP_parser_result = new CUP.runtime.Symbol(1 /*expr_list*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 1: // $START ::= expr_list EOF { Object RESULT = null; int start_valleft = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).left; int start_valright = ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).right; decimal start_val = (decimal)((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).Value; RESULT = start_val; CUP_parser_result = new CUP.runtime.Symbol(0 /*$START*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } /* ACCEPT */ CUP_parser_parser.done_parsing(); return(CUP_parser_result); /*. . . . . . . . . . . . . . . . . . . .*/ case 0: // expr_list ::= expr_list expr_part { decimal RESULT = decimal.Zero; CUP_parser_result = new CUP.runtime.Symbol(1 /*expr_list*/, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 1)).left, ((CUP.runtime.Symbol)CUP_parser_stack.Peek(CUP_parser_top - 0)).right, RESULT); } return(CUP_parser_result); /* . . . . . .*/ default: throw new Exception( "Invalid action number found in internal parse table"); } }