#include "xalloc.h"
#include "complain.h"
#include "gram.h"
-
-/* functions from main.c */
-extern char *printable_version PARAMS ((int));
+#include "quote.h"
/* Buffer for storing the current token. */
char *token_buffer;
switch (c)
{
case '/':
+ /* FIXME: Should probably be merged with copy_comment. */
c = getc (finput);
if (c != '*' && c != '/')
{
}
}
-/* do a getc, but give error message if EOF encountered */
+
+/*-----------------------------------------------------.
+| Do a getc, but give error message if EOF encountered |
+`-----------------------------------------------------*/
+
static int
xgetc (FILE *f)
{
}
else
{
+ char buf [] = "c";
+ buf[0] = c;
complain (_("unknown escape sequence: `\\' followed by `%s'"),
- printable_version (c));
+ quote (buf));
code = '?';
}
} /* has \ */
unlexed_symval = symval;
}
+/*-----------------------------------------------------------------.
+| We just read `<' from FIN. Store in TOKEN_BUFFER, the type name |
+| specified between the `<...>'. |
+`-----------------------------------------------------------------*/
+
+void
+read_type_name (FILE *fin)
+{
+ char *p = token_buffer;
+ int c = getc (fin);
+
+ while (c != '>')
+ {
+ if (c == EOF)
+ fatal (_("unterminated type name at end of file"));
+ if (c == '\n')
+ {
+ complain (_("unterminated type name"));
+ ungetc (c, fin);
+ break;
+ }
+
+ if (p == token_buffer + maxtoken)
+ p = grow_token_buffer (p);
+
+ *p++ = c;
+ c = getc (fin);
+ }
+ *p = 0;
+}
+
int
lex (void)
}
c = skip_white_space ();
- *token_buffer = c; /* for error messages (token buffer always valid) */
+ /* for error messages (token buffer always valid) */
+ *token_buffer = c;
token_buffer[1] = 0;
switch (c)
*p++ = '\'';
*p = 0;
symval = getsym (token_buffer);
- symval->class = STOKEN;
+ symval->class = token_sym;
if (!symval->user_token_number)
symval->user_token_number = code;
return IDENTIFIER;
int code; /* ignored here */
p = token_buffer;
*p++ = '\"';
- while (literalchar (&p, &code, '\"')) /* read up to and including " */
+ /* Read up to and including ". */
+ while (literalchar (&p, &code, '\"'))
{
if (p >= token_buffer + maxtoken - 4)
p = grow_token_buffer (p);
*p = 0;
symval = getsym (token_buffer);
- symval->class = STOKEN;
+ symval->class = token_sym;
return IDENTIFIER;
}
}
case '<':
- p = token_buffer;
- c = getc (finput);
- while (c != '>')
- {
- if (c == EOF)
- fatal (_("unterminated type name at end of file"));
- if (c == '\n')
- {
- complain (_("unterminated type name"));
- ungetc (c, finput);
- break;
- }
-
- if (p == token_buffer + maxtoken)
- p = grow_token_buffer (p);
-
- *p++ = c;
- c = getc (finput);
- }
- *p = 0;
+ read_type_name (finput);
return TYPENAME;
-
case '%':
return parse_percent_token ();
}
/* the following table dictates the action taken for the various %
- directives. A setflag value causes the named flag to be set. A
+ directives. A set_flag value causes the named flag to be set. A
retval action returns the code. */
struct percent_table_struct
{
const char *name;
- void *setflag;
+ void *set_flag;
int retval;
}
percent_table[] =
{ "semantic_parser", NULL, SEMANTIC_PARSER },
{ "pure_parser", NULL, PURE_PARSER },
{ "prec", NULL, PREC },
- { "no_lines", &nolinesflag, NOOP}, /* -l */
- { "raw", &rawtoknumflag, NOOP }, /* -r */
- { "token_table", &toknumflag, NOOP}, /* -k */
+ { "locations", &locations_flag, NOOP}, /* -l */
+ { "no_lines", &no_lines_flag, NOOP}, /* -l */
+ { "raw", &raw_flag, NOOP }, /* -r */
+ { "token_table", &token_table_flag, NOOP}, /* -k */
#if 0
/* These can be utilized after main is reoganized so
open_files() is deferred 'til after read_declarations().
But %{ and %union both put information into files
that have to be opened before read_declarations().
*/
- { "yacc", &yaccflag, NOOP}, /* -y */
- { "fixed_output_files", &yaccflag, NOOP}, /* -y */
- { "defines", &definesflag, NOOP}, /* -d */
- { "no_parser", &noparserflag, NOOP}, /* -n */
+ { "yacc", &yacc_flag, NOOP}, /* -y */
+ { "fixed_output_files", &yacc_flag, NOOP}, /* -y */
+ { "defines", &defines_flag, NOOP}, /* -d */
+ { "no_parser", &no_parser_flag, NOOP}, /* -n */
{ "output_file", &spec_outfile, SETOPT}, /* -o */
{ "file_prefix", &spec_file_prefix, SETOPT}, /* -b */
{ "name_prefix", &spec_name_prefix, SETOPT}, /* -p */
/* These would be acceptable, but they do not affect processing */
- { "verbose", &verboseflag, NOOP}, /* -v */
- { "debug", &debugflag, NOOP}, /* -t */
+ { "verbose", &verbose_flag, NOOP}, /* -v */
+ { "debug", &debug_flag, NOOP}, /* -t */
/* {"help", <print usage stmt>, NOOP}, *//* -h */
/* {"version", <print version number> , NOOP}, *//* -V */
#endif
break;
if (tx->retval == SETOPT)
{
- *((char **) (tx->setflag)) = optarg;
+ *((char **) (tx->set_flag)) = optarg;
return NOOP;
}
- if (tx->setflag)
+ if (tx->set_flag)
{
- *((int *) (tx->setflag)) = 1;
+ *((int *) (tx->set_flag)) = 1;
return NOOP;
}
return tx->retval;