* src/main.c (main): Standardize.

* src/output.c (output_table_data, output_parser): Likewise.
* src/macrotab.h, src/macrotab.c, src/bison.simple: Likewise.
This commit is contained in:
Pascal Bart
2001-08-31 16:56:44 +00:00
parent 63c2d5de0f
commit e8cb70b957
6 changed files with 53 additions and 47 deletions

View File

@@ -1,3 +1,9 @@
2001-08-31 Pascal Bart <pascal.bart@epita.fr>
* src/main.c (main): Standardize.
* src/output.c (output_table_data, output_parser): Likewise.
* src/macrotab.h, src/macrotab.c, src/bison.simple: Likewise.
2001-08-31 Pascal Bart <pascal.bart@epita.fr>, Marc Autret <autret_m@epita.fr> 2001-08-31 Pascal Bart <pascal.bart@epita.fr>, Marc Autret <autret_m@epita.fr>
* src/reader.c (read_additionnal_code): Rename %%user_code to * src/reader.c (read_additionnal_code): Rename %%user_code to

View File

@@ -118,7 +118,7 @@ typedef struct yyltype
# define YYERROR_VERBOSE %%verbose # define YYERROR_VERBOSE %%verbose
#endif #endif
/* Tokens. */ /* Tokens. */
%%tokendef %%tokendef
#define YYFINAL %%final #define YYFINAL %%final
@@ -160,8 +160,8 @@ static const short yyrline[] =
#endif #endif
#if YYDEBUG || YYERROR_VERBOSE #if YYDEBUG || YYERROR_VERBOSE
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char* const yytname[] = static const char *const yytname[] =
{ {
%%tname %%tname
}; };
@@ -390,7 +390,7 @@ int %%yyparse (void);
/* The lookahead symbol. */ \ /* The lookahead symbol. */ \
int %%yychar; \ int %%yychar; \
\ \
/* The semantic value of the lookahead symbol. */ \ /* The semantic value of the lookahead symbol. */ \
YYSTYPE %%yylval; \ YYSTYPE %%yylval; \
\ \
/* Number of parse errors so far. */ \ /* Number of parse errors so far. */ \
@@ -407,7 +407,7 @@ YYLTYPE yylloc;
_YY_DECL_VARIABLES _YY_DECL_VARIABLES
#endif #endif
/* If nonreentrant, generate the variables here. */ /* If nonreentrant, generate the variables here. */
#if !YYPURE #if !YYPURE
YY_DECL_VARIABLES YY_DECL_VARIABLES
@@ -417,7 +417,7 @@ int
%%yyparse (YYPARSE_PARAM_ARG) %%yyparse (YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL YYPARSE_PARAM_DECL
{ {
/* If reentrant, generate the variables here. */ /* If reentrant, generate the variables here. */
#if YYPURE #if YYPURE
YY_DECL_VARIABLES YY_DECL_VARIABLES
#endif /* !YYPURE */ #endif /* !YYPURE */
@@ -437,7 +437,7 @@ int
Refer to the stacks thru separate pointers, to allow yyoverflow Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */ to reallocate them elsewhere. */
/* The state stack. */ /* The state stack. */
short yyssa[YYINITDEPTH]; short yyssa[YYINITDEPTH];
short *yyss = yyssa; short *yyss = yyssa;
register short *yyssp; register short *yyssp;
@@ -471,7 +471,7 @@ int
# endif # endif
/* When reducing, the number of symbols on the RHS of the reduced /* When reducing, the number of symbols on the RHS of the reduced
rule. */ rule. */
int yylen; int yylen;
YYDPRINTF ((stderr, "Starting parse\n")); YYDPRINTF ((stderr, "Starting parse\n"));
@@ -617,12 +617,12 @@ yybackup:
%%yychar = YYLEX; %%yychar = YYLEX;
} }
/* Convert token to internal form (in yychar1) for indexing tables with */ /* Convert token to internal form (in yychar1) for indexing tables with. */
if (%%yychar <= 0) /* This means end of input. */ if (%%yychar <= 0) /* This means end of input. */
{ {
yychar1 = 0; yychar1 = 0;
%%yychar = YYEOF; /* Don't call YYLEX any more */ %%yychar = YYEOF; /* Don't call YYLEX any more. */
YYDPRINTF ((stderr, "Now at end of input.\n")); YYDPRINTF ((stderr, "Now at end of input.\n"));
} }
@@ -745,7 +745,7 @@ yyreduce:
#endif #endif
switch (yyn) switch (yyn)
{ {
%%action /* The action file replaces this line. */ %%action /* The action file replaces this line. */
} }
#line %%line "%%filename" #line %%line "%%filename"
@@ -845,16 +845,16 @@ yyerrlab:
goto yyerrlab1; goto yyerrlab1;
/*--------------------------------------------------. /*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action | | yyerrlab1 -- error raised explicitly by an action. |
`--------------------------------------------------*/ `----------------------------------------------------*/
yyerrlab1: yyerrlab1:
if (yyerrstatus == 3) if (yyerrstatus == 3)
{ {
/* If just tried and failed to reuse lookahead token after an /* If just tried and failed to reuse lookahead token after an
error, discard it. */ error, discard it. */
/* return failure if at end of input */ /* Return failure if at end of input. */
if (%%yychar == YYEOF) if (%%yychar == YYEOF)
YYABORT; YYABORT;
YYDPRINTF ((stderr, "Discarding token %d (%s).\n", YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
@@ -865,7 +865,7 @@ yyerrlab1:
/* Else will try to reuse lookahead token after shifting the error /* Else will try to reuse lookahead token after shifting the error
token. */ token. */
yyerrstatus = 3; /* Each real token shifted decrements this */ yyerrstatus = 3; /* Each real token shifted decrements this. */
goto yyerrhandle; goto yyerrhandle;
@@ -888,7 +888,7 @@ yyerrdefault:
/*---------------------------------------------------------------. /*---------------------------------------------------------------.
| yyerrpop -- pop the current state because it cannot handle the | | yyerrpop -- pop the current state because it cannot handle the |
| error token | | error token. |
`---------------------------------------------------------------*/ `---------------------------------------------------------------*/
yyerrpop: yyerrpop:
if (yyssp == yyss) if (yyssp == yyss)

View File

@@ -29,21 +29,21 @@
struct hash_table macro_table; struct hash_table macro_table;
static unsigned long static unsigned long
mhash1 (const void* item) mhash1 (const void *item)
{ {
return_STRING_HASH_1 (((macro_entry_t*) item)->key); return_STRING_HASH_1 (((macro_entry_t *) item)->key);
} }
static unsigned long static unsigned long
mhash2 (const void* item) mhash2 (const void *item)
{ {
return_STRING_HASH_2 (((macro_entry_t*) item)->key); return_STRING_HASH_2 (((macro_entry_t *) item)->key);
} }
static int static int
mcmp (const void* x, const void* y) mcmp (const void *x, const void *y)
{ {
return strcmp (((macro_entry_t*) x)->key, ((macro_entry_t*) y)->key); return strcmp (((macro_entry_t*) x)->key, ((macro_entry_t *) y)->key);
} }
void void
@@ -51,18 +51,18 @@ macro_init (void)
{ {
hash_init (&macro_table, MTABSIZE, &mhash1, &mhash2, &mcmp); hash_init (&macro_table, MTABSIZE, &mhash1, &mhash2, &mcmp);
/* Version and input file. */ /* Version and input file. */
macro_insert ("version", VERSION); macro_insert ("version", VERSION);
macro_insert ("filename", "a.y"); macro_insert ("filename", "a.y");
/* Types. */ /* Types. */
macro_insert ("stype", "int"); macro_insert ("stype", "int");
macro_insert ("ltype", "yyltype"); macro_insert ("ltype", "yyltype");
/* Tokens. */ /* Tokens. */
macro_insert ("tokendef", ""); macro_insert ("tokendef", "");
/* Tables. */ /* Tables. */
macro_insert ("rhs", "0"); macro_insert ("rhs", "0");
macro_insert ("pact", "0"); macro_insert ("pact", "0");
macro_insert ("prhs", "0"); macro_insert ("prhs", "0");
@@ -76,7 +76,7 @@ macro_init (void)
macro_insert ("defgoto", "0"); macro_insert ("defgoto", "0");
macro_insert ("translate", "0"); macro_insert ("translate", "0");
/* Various macros. */ /* Various macros. */
macro_insert ("flag", "0"); macro_insert ("flag", "0");
macro_insert ("last", "0"); macro_insert ("last", "0");
macro_insert ("pure", "0"); macro_insert ("pure", "0");
@@ -87,7 +87,7 @@ macro_init (void)
macro_insert ("ntbase", "0"); macro_insert ("ntbase", "0");
macro_insert ("verbose", "0"); macro_insert ("verbose", "0");
/* Variable prefix names. */ /* Variable prefix names. */
macro_insert ("yyparse", "yyparse"); macro_insert ("yyparse", "yyparse");
macro_insert ("yylex", "yylex"); macro_insert ("yylex", "yylex");
macro_insert ("yyerror", "yyerror"); macro_insert ("yyerror", "yyerror");
@@ -96,24 +96,24 @@ macro_init (void)
macro_insert ("yydebug", "yydebug"); macro_insert ("yydebug", "yydebug");
macro_insert ("yynerrs", "yynerrs"); macro_insert ("yynerrs", "yynerrs");
/* No parser macros. */ /* No parser macros. */
macro_insert ("nnts", "0"); macro_insert ("nnts", "0");
macro_insert ("nrules", "0"); macro_insert ("nrules", "0");
macro_insert ("nstates", "0"); macro_insert ("nstates", "0");
macro_insert ("ntokens", "0"); macro_insert ("ntokens", "0");
/* Stack parameters. */ /* Stack parameters. */
macro_insert ("maxdepth", "10000"); macro_insert ("maxdepth", "10000");
macro_insert ("initdepth", "200"); macro_insert ("initdepth", "200");
/* C++ macros. */ /* C++ macros. */
macro_insert ("name", "Parser"); macro_insert ("name", "Parser");
} }
void void
macro_insert (const char *key, const char *value) macro_insert (const char *key, const char *value)
{ {
macro_entry_t* pair = XMALLOC (macro_entry_t, 1); macro_entry_t *pair = XMALLOC (macro_entry_t, 1);
pair->key = key; pair->key = key;
pair->value = value; pair->value = value;
hash_insert (&macro_table, pair); hash_insert (&macro_table, pair);
@@ -123,6 +123,6 @@ const char*
macro_find (const char *key) macro_find (const char *key)
{ {
macro_entry_t pair = { key, 0 }; macro_entry_t pair = { key, 0 };
macro_entry_t* result = hash_find_item (&macro_table, &pair); macro_entry_t *result = hash_find_item (&macro_table, &pair);
return result ? result->value : 0; return result ? result->value : 0;
} }

View File

@@ -25,12 +25,12 @@
typedef struct macro_entry_s typedef struct macro_entry_s
{ {
const char* key; const char *key;
const char* value; const char *value;
} macro_entry_t; } macro_entry_t;
void macro_init PARAMS ((void)); void macro_init PARAMS ((void));
void macro_insert PARAMS ((const char *key, const char *value)); void macro_insert PARAMS ((const char *key, const char *value));
const char* macro_find PARAMS ((const char *key)); const char *macro_find PARAMS ((const char *key));
#endif /* not MACROTAB_H_ */ #endif /* not MACROTAB_H_ */

View File

@@ -86,7 +86,7 @@ main (int argc, char *argv[])
/* Print information about results, if requested. */ /* Print information about results, if requested. */
print_results (); print_results ();
/* Output the VCG graph. */ /* Output the VCG graph. */
print_graph (); print_graph ();
/* Output the tables and the parser to ftable. In file output. */ /* Output the tables and the parser to ftable. In file output. */

View File

@@ -129,8 +129,8 @@ struct obstack output_obstack;
/* FIXME. */ /* FIXME. */
static inline void static inline void
output_table_data (struct obstack* oout, output_table_data (struct obstack *oout,
short* table_data, short *table_data,
short first, short first,
short begin, short begin,
short end) short end)
@@ -969,7 +969,7 @@ output_parser (void)
} }
fskel = xfopen (skeleton, "r"); fskel = xfopen (skeleton, "r");
/* New output code. */ /* New output code. */
line = 1; line = 1;
c = getc (fskel); c = getc (fskel);
while (c != EOF) while (c != EOF)
@@ -983,14 +983,14 @@ output_parser (void)
} }
else if ((c = getc (fskel)) == '%') else if ((c = getc (fskel)) == '%')
{ {
/* Read the macro. */ /* Read the macro. */
const char* macro_key = 0; const char *macro_key = 0;
const char* macro_value = 0; const char *macro_value = 0;
while (isalnum (c = getc (fskel)) || c == '_') while (isalnum (c = getc (fskel)) || c == '_')
obstack_1grow (&macro_obstack, c); obstack_1grow (&macro_obstack, c);
obstack_1grow (&macro_obstack, 0); obstack_1grow (&macro_obstack, 0);
/* Output the right value, or see if it's something special. */ /* Output the right value, or see if it's something special. */
macro_key = obstack_finish (&macro_obstack); macro_key = obstack_finish (&macro_obstack);
macro_value = macro_find (macro_key); macro_value = macro_find (macro_key);
if (macro_value) if (macro_value)
@@ -1013,7 +1013,7 @@ output_parser (void)
obstack_1grow (&table_obstack, '%'); obstack_1grow (&table_obstack, '%');
} }
/* End. */ /* End. */
xfclose (fskel); xfclose (fskel);
} }