📄 jikespg.g
字号:
q -> value = error_image; num_items++; SHORT_CHECK(num_items); if (rulehdr[num_rules].rhs_root == NULL) q -> next = q; else { q -> next = rulehdr[num_rules].rhs_root -> next; rulehdr[num_rules].rhs_root -> next = q; } rulehdr[num_rules].rhs_root = q; return;}./ | rule_list SYMBOL/:$offset $action://.$locationstatic void act$rule_number(void){ register int sym; register struct node *q; assign_symbol_no(SYM2.name, OMEGA); sym = symbol_image(SYM2.name); if (sym != empty) { if (sym == eoft_image) { sprintf(msg_line, "End-of-file symbol cannot be used " "in rule. Line %d, column %d", SYM2.start_line, SYM2.start_column); PRNTERR(msg_line); exit(12); } q = Allocate_node(); q -> value = sym; num_items++; SHORT_CHECK(num_items); if (rulehdr[num_rules].rhs_root == NULL) q -> next = q; else { q -> next = rulehdr[num_rules].rhs_root -> next; rulehdr[num_rules].rhs_root -> next = q; } rulehdr[num_rules].rhs_root = q; } return;}./ | '|' -- can't be first SYMBOL/:$offset bad_first_symbol_in_RULES_section, /* $rule_number */://.$locationstatic void bad_first_symbol_in_RULES_section(void){ sprintf(msg_line, "First symbol in Rules section is not " "a valid left-hand side.\n Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}./ | EMPTY_SYMBOL -- can't be first SYMBOL/:$offset bad_first_symbol_in_RULES_section, /* $rule_number */:/ | ERROR_SYMBOL -- can't be first SYMBOL/:$offset bad_first_symbol_in_RULES_section, /* $rule_number */:/ | keyword -- keyword out of place/:$offset bad_first_symbol_in_RULES_section, /* $rule_number */:/ | rule_list '|' produces -- No good !!!/:$offset rule_without_left_hand_side, /* $rule_number */://.$locationstatic void rule_without_left_hand_side(void){ sprintf(msg_line, "Rule without left-hand-side. Line %d, column %d", SYM3.start_line, SYM3.start_column); PRNTERR(msg_line); exit(12);}./ | rule_list action_block produces -- No good !!!/:$offset rule_without_left_hand_side, /* $rule_number */:/ | rule_list EMPTY_SYMBOL produces -- No good !!!/:$offset rule_without_left_hand_side, /* $rule_number */:/ | rule_list keyword produces -- No good !!!/:$offset $action://.$locationstatic void act$rule_number(void){ sprintf(msg_line, "Misplaced keyword found in Rules section " "Line %d, column %d", SYM2.start_line, SYM2.start_column); PRNTERR(msg_line); exit(12);}./ action_block ::= BLOCK/:$offset $action://.$locationstatic void act$rule_number(void){ if (action_bit) add_block_definition(&(SYM1)); return;}./ | HBLOCK/:$offset $action://.$locationstatic void act$rule_number(void){ if (action_bit) add_block_definition(&(SYM1)); return;}./ keyword ::= DEFINE_KEY/:$offset misplaced_keyword_found_in_RULES_section, /* $rule_number */://.$locationstatic void misplaced_keyword_found_in_RULES_section(void){ sprintf(msg_line, "Misplaced keyword found in RULES section. " "Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}./ | TERMINALS_KEY/:$offset misplaced_keyword_found_in_RULES_section, /* $rule_number */:/ | ALIAS_KEY/:$offset misplaced_keyword_found_in_RULES_section, /* $rule_number */:/ | START_KEY/:$offset misplaced_keyword_found_in_RULES_section, /* $rule_number */:/ | RULES_KEY/:$offset misplaced_keyword_found_in_RULES_section, /* $rule_number */:/ names_block ::= NAMES_KEY {names_definition}/:$no_action:/ names_definition ::= name produces name/:$offset $action://.$locationstatic void act$rule_number(void){ if (error_maps_bit) { int symbol; switch(SYM1.kind) { case EMPTY_SYMBOL_TK: symbol = empty; break; case ERROR_SYMBOL_TK: symbol = error_image; break; case EOL_SYMBOL_TK: symbol = eolt_image; break; case EOF_SYMBOL_TK: symbol = eoft_image; break; default: symbol = symbol_image(SYM1.name); break; } if (symbol == OMEGA) { sprintf(msg_line, "Symbol %s is undefined. Line %d, column %d", SYM1.name, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } if (symno[symbol].name_index != OMEGA) { sprintf(msg_line, "Symbol %s has been named more than once. " "Line %d, column %d.", SYM1.name, SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12); } symno[symbol].name_index = name_map(SYM3.name); } return;}./ | bad_name produces name/:$no_action:/ | name produces bad_name/:$no_action:/ name ::= SYMBOL/:$no_action:/ | EMPTY_SYMBOL/:$no_action:/ | ERROR_SYMBOL/:$no_action:/ | EOL_SYMBOL/:$no_action:/ | EOF_SYMBOL/:$no_action:/ | '|'/:$no_action:/ | produces/:$no_action:/ bad_name ::= DEFINE_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */://.$locationstatic void misplaced_keyword_found_in_NAMES_section(void){ sprintf(msg_line, "Keyword has been misplaced in NAMES section." " Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}./ | TERMINALS_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */:/ | ALIAS_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */:/ | START_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */:/ | RULES_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */:/ | NAMES_KEY/:$offset misplaced_keyword_found_in_NAMES_section, /* $rule_number */:/ | BLOCK/:$offset $action://.$locationstatic void act$rule_number(void){ sprintf(msg_line, "Misplaced action block found in NAMES " "section. Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}./ | MACRO_NAME/:$offset $action://.$locationstatic void act$rule_number(void){ sprintf(msg_line, "Misplaced macro name found in NAMES " "section. Line %d, column %d", SYM1.start_line, SYM1.start_column); PRNTERR(msg_line); exit(12);}./------------------------------------------------------------------------[define_block] ::= $EMPTY/:$no_action:/ | define_block/:$no_action:/[terminals_block] ::= $EMPTY/:$offset process_TERMINALS_section, /* $rule_number */://.$locationstatic void process_TERMINALS_section(void){ num_terminals = num_symbols; assign_symbol_no(keoft, OMEGA); eoft_image = symbol_image(keoft); if (error_maps_bit) { assign_symbol_no(kerror, OMEGA); error_image = symbol_image(kerror); } else error_image = DEFAULT_SYMBOL; /* should be 0 */ assign_symbol_no(kaccept, OMEGA); accept_image = symbol_image(kaccept); return;}./ | terminals_block/:$offset process_TERMINALS_section, /* $rule_number */:/[alias_block] ::= $EMPTY/:$offset process_ALIAS_section, /* $rule_number */://.$locationstatic void process_ALIAS_section(void){ register int i, k; register struct hash_type *p; k = 0; if (eoft_image <= num_terminals) k++; else num_terminals++; if (error_maps_bit) { if (error_image <= num_terminals) k++; else { num_terminals++; if (k == 1) error_image--; } } if (k > 0) { for (i = 0; i < HT_SIZE; i++) { p = hash_table[i]; while(p != NULL) { if (p -> number > num_terminals) p -> number -= k; else if (p -> number < -num_terminals) p -> number += k; p = p -> link; } } num_symbols -= k; accept_image -= k; } if (eolt_image == OMEGA) eolt_image = eoft_image; if (error_image == DEFAULT_SYMBOL) alias_map(kerror, DEFAULT_SYMBOL); return;}./ | alias_block/:$offset process_ALIAS_section, /* $rule_number */:/[start_block] ::= $EMPTY/:$no_action:/ | start_block/:$no_action:/[rules_block] ::= $EMPTY/:$no_action:/ | rules_block/:$no_action:/[names_block] ::= $EMPTY/:$no_action:/ | names_block/:$no_action:/[%END] ::= $EMPTY/:$no_action:/ | END_KEY/:$no_action:/------------------------------------------------------------------------{terminal_symbol} ::= $EMPTY/:$offset $action://.$locationstatic void act$rule_number(void){ assign_symbol_no(kempty, OMEGA); empty = symbol_image(kempty); return;}./ | {terminal_symbol} terminal_symbol/:$no_action:/{start_symbol} ::= $EMPTY/:$no_action:/ | {start_symbol} start_symbol/:$no_action:/{alias_definition} ::= $EMPTY/:$no_action:/ | {alias_definition} alias_definition/:$no_action:/{names_definition} ::= $EMPTY/:$no_action:/ | {names_definition} names_definition/:$no_action:/{action_block} ::= $EMPTY/:$no_action:/ | {action_block} action_block/:$no_action://:$offset NULL};:/$End
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -