mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
style: prefer 'FOO ()' to 'FOO' for function-like macros
* src/flex-scanner.h (STRING_GROW, STRING_FINISH, STRING_FREE): Make them function-like macros. Adjust dependencies.
This commit is contained in:
@@ -94,22 +94,22 @@ int FLEX_PREFIX (lex_destroy) (void);
|
|||||||
keep (to construct ID, STRINGS etc.). Use the following macros to
|
keep (to construct ID, STRINGS etc.). Use the following macros to
|
||||||
use it.
|
use it.
|
||||||
|
|
||||||
Use STRING_GROW to append what has just been matched, and
|
Use STRING_GROW () to append what has just been matched, and
|
||||||
STRING_FINISH to end the string (it puts the ending 0).
|
STRING_FINISH () to end the string (it puts the ending 0).
|
||||||
STRING_FINISH also stores this string in LAST_STRING, which can be
|
STRING_FINISH () also stores this string in LAST_STRING, which can be
|
||||||
used, and which is used by STRING_FREE to free the last string. */
|
used, and which is used by STRING_FREE () to free the last string. */
|
||||||
|
|
||||||
#ifndef FLEX_NO_OBSTACK
|
#ifndef FLEX_NO_OBSTACK
|
||||||
|
|
||||||
static struct obstack obstack_for_string;
|
static struct obstack obstack_for_string;
|
||||||
|
|
||||||
# define STRING_GROW \
|
# define STRING_GROW() \
|
||||||
obstack_grow (&obstack_for_string, yytext, yyleng)
|
obstack_grow (&obstack_for_string, yytext, yyleng)
|
||||||
|
|
||||||
# define STRING_FINISH \
|
# define STRING_FINISH() \
|
||||||
(last_string = obstack_finish0 (&obstack_for_string))
|
(last_string = obstack_finish0 (&obstack_for_string))
|
||||||
|
|
||||||
# define STRING_FREE \
|
# define STRING_FREE() \
|
||||||
obstack_free (&obstack_for_string, last_string)
|
obstack_free (&obstack_for_string, last_string)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_COMMENT>
|
<SC_COMMENT>
|
||||||
{
|
{
|
||||||
"*"{splice}"/" STRING_GROW; BEGIN sc_context;
|
"*"{splice}"/" STRING_GROW (); BEGIN sc_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,8 +122,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_LINE_COMMENT>
|
<SC_LINE_COMMENT>
|
||||||
{
|
{
|
||||||
"\n" STRING_GROW; BEGIN sc_context;
|
"\n" STRING_GROW (); BEGIN sc_context;
|
||||||
{splice} STRING_GROW;
|
{splice} STRING_GROW ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,26 +133,26 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_CHARACTER,SC_STRING>
|
<SC_CHARACTER,SC_STRING>
|
||||||
{
|
{
|
||||||
{splice}|\\{splice}. STRING_GROW;
|
{splice}|\\{splice}. STRING_GROW ();
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_CHARACTER>
|
<SC_CHARACTER>
|
||||||
{
|
{
|
||||||
"'" STRING_GROW; BEGIN sc_context;
|
"'" STRING_GROW (); BEGIN sc_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_STRING>
|
<SC_STRING>
|
||||||
{
|
{
|
||||||
"\"" STRING_GROW; BEGIN sc_context;
|
"\"" STRING_GROW (); BEGIN sc_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
|
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
|
||||||
{
|
{
|
||||||
"'" STRING_GROW; BEGIN SC_CHARACTER;
|
"'" STRING_GROW (); BEGIN SC_CHARACTER;
|
||||||
"\"" STRING_GROW; BEGIN SC_STRING;
|
"\"" STRING_GROW (); BEGIN SC_STRING;
|
||||||
"/"{splice}"*" STRING_GROW; BEGIN SC_COMMENT;
|
"/"{splice}"*" STRING_GROW (); BEGIN SC_COMMENT;
|
||||||
"/"{splice}"/" STRING_GROW; BEGIN SC_LINE_COMMENT;
|
"/"{splice}"/" STRING_GROW (); BEGIN SC_LINE_COMMENT;
|
||||||
|
|
||||||
[$@] {
|
[$@] {
|
||||||
complain (loc, Wother, _("stray '%s'"), yytext);
|
complain (loc, Wother, _("stray '%s'"), yytext);
|
||||||
@@ -199,10 +199,10 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
|
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
|
||||||
|
|
||||||
/* By default, grow the string obstack with the input. */
|
/* By default, grow the string obstack with the input. */
|
||||||
.|\n STRING_GROW;
|
.|\n STRING_GROW ();
|
||||||
|
|
||||||
/* End of processing. */
|
/* End of processing. */
|
||||||
<<EOF>> STRING_FINISH; return last_string;
|
<<EOF>> STRING_FINISH (); return last_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -835,7 +835,7 @@ code_props_translate_code (code_props *self)
|
|||||||
void
|
void
|
||||||
code_scanner_last_string_free (void)
|
code_scanner_last_string_free (void)
|
||||||
{
|
{
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ static int bracketed_id_context_state = 0;
|
|||||||
void
|
void
|
||||||
gram_scanner_last_string_free (void)
|
gram_scanner_last_string_free (void)
|
||||||
{
|
{
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_syncline (char *, location);
|
static void handle_syncline (char *, location);
|
||||||
@@ -344,7 +344,7 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
/* Code in between braces. */
|
/* Code in between braces. */
|
||||||
"{" {
|
"{" {
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
nesting = 0;
|
nesting = 0;
|
||||||
code_start = loc->start;
|
code_start = loc->start;
|
||||||
BEGIN SC_BRACED_CODE;
|
BEGIN SC_BRACED_CODE;
|
||||||
@@ -403,7 +403,7 @@ eqopt ({sp}=)?
|
|||||||
{
|
{
|
||||||
\0 {
|
\0 {
|
||||||
complain (loc, complaint, _("invalid null character"));
|
complain (loc, complaint, _("invalid null character"));
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
return GRAM_error;
|
return GRAM_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -533,7 +533,7 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
<SC_COMMENT>
|
<SC_COMMENT>
|
||||||
{
|
{
|
||||||
"*"{splice}"/" STRING_GROW; BEGIN context_state;
|
"*"{splice}"/" STRING_GROW (); BEGIN context_state;
|
||||||
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,8 +544,8 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
<SC_LINE_COMMENT>
|
<SC_LINE_COMMENT>
|
||||||
{
|
{
|
||||||
{eol} STRING_GROW; BEGIN context_state;
|
{eol} STRING_GROW (); BEGIN context_state;
|
||||||
{splice} STRING_GROW;
|
{splice} STRING_GROW ();
|
||||||
<<EOF>> BEGIN context_state;
|
<<EOF>> BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ eqopt ({sp}=)?
|
|||||||
<SC_ESCAPED_STRING>
|
<SC_ESCAPED_STRING>
|
||||||
{
|
{
|
||||||
"\"" {
|
"\"" {
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
loc->start = token_start;
|
loc->start = token_start;
|
||||||
complain (loc, Wyacc,
|
complain (loc, Wyacc,
|
||||||
@@ -572,7 +572,7 @@ eqopt ({sp}=)?
|
|||||||
<SC_ESCAPED_TSTRING>
|
<SC_ESCAPED_TSTRING>
|
||||||
{
|
{
|
||||||
"\")" {
|
"\")" {
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
loc->start = token_start;
|
loc->start = token_start;
|
||||||
complain (loc, Wyacc,
|
complain (loc, Wyacc,
|
||||||
@@ -591,7 +591,7 @@ eqopt ({sp}=)?
|
|||||||
<SC_ESCAPED_CHARACTER>
|
<SC_ESCAPED_CHARACTER>
|
||||||
{
|
{
|
||||||
"'" {
|
"'" {
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
loc->start = token_start;
|
loc->start = token_start;
|
||||||
val->CHAR = last_string[0];
|
val->CHAR = last_string[0];
|
||||||
@@ -599,18 +599,18 @@ eqopt ({sp}=)?
|
|||||||
if (last_string[0] == '\0')
|
if (last_string[0] == '\0')
|
||||||
{
|
{
|
||||||
complain (loc, complaint, _("empty character literal"));
|
complain (loc, complaint, _("empty character literal"));
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
return GRAM_error;
|
return GRAM_error;
|
||||||
}
|
}
|
||||||
else if (last_string[1] != '\0')
|
else if (last_string[1] != '\0')
|
||||||
{
|
{
|
||||||
complain (loc, complaint, _("extra characters in character literal"));
|
complain (loc, complaint, _("extra characters in character literal"));
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
return GRAM_error;
|
return GRAM_error;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
return CHAR;
|
return CHAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -630,18 +630,18 @@ eqopt ({sp}=)?
|
|||||||
--nesting;
|
--nesting;
|
||||||
if (nesting < 0)
|
if (nesting < 0)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
loc->start = token_start;
|
loc->start = token_start;
|
||||||
val->TAG = uniqstr_new (last_string);
|
val->TAG = uniqstr_new (last_string);
|
||||||
STRING_FREE;
|
STRING_FREE ();
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
}
|
}
|
||||||
|
|
||||||
([^<>]|->)+ STRING_GROW;
|
([^<>]|->)+ STRING_GROW ();
|
||||||
"<"+ STRING_GROW; nesting += yyleng;
|
"<"+ STRING_GROW (); nesting += yyleng;
|
||||||
|
|
||||||
<<EOF>> unexpected_eof (token_start, ">");
|
<<EOF>> unexpected_eof (token_start, ">");
|
||||||
}
|
}
|
||||||
@@ -696,19 +696,19 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
<SC_CHARACTER,SC_STRING>
|
<SC_CHARACTER,SC_STRING>
|
||||||
{
|
{
|
||||||
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
|
{splice}|\\{splice}[^\n\[\]] STRING_GROW ();
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_CHARACTER>
|
<SC_CHARACTER>
|
||||||
{
|
{
|
||||||
"'" STRING_GROW; BEGIN context_state;
|
"'" STRING_GROW (); BEGIN context_state;
|
||||||
{eol} unexpected_newline (token_start, "'");
|
{eol} unexpected_newline (token_start, "'");
|
||||||
<<EOF>> unexpected_eof (token_start, "'");
|
<<EOF>> unexpected_eof (token_start, "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_STRING>
|
<SC_STRING>
|
||||||
{
|
{
|
||||||
"\"" STRING_GROW; BEGIN context_state;
|
"\"" STRING_GROW (); BEGIN context_state;
|
||||||
{eol} unexpected_newline (token_start, "\"");
|
{eol} unexpected_newline (token_start, "\"");
|
||||||
<<EOF>> unexpected_eof (token_start, "\"");
|
<<EOF>> unexpected_eof (token_start, "\"");
|
||||||
}
|
}
|
||||||
@@ -721,25 +721,25 @@ eqopt ({sp}=)?
|
|||||||
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_PREDICATE>
|
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_PREDICATE>
|
||||||
{
|
{
|
||||||
"'" {
|
"'" {
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
context_state = YY_START;
|
context_state = YY_START;
|
||||||
token_start = loc->start;
|
token_start = loc->start;
|
||||||
BEGIN SC_CHARACTER;
|
BEGIN SC_CHARACTER;
|
||||||
}
|
}
|
||||||
"\"" {
|
"\"" {
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
context_state = YY_START;
|
context_state = YY_START;
|
||||||
token_start = loc->start;
|
token_start = loc->start;
|
||||||
BEGIN SC_STRING;
|
BEGIN SC_STRING;
|
||||||
}
|
}
|
||||||
"/"{splice}"*" {
|
"/"{splice}"*" {
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
context_state = YY_START;
|
context_state = YY_START;
|
||||||
token_start = loc->start;
|
token_start = loc->start;
|
||||||
BEGIN SC_COMMENT;
|
BEGIN SC_COMMENT;
|
||||||
}
|
}
|
||||||
"/"{splice}"/" {
|
"/"{splice}"/" {
|
||||||
STRING_GROW;
|
STRING_GROW ();
|
||||||
context_state = YY_START;
|
context_state = YY_START;
|
||||||
BEGIN SC_LINE_COMMENT;
|
BEGIN SC_LINE_COMMENT;
|
||||||
}
|
}
|
||||||
@@ -754,12 +754,12 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
<SC_BRACED_CODE,SC_PREDICATE>
|
<SC_BRACED_CODE,SC_PREDICATE>
|
||||||
{
|
{
|
||||||
"{"|"<"{splice}"%" STRING_GROW; nesting++;
|
"{"|"<"{splice}"%" STRING_GROW (); nesting++;
|
||||||
"%"{splice}">" STRING_GROW; nesting--;
|
"%"{splice}">" STRING_GROW (); nesting--;
|
||||||
|
|
||||||
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly
|
/* Tokenize '<<%' correctly (as '<<' '%') rather than incorrectly
|
||||||
(as '<' '<%'). */
|
(as '<' '<%'). */
|
||||||
"<"{splice}"<" STRING_GROW;
|
"<"{splice}"<" STRING_GROW ();
|
||||||
|
|
||||||
<<EOF>> unexpected_eof (code_start, "}");
|
<<EOF>> unexpected_eof (code_start, "}");
|
||||||
}
|
}
|
||||||
@@ -772,7 +772,7 @@ eqopt ({sp}=)?
|
|||||||
--nesting;
|
--nesting;
|
||||||
if (nesting < 0)
|
if (nesting < 0)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
RETURN_VALUE (BRACED_CODE, last_string);
|
RETURN_VALUE (BRACED_CODE, last_string);
|
||||||
@@ -786,7 +786,7 @@ eqopt ({sp}=)?
|
|||||||
--nesting;
|
--nesting;
|
||||||
if (nesting < 0)
|
if (nesting < 0)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
RETURN_VALUE (BRACED_PREDICATE, last_string);
|
RETURN_VALUE (BRACED_PREDICATE, last_string);
|
||||||
@@ -803,7 +803,7 @@ eqopt ({sp}=)?
|
|||||||
<SC_PROLOGUE>
|
<SC_PROLOGUE>
|
||||||
{
|
{
|
||||||
"%}" {
|
"%}" {
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
RETURN_VALUE (PROLOGUE, last_string);
|
RETURN_VALUE (PROLOGUE, last_string);
|
||||||
@@ -821,7 +821,7 @@ eqopt ({sp}=)?
|
|||||||
<SC_EPILOGUE>
|
<SC_EPILOGUE>
|
||||||
{
|
{
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
STRING_FINISH;
|
STRING_FINISH ();
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
RETURN_VALUE (EPILOGUE, last_string);
|
RETURN_VALUE (EPILOGUE, last_string);
|
||||||
@@ -841,7 +841,7 @@ eqopt ({sp}=)?
|
|||||||
|
|
||||||
Add a fallthrough "|." so that non UTF-8 input is still accepted
|
Add a fallthrough "|." so that non UTF-8 input is still accepted
|
||||||
and does not jam the scanner. */
|
and does not jam the scanner. */
|
||||||
{mbchar}|. STRING_GROW;
|
{mbchar}|. STRING_GROW ();
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ static void output_mapped_file (char const *name);
|
|||||||
|
|
||||||
<SC_AT_DIRECTIVE_ARGS>
|
<SC_AT_DIRECTIVE_ARGS>
|
||||||
{
|
{
|
||||||
[^@]+ STRING_GROW;
|
[^@]+ STRING_GROW ();
|
||||||
|
|
||||||
"@@" obstack_1grow (&obstack_for_string, '@');
|
"@@" obstack_1grow (&obstack_for_string, '@');
|
||||||
"@{" obstack_1grow (&obstack_for_string, '[');
|
"@{" obstack_1grow (&obstack_for_string, '[');
|
||||||
|
|||||||
@@ -1690,8 +1690,8 @@ AT_CLEANUP
|
|||||||
|
|
||||||
AT_SETUP([Unclosed constructs])
|
AT_SETUP([Unclosed constructs])
|
||||||
|
|
||||||
# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
|
# Bison's scan-gram.l once forgot to STRING_FINISH () some unclosed
|
||||||
# constructs, so they were prepended to whatever it STRING_GROW'ed
|
# constructs, so they were prepended to whatever it STRING_GROW ()'ed
|
||||||
# next. It also threw them away rather than returning them to the
|
# next. It also threw them away rather than returning them to the
|
||||||
# parser. The effect was confusing subsequent error messages.
|
# parser. The effect was confusing subsequent error messages.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user