Berkeley YACC
1993-03-03
Berkeley's version of Yet Another Compiler Compiler
|
Go to the source code of this file.
Functions | |
char * | mktemp () |
char * | getenv () |
done (int k) | |
Shutdown function. More... | |
onintr () | |
Signal handler callback. More... | |
set_signals () | |
Sets the appropriate signal handlers up. More... | |
usage () | |
getargs (int argc, argv) | |
char * | allocate (unsigned n) |
create_file_names () | |
open_files () | |
int | main (int argc, argv) |
Variables | |
char | dflag |
char | lflag |
char | rflag |
char | tflag |
char | vflag |
char * | symbol_prefix |
char * | file_prefix = "y" |
char * | myname = "yacc" |
char * | temp_form = "yacc.XXXXXXX" |
int | lineno |
int | outline |
char * | action_file_name |
char * | code_file_name |
char * | defines_file_name |
char * | input_file_name = "" |
char * | output_file_name |
char * | text_file_name |
char * | union_file_name |
char * | verbose_file_name |
FILE * | action_file |
FILE * | code_file |
FILE * | defines_file |
FILE * | input_file |
FILE * | output_file |
FILE * | text_file |
FILE * | union_file |
FILE * | verbose_file |
int | nitems |
int | nrules |
The number of rules in the grammar. More... | |
int | nsyms |
The number of symbols (terminals + non-terminals) in the grammar. More... | |
int | ntokens |
The number of tokens (terminals) in the grammar. More... | |
int | nvars |
The number of variables (non-terminals) in the grammar. More... | |
int | start_symbol |
Index of the starting symbol of the grammar. More... | |
char ** | symbol_name |
Array of symbol names. More... | |
short * | symbol_value |
short * | symbol_prec |
char * | symbol_assoc |
short * | ritem |
Representation of all productions (and items) More... | |
short * | rlhs |
List of left-hand sides of all rules. More... | |
short * | rrhs |
List of right-hand sides of all rules. More... | |
short * | rprec |
char * | rassoc |
short ** | derives |
List of rules that derive each non-terminal. More... | |
char * | nullable |
char* allocate | ( | unsigned | n | ) |
Definition at line 315 of file main.c.
References CALLOC, and no_space().
create_file_names | ( | ) |
Definition at line 330 of file main.c.
References action_file_name, code_file_name, CODE_SUFFIX, defines_file_name, DEFINES_SUFFIX, dflag, file_prefix, getenv(), MALLOC, mktemp(), no_space(), output_file_name, OUTPUT_SUFFIX, rflag, strcpy(), temp_form, text_file_name, union_file_name, verbose_file_name, VERBOSE_SUFFIX, and vflag.
Referenced by open_files().
getargs | ( | int | argc, |
argv | |||
) |
Definition at line 209 of file main.c.
References dflag, file_prefix, input_file, input_file_name, lflag, myname, rflag, symbol_prefix, tflag, usage(), and vflag.
Referenced by main().
char* getenv | ( | ) |
int main | ( | int | argc, |
argv | |||
) |
Definition at line 465 of file main.c.
References done(), getargs(), lalr(), lr0(), make_parser(), open_files(), output(), reader(), set_signals(), and verbose().
char* mktemp | ( | ) |
open_files | ( | ) |
Definition at line 413 of file main.c.
References action_file, action_file_name, code_file, code_file_name, create_file_names(), defines_file, defines_file_name, dflag, input_file, input_file_name, open_error(), output_file, output_file_name, rflag, text_file, text_file_name, union_file, union_file_name, verbose_file, verbose_file_name, and vflag.
Referenced by main().
usage | ( | ) |
FILE* action_file |
Definition at line 27 of file main.c.
Referenced by copy_action(), done(), open_files(), and output_semantic_actions().
char* action_file_name |
Definition at line 18 of file main.c.
Referenced by create_file_names(), done(), open_files(), and output_semantic_actions().
FILE* code_file |
Definition at line 29 of file main.c.
Referenced by open_files(), output_debug(), output_defines(), output_prefix(), output_semantic_actions(), output_stored_text(), output_stype(), output_table(), output_trailing_text(), and write_section().
char* code_file_name |
Definition at line 19 of file main.c.
Referenced by create_file_names(), open_files(), output_semantic_actions(), output_stored_text(), and output_trailing_text().
FILE* defines_file |
Definition at line 30 of file main.c.
Referenced by open_files(), and output_defines().
char* defines_file_name |
Definition at line 20 of file main.c.
Referenced by create_file_names(), and open_files().
short** derives |
List of rules that derive each non-terminal.
Array of pointers that associates to each symbol the list of productions that have it as the left-hand side. Each item in those lists is the identifying number of a rule. The first ntokens entries (the ones for terminals) are not set and should not be accessed. They are only present to make the indexes consistent with other arrays (i.e. this array can be indexed using the symbol number).
Allocated and filled in set_first_derives().
Definition at line 140 of file main.c.
Referenced by build_relations(), free_derives(), initialize_states(), set_derives(), set_EFF(), and set_first_derives().
char dflag |
Definition at line 4 of file main.c.
Referenced by copy_union(), create_file_names(), getargs(), open_files(), and output_defines().
char* file_prefix = "y" |
Definition at line 11 of file main.c.
Referenced by create_file_names(), and getargs().
FILE* input_file |
Definition at line 31 of file main.c.
Referenced by get_line(), getargs(), open_files(), and output_trailing_text().
char* input_file_name = "" |
Definition at line 21 of file main.c.
Referenced by copy_action(), copy_text(), copy_union(), default_action_warning(), dollar_error(), dollar_warning(), getargs(), illegal_character(), illegal_tag(), no_grammar(), open_files(), output_trailing_text(), over_unionized(), prec_redeclared(), reprec_warning(), restarted_warning(), retyped_warning(), revalued_warning(), syntax_error(), terminal_lhs(), terminal_start(), tokenized_start(), unexpected_EOF(), unknown_rhs(), unterminated_action(), unterminated_comment(), unterminated_string(), unterminated_text(), unterminated_union(), untyped_lhs(), untyped_rhs(), and used_reserved().
char lflag |
Definition at line 5 of file main.c.
Referenced by copy_action(), copy_text(), copy_union(), getargs(), output_semantic_actions(), output_stored_text(), and output_trailing_text().
int lineno |
Definition at line 15 of file main.c.
Referenced by add_symbol(), advance_to_start(), copy_action(), copy_ident(), copy_text(), copy_union(), declare_start(), declare_types(), default_action_warning(), get_line(), get_literal(), get_tag(), illegal_character(), keyword(), mark_symbol(), no_grammar(), output_trailing_text(), over_unionized(), prec_redeclared(), read_declarations(), read_grammar(), reprec_warning(), restarted_warning(), retyped_warning(), revalued_warning(), skip_comment(), terminal_start(), tokenized_start(), unexpected_EOF(), unknown_rhs(), untyped_lhs(), untyped_rhs(), and used_reserved().
char* myname = "yacc" |
Definition at line 12 of file main.c.
Referenced by default_action_warning(), dollar_error(), dollar_warning(), fatal(), getargs(), illegal_character(), illegal_tag(), no_grammar(), no_space(), open_error(), over_unionized(), prec_redeclared(), reprec_warning(), restarted_warning(), retyped_warning(), revalued_warning(), syntax_error(), terminal_lhs(), terminal_start(), tokenized_start(), total_conflicts(), undefined_goal(), undefined_symbol_warning(), unexpected_EOF(), unknown_rhs(), unterminated_action(), unterminated_comment(), unterminated_string(), unterminated_text(), unterminated_union(), untyped_lhs(), untyped_rhs(), unused_rules(), usage(), and used_reserved().
int nitems |
Definition at line 40 of file main.c.
Referenced by add_symbol(), allocate_itemsets(), allocate_storage(), copy_action(), end_rule(), generate_states(), get_state(), initialize_grammar(), insert_empty_rule(), pack_grammar(), set_maxrhs(), set_nullable(), and show_ritems().
int nrules |
The number of rules in the grammar.
Definition at line 45 of file main.c.
Referenced by allocate_storage(), closure(), copy_action(), end_rule(), finalize_closure(), generate_states(), initialize_grammar(), insert_empty_rule(), log_unused(), mark_symbol(), output_debug(), output_rule_data(), pack_grammar(), print_grammar(), read_grammar(), set_derives(), set_first_derives(), show_rrhs(), start_rule(), unused_rules(), and verbose().
int nsyms |
The number of symbols (terminals + non-terminals) in the grammar.
All symbols can be uniquely represented using integers in the range [0, nsyms - 1], which is obtained by joining the range of terminals [0, ntokens - 1] with the range of non-terminals [ntokens, nsyms - 1].
It holds that nsyms = ntokens + nvars.
Definition at line 55 of file main.c.
Referenced by allocate_itemsets(), allocate_storage(), goto_actions(), new_itemsets(), pack_symbols(), set_derives(), set_EFF(), set_first_derives(), set_goto_map(), and set_nullable().
int ntokens |
The number of tokens (terminals) in the grammar.
All tokens can be uniquely represented using integers in the range [0, ntokens - 1].
It holds that nsyms = ntokens + nvars.
Definition at line 64 of file main.c.
Referenced by add_reductions(), finalize_closure(), lalr(), output_actions(), output_debug(), output_defines(), pack_symbols(), set_first_derives(), set_goto_map(), token_actions(), and verbose().
char* nullable |
Definition at line 141 of file main.c.
Referenced by build_relations(), free_nullable(), initialize_F(), and set_nullable().
int nvars |
The number of variables (non-terminals) in the grammar.
All variables can be uniquely represented using integers in the range [ntokens, nsyms - 1], which is equivalent to the range [ntokens, ntokens + nvars - 1].
It holds that nsyms = ntokens + nvars.
Definition at line 74 of file main.c.
Referenced by output_actions(), pack_symbols(), set_derives(), set_EFF(), set_first_derives(), set_goto_map(), and verbose().
int outline |
Definition at line 16 of file main.c.
Referenced by copy_ident(), goto_actions(), output_base(), output_check(), output_debug(), output_defines(), output_prefix(), output_rule_data(), output_semantic_actions(), output_stored_text(), output_stype(), output_table(), output_trailing_text(), output_yydefred(), and write_section().
FILE* output_file |
Definition at line 32 of file main.c.
Referenced by copy_ident(), goto_actions(), open_files(), output_base(), output_check(), output_debug(), output_rule_data(), output_table(), and output_yydefred().
char* output_file_name |
Definition at line 22 of file main.c.
Referenced by create_file_names(), and open_files().
char* rassoc |
Definition at line 128 of file main.c.
Referenced by add_reduce(), expand_rules(), initialize_grammar(), insert_empty_rule(), mark_symbol(), pack_grammar(), and start_rule().
char rflag |
Definition at line 6 of file main.c.
Referenced by create_file_names(), getargs(), goto_actions(), open_files(), output(), output_base(), output_check(), output_debug(), output_rule_data(), output_table(), and output_yydefred().
short* ritem |
Representation of all productions (and items)
Typical shape: [1, 12, 21, -1, 2, 3, -2, 1, 4, -3, ...]
All productions are represented in this array as the list of their right-hand side symbols followed by the negation of their index. So the symbols on the right-hand side of the first rule are followed by -1, then there are the right-hand side symbols of the second rule and then -2, and so on.
Indices (using short integers) inside this array can represent rules (in that case they point to the first element after a negative one) or items, in which case they can point to any position; the element in that position is taken to be the first element after the "point" of the item. If the index points to a negative number, then it represents a reduction item for the rule whose number is the absolute value of the pointed element.
The array called rrhs contains indices inside this list and is used to associate to each rule the beginning of its production (that is, the closure item for that rule).
Definition at line 112 of file main.c.
Referenced by allocate_itemsets(), build_relations(), closure(), find_final_state(), log_unused(), new_itemsets(), output_debug(), pack_grammar(), print_core(), print_grammar(), save_reductions(), set_EFF(), set_maxrhs(), set_nullable(), show_cores(), and show_ritems().
short* rlhs |
List of left-hand sides of all rules.
This array associates to each production its left-hand side symbol.
Definition at line 119 of file main.c.
Referenced by log_unused(), output_debug(), output_rule_data(), pack_grammar(), print_core(), print_grammar(), print_nulls(), set_derives(), set_nullable(), and show_cores().
short* rprec |
Definition at line 127 of file main.c.
Referenced by add_reduce(), expand_rules(), initialize_grammar(), insert_empty_rule(), mark_symbol(), pack_grammar(), and start_rule().
short* rrhs |
List of right-hand sides of all rules.
Array of indices inside ritem. It is used record the position inside ritem where each rule begins.
Definition at line 126 of file main.c.
Referenced by build_relations(), closure(), initialize_states(), log_unused(), output_debug(), output_rule_data(), pack_grammar(), print_core(), print_nulls(), set_EFF(), show_cores(), and show_rrhs().
int start_symbol |
Index of the starting symbol of the grammar.
It holds that start_symbol = ntokens. In fact, the starting symbol is always placed at the beginning of the non-terminal range [ntokens, nsyms - 1].
Definition at line 82 of file main.c.
Referenced by free_derives(), goto_actions(), initialize_states(), output_rule_data(), pack_grammar(), pack_symbols(), set_derives(), set_EFF(), and set_first_derives().
char* symbol_assoc |
Definition at line 93 of file main.c.
Referenced by get_shifts(), and pack_symbols().
char** symbol_name |
Array of symbol names.
Array of strings representing the names of all symbols. All names are allocated in a single contiguous block of memory to improve locality.
Definition at line 90 of file main.c.
Referenced by log_unused(), output_debug(), output_defines(), pack_symbols(), print_conflicts(), print_core(), print_gotos(), print_grammar(), print_nulls(), print_reductions(), print_shifts(), set_nullable(), and show_cores().
short* symbol_prec |
Definition at line 92 of file main.c.
Referenced by get_shifts(), and pack_symbols().
char* symbol_prefix |
Definition at line 10 of file main.c.
Referenced by getargs(), goto_actions(), output_base(), output_check(), output_debug(), output_defines(), output_prefix(), output_rule_data(), output_table(), and output_yydefred().
short* symbol_value |
Definition at line 91 of file main.c.
Referenced by output_debug(), output_defines(), output_rule_data(), pack_symbols(), save_column(), and token_actions().
char* temp_form = "yacc.XXXXXXX" |
Definition at line 13 of file main.c.
Referenced by create_file_names().
FILE* text_file |
Definition at line 33 of file main.c.
Referenced by copy_text(), copy_union(), done(), open_files(), and output_stored_text().
char* text_file_name |
Definition at line 23 of file main.c.
Referenced by create_file_names(), done(), open_files(), and output_stored_text().
char tflag |
Definition at line 7 of file main.c.
Referenced by getargs(), and output_debug().
FILE* union_file |
Definition at line 35 of file main.c.
Referenced by copy_union(), done(), open_files(), and output_defines().
char* union_file_name |
Definition at line 24 of file main.c.
Referenced by create_file_names(), done(), open_files(), and output_defines().
FILE* verbose_file |
Definition at line 38 of file main.c.
Referenced by log_conflicts(), log_unused(), open_files(), print_actions(), print_conflicts(), print_core(), print_gotos(), print_grammar(), print_nulls(), print_reductions(), print_shifts(), print_state(), and verbose().
char* verbose_file_name |
Definition at line 25 of file main.c.
Referenced by create_file_names(), and open_files().
char vflag |
Definition at line 8 of file main.c.
Referenced by create_file_names(), getargs(), open_files(), print_grammar(), and verbose().