📄 lpgact.i
字号:
// $Id: lpgact.i,v 1.2 1999/11/08 23:22:40 shields Exp $//// This software is subject to the terms of the IBM Jikes Compiler// License Agreement available at the following URL:// http://www.ibm.com/research/jikes.// Copyright (C) 1996, 1998, International Business Machines Corporation// and others. All Rights Reserved.// You must accept the terms of that agreement to use this software.//#line 65 "jikespg.g"#define SYM1 terminal[stack_top + 1]#define SYM2 terminal[stack_top + 2]#define SYM3 terminal[stack_top + 3]static void null_action(void){ return;}static void add_macro_definition(char *name, struct terminal_type *term){ if (num_defs >= (int)defelmt_size) { defelmt_size += DEFELMT_INCREMENT; defelmt = (struct defelmt_type *) (defelmt == (struct defelmt_type *) NULL ? malloc(defelmt_size * sizeof(struct defelmt_type)) : realloc(defelmt, defelmt_size * sizeof(struct defelmt_type))); if (defelmt == (struct defelmt_type *) NULL) nospace(__FILE__, __LINE__); } defelmt[num_defs].length = (*term).length; defelmt[num_defs].start_line = (*term).start_line; defelmt[num_defs].start_column = (*term).start_column; defelmt[num_defs].end_line = (*term).end_line; defelmt[num_defs].end_column = (*term).end_column; strcpy(defelmt[num_defs].name, name); num_defs++; return;}static void add_block_definition(struct terminal_type *term){ if (num_acts >= (int) actelmt_size) { actelmt_size += ACTELMT_INCREMENT; actelmt = (struct actelmt_type *) (actelmt == (struct actelmt_type *) NULL ? malloc(actelmt_size * sizeof(struct actelmt_type)) : realloc(actelmt, actelmt_size * sizeof(struct actelmt_type))); if (actelmt == (struct actelmt_type *) NULL) nospace(__FILE__, __LINE__); } actelmt[num_acts].rule_number = num_rules; actelmt[num_acts].start_line = (*term).start_line; actelmt[num_acts].start_column = (*term).start_column; actelmt[num_acts].end_line = (*term).end_line; actelmt[num_acts].end_column = (*term).end_column; actelmt[num_acts].header_block = ((*term).kind == HBLOCK_TK); num_acts++; return;}/* bad_symbol ::= EQUIVALENCE */#line 136 "jikespg.g"static void bad_first_symbol(void){ sprintf(msg_line, "First symbol: \"%s\" found in file is illegal. " "Line %d, column %d", SYM1.name, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* bad_symbol ::= BLOCK */#line 162 "jikespg.g"static void act10(void){ sprintf(msg_line, "Action block cannot be first object in file. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* macro_list ::= macro_name_symbol macro_block */#line 182 "jikespg.g"static void act13(void){ if (action_bit) add_macro_definition(SYM1.name, &(SYM2)); return;}/* macro_list ::= macro_list macro_name_symbol macro_block */#line 193 "jikespg.g"static void act14(void){ if (action_bit) add_macro_definition(SYM2.name, &(SYM3)); return;}/* macro_name_symbol ::= SYMBOL */#line 207 "jikespg.g"static void act16(void){ sprintf(msg_line, "Macro name \"%s\" does not start with the " "escape character. Line %d, column %d", SYM1.name, SYM1.start_line, SYM1.start_column); PRNTWNG(msg_line); return;}/* macro_name_symbol ::= OR */#line 221 "jikespg.g"static void bad_macro_name(void){ sprintf(msg_line, "Reserved symbol cannot be used as macro name. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* macro_name_symbol ::= BLOCK */#line 241 "jikespg.g"static void act21(void){ sprintf(msg_line, "Macro name not supplied for macro definition. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* macro_name_symbol ::= DEFINE_KEY */#line 255 "jikespg.g"static void act22(void){ sprintf(msg_line, "Macro keyword misplaced. Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* macro_block ::= OR */#line 271 "jikespg.g"static void definition_expected(void){ sprintf(msg_line, "Definition block expected where symbol found. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* terminal_symbol ::= SYMBOL */#line 302 "jikespg.g"static void process_terminal(void){ assign_symbol_no(SYM1.name, OMEGA); return;}/* terminal_symbol ::= DEFINE_KEY */#line 316 "jikespg.g"static void bad_terminal(void){ sprintf(msg_line, "Keyword has been misplaced in Terminal section." " Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* terminal_symbol ::= BLOCK */#line 332 "jikespg.g"static void act37(void){ sprintf(msg_line, "Misplaced block found in TERMINALS section." " Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* alias_definition ::= alias_lhs produces alias_rhs */#line 350 "jikespg.g"static void act39(void){ register int image; char tok_string[SYMBOL_SIZE + 1]; switch(SYM3.kind) { case EMPTY_SYMBOL_TK: image = empty; break; case SYMBOL_TK: assign_symbol_no(SYM3.name, OMEGA); image = symbol_image(SYM3.name); break; case ERROR_SYMBOL_TK: if (error_image > num_terminals) { restore_symbol(tok_string, kerror); sprintf(msg_line, "Illegal aliasing to %s prior to its " "definition. Line %d, column %d", tok_string, SYM3.start_line, SYM3.start_column); PRNTERR(msg_line); exit(12); } image = error_image; break; case EOF_SYMBOL_TK: if (eoft_image > num_terminals) { restore_symbol(tok_string, keoft); sprintf(msg_line, "Illegal aliasing to %s prior to its " "definition. Line %d, column %d", tok_string, SYM3.start_line, SYM3.start_column); PRNTERR(msg_line); exit(12); } image = eoft_image; break; case EOL_SYMBOL_TK: if (eolt_image == OMEGA) { sprintf(msg_line, "Illegal aliasing to EOL prior to its " "definition. Line %d, column %d", SYM3.start_line, SYM3.start_column); PRNTERR(msg_line); exit(12); } image = eolt_image; break; default: /* if SYM3.kind == symbol */ image = symbol_image(SYM3.name); break; } switch(SYM1.kind) { case SYMBOL_TK: if (symbol_image(SYM1.name) != OMEGA) { restore_symbol(tok_string, SYM1.name); sprintf(msg_line, "Symbol %s was previously defined. " "Line %d, column %d", tok_string, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } assign_symbol_no(SYM1.name, image); break; case ERROR_SYMBOL_TK: if (error_image > num_terminals || ! error_maps_bit) { if (image == empty || image == eolt_image || image == eoft_image || image > num_terminals) { restore_symbol(tok_string, kerror); sprintf(msg_line, "Illegal alias for symbol %s. " "Line %d, column %d.", tok_string, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } alias_map(kerror, image); error_image = image; } else { restore_symbol(tok_string, kerror); sprintf(msg_line, "Symbol %s was previously defined. " "Line %d, column %d", tok_string, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } break; case EOF_SYMBOL_TK: if (eoft_image > num_terminals) { if (image == empty || image == eolt_image || image == error_image || image > num_terminals) { restore_symbol(tok_string, keoft); sprintf(msg_line, "Illegal alias for symbol %s. " "Line %d, column %d.", tok_string, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } alias_map(keoft, image); eoft_image = image; } else { restore_symbol(tok_string, keoft); sprintf(msg_line, "Symbol %s was previously defined. " "Line %d, column %d", tok_string, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } break; default: /* if SYM1.kind == EOL_SYMBOL */ if (eolt_image == OMEGA) { if (image == empty || image == eoft_image || image == error_image || image > num_terminals) { sprintf(msg_line, "Illegal alias for symbol EOL. " "Line %d, column %d.", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } eolt_image = image; } else { sprintf(msg_line, "Symbol EOL was previously defined. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } break; } return;}/* bad_alias_rhs ::= DEFINE_KEY */#line 558 "jikespg.g"static void bad_alias_rhs(void){ sprintf(msg_line, "Misplaced keyword found in Alias section. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* bad_alias_rhs ::= BLOCK */#line 576 "jikespg.g"static void act57(void){ sprintf(msg_line, "Misplaced block found in Alias section. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* bad_alias_lhs ::= EMPTY_SYMBOL */#line 594 "jikespg.g"static void act59(void){ sprintf(msg_line, "Empty symbol cannot be aliased. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* bad_alias_lhs ::= produces */#line 608 "jikespg.g"static void missing_quote(void){ sprintf(msg_line, "Symbol must be quoted when used as a " "grammar symbol. Line %d, column %d", ormark, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}/* start_symbol ::= SYMBOL */#line 630 "jikespg.g"/*********************************************************************//*********************************************************************/static void act63(void){ register struct node *q; assign_symbol_no(SYM1.name, OMEGA); q = Allocate_node(); q -> value = symbol_image(SYM1.name); if (start_symbol_root == NULL) q -> next = q; else { q -> next = start_symbol_root -> next; start_symbol_root -> next = q; } start_symbol_root = q; num_rules++; num_items++; SHORT_CHECK(num_items); return;}/* start_symbol ::= OR */#line 657 "jikespg.g"static void bad_start_symbol(void){ sprintf(msg_line,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -