From 7db2ed2d82f65d980ab93645e288b0b75c74e3e6 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 3 Jul 2002 12:51:30 +0000 Subject: [PATCH] * src/output.c (froms, tos): Are state_number_t. (save_column): sp, sp1, and sp2 are state_number_t. (prepare): Rename `final' as `final_state_number', `nnts' as `nterms_number', `nrules' as `rules_number', `nstates' as `states_number', and `ntokens' as `tokens_number'. Remove `nsym', unused. * data/yacc.c, data/glr.c, data/lalr1.cc: Adjust. * data/lalr1.cc (nsym_): Remove, unused. --- ChangeLog | 11 +++++++++ data/glr.c | 10 ++++---- data/lalr1.cc | 8 +++---- data/yacc.c | 10 ++++---- src/output.c | 65 ++++++++++++++++++++++++++------------------------- src/state.c | 6 ++--- 6 files changed, 60 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26fa0e58..f153d48c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-07-03 Akim Demaille + + * src/output.c (froms, tos): Are state_number_t. + (save_column): sp, sp1, and sp2 are state_number_t. + (prepare): Rename `final' as `final_state_number', `nnts' as + `nterms_number', `nrules' as `rules_number', `nstates' as + `states_number', and `ntokens' as `tokens_number'. Remove `nsym', + unused. + * data/yacc.c, data/glr.c, data/lalr1.cc: Adjust. + * data/lalr1.cc (nsym_): Remove, unused. + 2002-07-03 Akim Demaille * src/lalr.h, src/lalr.c (goto_number_t): New. diff --git a/data/glr.c b/data/glr.c index 8918aa89..2d30eb9e 100644 --- a/data/glr.c +++ b/data/glr.c @@ -218,18 +218,18 @@ static YYLTYPE yyloc_default; #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL ]b4_final[ +#define YYFINAL ]b4_final_state_number[ #define YYFLAG ]b4_flag[ #define YYLAST ]b4_last[ /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS ]b4_ntokens[ +#define YYNTOKENS ]b4_tokens_number[ /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS ]b4_nnts[ +#define YYNNTS ]b4_nterms_number[ /* YYNRULES -- Number of rules. */ -#define YYNRULES ]b4_nrules[ +#define YYNRULES ]b4_rules_number[ /* YYNRULES -- Number of states. */ -#define YYNSTATES ]b4_nstates[ +#define YYNSTATES ]b4_states_number[ /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ #define YYMAXRHS ]b4_r2_max[ diff --git a/data/lalr1.cc b/data/lalr1.cc index 1488d921..f0844bb2 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -253,7 +253,6 @@ namespace yy static const int last_; static const int flag_; static const int nnts_; - static const int nsym_; static const int empty_; static const int final_; static const int terror_; @@ -759,13 +758,12 @@ yy::b4_name::translate_ (int token) const int yy::b4_name::eof_ = 0; const int yy::b4_name::last_ = b4_last; const int yy::b4_name::flag_ = b4_flag; -const int yy::b4_name::nnts_ = b4_nnts; -const int yy::b4_name::nsym_ = b4_nsym; +const int yy::b4_name::nnts_ = b4_nterms_number; const int yy::b4_name::empty_ = -2; -const int yy::b4_name::final_ = b4_final; +const int yy::b4_name::final_ = b4_final_state_number; const int yy::b4_name::terror_ = 1; const int yy::b4_name::errcode_ = 256; -const int yy::b4_name::ntokens_ = b4_ntokens; +const int yy::b4_name::ntokens_ = b4_tokens_number; const int yy::b4_name::initdepth_ = b4_initdepth; const unsigned yy::b4_name::user_token_number_max_ = b4_user_token_number_max; diff --git a/data/yacc.c b/data/yacc.c index c96586d5..fff62912 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -302,18 +302,18 @@ b4_location_if( #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL b4_final +#define YYFINAL b4_final_state_number #define YYFLAG b4_flag #define YYLAST b4_last /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS b4_ntokens +#define YYNTOKENS b4_tokens_number /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS b4_nnts +#define YYNNTS b4_nterms_number /* YYNRULES -- Number of rules. */ -#define YYNRULES b4_nrules +#define YYNRULES b4_rules_number /* YYNRULES -- Number of states. */ -#define YYNSTATES b4_nstates +#define YYNSTATES b4_states_number /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK b4_undef_token_number diff --git a/src/output.c b/src/output.c index 3e907a14..dec92b85 100644 --- a/src/output.c +++ b/src/output.c @@ -20,17 +20,15 @@ 02111-1307, USA. */ -/* The parser tables consist of these tables. Marked ones needed only - for the semantic parser. Double marked are output only if switches - are set. +/* The parser tables consist of these tables. YYTRANSLATE = vector mapping yylex's token numbers into bison's token numbers. - ++ YYTNAME = vector of string-names indexed by bison token number. + YYTNAME = vector of string-names indexed by bison token number. - ++ YYTOKNUM = vector of yylex token numbers corresponding to - entries in YYTNAME. + YYTOKNUM = vector of yylex token numbers corresponding to entries + in YYTNAME. YYRLINE = vector of line-numbers of all rules. For yydebug printouts. @@ -44,8 +42,7 @@ YYR2[R] = number of symbols composing right hand side of rule R. - + YYSTOS[S] = the symbol number of the symbol that leads to state - S. + YYSTOS[S] = the symbol number of the symbol that leads to state S. YYDEFACT[S] = default rule to reduce with in state s, when YYTABLE doesn't specify something else to do. Zero means the default is an @@ -109,8 +106,8 @@ void m4_invoke PARAMS ((const char *definitions)); static int nvectors; static int nentries; -static short **froms = NULL; -static short **tos = NULL; +static state_number_t **froms = NULL; +static state_number_t **tos = NULL; static unsigned int **conflict_tos = NULL; static short *tally = NULL; static short *width = NULL; @@ -790,14 +787,14 @@ static void save_column (symbol_number_t symbol, state_number_t default_state) { int i; - short *sp; - short *sp1; - short *sp2; + state_number_t *sp; + state_number_t *sp1; + state_number_t *sp2; int count; int symno = symbol - ntokens + state_number_as_int (nstates); - int begin = goto_map[symbol]; - int end = goto_map[symbol + 1]; + goto_number_t begin = goto_map[symbol]; + goto_number_t end = goto_map[symbol + 1]; count = 0; for (i = begin; i < end; i++) @@ -827,8 +824,8 @@ default_goto (symbol_number_t symbol) { state_number_t s; int i; - int m = goto_map[symbol]; - int n = goto_map[symbol + 1]; + goto_number_t m = goto_map[symbol]; + goto_number_t n = goto_map[symbol + 1]; state_number_t default_state = (state_number_t) -1; int max = 0; @@ -1214,33 +1211,37 @@ output_skeleton (void) static void prepare (void) { - MUSCLE_INSERT_INT ("last", high); - MUSCLE_INSERT_INT ("flag", SHRT_MIN); + /* Flags. */ + MUSCLE_INSERT_INT ("locations_flag", locations_flag); + MUSCLE_INSERT_INT ("defines_flag", defines_flag); + MUSCLE_INSERT_INT ("error_verbose", error_verbose); MUSCLE_INSERT_INT ("pure", pure_parser); - MUSCLE_INSERT_INT ("nsym", nsyms); MUSCLE_INSERT_INT ("debug", debug_flag); - MUSCLE_INSERT_INT ("final", final_state->number); - MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number); - MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number); - MUSCLE_INSERT_INT ("error_verbose", error_verbose); - MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); /* FIXME: This is wrong: the muscles should decide whether they hold a copy or not, but the situation is too obscure currently. */ + MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy"); MUSCLE_INSERT_STRING ("output_infix", output_infix ? output_infix : ""); MUSCLE_INSERT_STRING ("output_prefix", short_base_name); MUSCLE_INSERT_STRING ("output_parser_name", parser_file_name); MUSCLE_INSERT_STRING ("output_header_name", spec_defines_file); - MUSCLE_INSERT_INT ("nnts", nvars); - MUSCLE_INSERT_INT ("nrules", nrules); - MUSCLE_INSERT_INT ("nstates", nstates); - MUSCLE_INSERT_INT ("ntokens", ntokens); + /* Symbols. */ + MUSCLE_INSERT_INT ("tokens_number", ntokens); + MUSCLE_INSERT_INT ("nterms_number", nvars); + MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number); + MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number); - MUSCLE_INSERT_INT ("locations_flag", locations_flag); - MUSCLE_INSERT_INT ("defines_flag", defines_flag); + /* Rules. */ + MUSCLE_INSERT_INT ("rules_number", nrules); + + /* States. */ + MUSCLE_INSERT_INT ("last", high); + MUSCLE_INSERT_INT ("flag", SHRT_MIN); + MUSCLE_INSERT_INT ("final_state_number", final_state->number); + MUSCLE_INSERT_INT ("states_number", nstates); - /* Copy definitions in directive. */ + /* User Code. */ obstack_1grow (&pre_prologue_obstack, 0); obstack_1grow (&post_prologue_obstack, 0); muscle_insert ("pre_prologue", obstack_finish (&pre_prologue_obstack)); diff --git a/src/state.c b/src/state.c index 24a05918..92180895 100644 --- a/src/state.c +++ b/src/state.c @@ -35,9 +35,9 @@ | Create a new array of N shifts/gotos. | `---------------------------------------*/ -#define TRANSITIONS_ALLOC(Nshifts) \ - (transitions_t *) xcalloc ((unsigned) (sizeof (transitions_t) \ - + (Nshifts - 1) * sizeof (state_number_t)), 1) +#define TRANSITIONS_ALLOC(Num) \ + (transitions_t *) xcalloc ((sizeof (transitions_t) \ + + (Num - 1) * sizeof (state_number_t)), 1) static transitions_t * transitions_new (int num, state_number_t *the_states) -- 2.45.2