From: Marc Autret Date: Wed, 28 Nov 2001 22:28:01 +0000 (+0000) Subject: * src/reader.c (parse_dquoted_param): New. X-Git-Tag: before-m4-back-end~236 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/426cf563bd6b9b69efd3720d15ecb6326f667ce0 * src/reader.c (parse_dquoted_param): New. (parse_skel_decl): Use it. * src/lex.h: Add its prototype. * src/lex.c (literalchar): Become not static. --- diff --git a/ChangeLog b/ChangeLog index 68fd377d..3ff10416 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-11-28 Marc Autret + + * src/reader.c (parse_dquoted_param): New. + (parse_skel_decl): Use it. + * src/lex.h: Add its prototype. + * src/lex.c (literalchar): Become not static. + 2001-11-28 Marc Autret * src/output.h: And put its extern declaration here. diff --git a/src/lex.c b/src/lex.c index 651ff98e..78b8a8f3 100644 --- a/src/lex.c +++ b/src/lex.c @@ -152,7 +152,7 @@ xgetc (FILE *f) being, I prefer have literalchar behave like quotearg, and change my mind later if I was wrong. */ -static int +int literalchar (struct obstack *out, int *pcode, char term) { int c; diff --git a/src/lex.h b/src/lex.h index 16ac115a..df825a8b 100644 --- a/src/lex.h +++ b/src/lex.h @@ -73,6 +73,7 @@ void read_type_name PARAMS ((FILE *fin)); entry found. */ token_t lex PARAMS ((void)); +int literalchar PARAMS ((struct obstack *out, int *pcode, char term)); token_t parse_percent_token PARAMS ((void)); diff --git a/src/reader.c b/src/reader.c index 73e79704..8e7d9949 100644 --- a/src/reader.c +++ b/src/reader.c @@ -964,6 +964,52 @@ parse_muscle_decl (void) } + +/*---------------------------------. +| Parse a double quoted parameter. | +`---------------------------------*/ + +static const char * +parse_dquoted_param (const char *from) +{ + struct obstack param_obstack; + const char *param = NULL; + int c; + + obstack_init (¶m_obstack); + c = skip_white_space (); + + if (c != '"') + { + complain (_("invalid %s declaration"), from); + ungetc (c, finput); + skip_to_char ('%'); + return NULL; + } + + for (;;) + { + if (literalchar (NULL, &c, '\"')) + obstack_1grow (¶m_obstack, c); + else + break; + } + + obstack_1grow (¶m_obstack, '\0'); + param = obstack_finish (¶m_obstack); + + if (c != '"' || strlen (param) == 0) + { + complain (_("invalid %s declaration"), from); + if (c != '"') + ungetc (c, finput); + skip_to_char ('%'); + return NULL; + } + + return param; +} + /*----------------------------------. | Parse what comes after %skeleton. | `----------------------------------*/ @@ -971,7 +1017,7 @@ parse_muscle_decl (void) void parse_skel_decl (void) { - /* Complete with parse_dquoted_param () on the CVS branch 1.29. */ + skeleton = parse_dquoted_param ("%skeleton"); } /*----------------------------------------------------------------.