summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-06-13 08:11:22 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-06-13 15:20:56 +0200
commitc857ed4f72b83c561bfd42e5ff6c129ddb2017ee (patch)
tree2230aeead8af9340f965af82342c8131930804c6
parent1998606a904f0155079beda7a76489ff6940a7b6 (diff)
downloadbison-c857ed4f72b83c561bfd42e5ff6c129ddb2017ee.tar.gz
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.
-rw-r--r--src/flex-scanner.h14
-rw-r--r--src/scan-code.l26
-rw-r--r--src/scan-gram.l64
-rw-r--r--src/scan-skel.l2
-rw-r--r--tests/input.at4
5 files changed, 55 insertions, 55 deletions
diff --git a/src/flex-scanner.h b/src/flex-scanner.h
index 6f686174..f0f3ae17 100644
--- a/src/flex-scanner.h
+++ b/src/flex-scanner.h
@@ -94,22 +94,22 @@ int FLEX_PREFIX (lex_destroy) (void);
keep (to construct ID, STRINGS etc.). Use the following macros to
use it.
- Use STRING_GROW to append what has just been matched, and
- STRING_FINISH to end the string (it puts the ending 0).
- 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. */
+ Use STRING_GROW () to append what has just been matched, and
+ STRING_FINISH () to end the string (it puts the ending 0).
+ 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. */
#ifndef FLEX_NO_OBSTACK
static struct obstack obstack_for_string;
-# define STRING_GROW \
+# define STRING_GROW() \
obstack_grow (&obstack_for_string, yytext, yyleng)
-# define STRING_FINISH \
+# define STRING_FINISH() \
(last_string = obstack_finish0 (&obstack_for_string))
-# define STRING_FREE \
+# define STRING_FREE() \
obstack_free (&obstack_for_string, last_string)
#endif
diff --git a/src/scan-code.l b/src/scan-code.l
index 1aaecd4e..86f87749 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -112,7 +112,7 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<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>
{
- "\n" STRING_GROW; BEGIN sc_context;
- {splice} STRING_GROW;
+ "\n" STRING_GROW (); BEGIN sc_context;
+ {splice} STRING_GROW ();
}
@@ -133,26 +133,26 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_CHARACTER,SC_STRING>
{
- {splice}|\\{splice}. STRING_GROW;
+ {splice}|\\{splice}. STRING_GROW ();
}
<SC_CHARACTER>
{
- "'" STRING_GROW; BEGIN sc_context;
+ "'" STRING_GROW (); BEGIN sc_context;
}
<SC_STRING>
{
- "\"" STRING_GROW; BEGIN sc_context;
+ "\"" STRING_GROW (); BEGIN sc_context;
}
<SC_RULE_ACTION,SC_SYMBOL_ACTION>
{
- "'" STRING_GROW; BEGIN SC_CHARACTER;
- "\"" STRING_GROW; BEGIN SC_STRING;
- "/"{splice}"*" STRING_GROW; BEGIN SC_COMMENT;
- "/"{splice}"/" STRING_GROW; BEGIN SC_LINE_COMMENT;
+ "'" STRING_GROW (); BEGIN SC_CHARACTER;
+ "\"" STRING_GROW (); BEGIN SC_STRING;
+ "/"{splice}"*" STRING_GROW (); BEGIN SC_COMMENT;
+ "/"{splice}"/" STRING_GROW (); BEGIN SC_LINE_COMMENT;
[$@] {
complain (loc, Wother, _("stray '%s'"), yytext);
@@ -199,10 +199,10 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
[$@\[\]] obstack_escape (&obstack_for_string, yytext);
/* By default, grow the string obstack with the input. */
- .|\n STRING_GROW;
+ .|\n STRING_GROW ();
/* 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
code_scanner_last_string_free (void)
{
- STRING_FREE;
+ STRING_FREE ();
}
void
diff --git a/src/scan-gram.l b/src/scan-gram.l
index e3d96f24..1bbcfd7d 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -115,7 +115,7 @@ static int bracketed_id_context_state = 0;
void
gram_scanner_last_string_free (void)
{
- STRING_FREE;
+ STRING_FREE ();
}
static void handle_syncline (char *, location);
@@ -344,7 +344,7 @@ eqopt ({sp}=)?
/* Code in between braces. */
"{" {
- STRING_GROW;
+ STRING_GROW ();
nesting = 0;
code_start = loc->start;
BEGIN SC_BRACED_CODE;
@@ -403,7 +403,7 @@ eqopt ({sp}=)?
{
\0 {
complain (loc, complaint, _("invalid null character"));
- STRING_FREE;
+ STRING_FREE ();
return GRAM_error;
}
}
@@ -533,7 +533,7 @@ eqopt ({sp}=)?
<SC_COMMENT>
{
- "*"{splice}"/" STRING_GROW; BEGIN context_state;
+ "*"{splice}"/" STRING_GROW (); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
@@ -544,8 +544,8 @@ eqopt ({sp}=)?
<SC_LINE_COMMENT>
{
- {eol} STRING_GROW; BEGIN context_state;
- {splice} STRING_GROW;
+ {eol} STRING_GROW (); BEGIN context_state;
+ {splice} STRING_GROW ();
<<EOF>> BEGIN context_state;
}
@@ -558,7 +558,7 @@ eqopt ({sp}=)?
<SC_ESCAPED_STRING>
{
"\"" {
- STRING_FINISH;
+ STRING_FINISH ();
BEGIN INITIAL;
loc->start = token_start;
complain (loc, Wyacc,
@@ -572,7 +572,7 @@ eqopt ({sp}=)?
<SC_ESCAPED_TSTRING>
{
"\")" {
- STRING_FINISH;
+ STRING_FINISH ();
BEGIN INITIAL;
loc->start = token_start;
complain (loc, Wyacc,
@@ -591,7 +591,7 @@ eqopt ({sp}=)?
<SC_ESCAPED_CHARACTER>
{
"'" {
- STRING_FINISH;
+ STRING_FINISH ();
BEGIN INITIAL;
loc->start = token_start;
val->CHAR = last_string[0];
@@ -599,18 +599,18 @@ eqopt ({sp}=)?
if (last_string[0] == '\0')
{
complain (loc, complaint, _("empty character literal"));
- STRING_FREE;
+ STRING_FREE ();
return GRAM_error;
}
else if (last_string[1] != '\0')
{
complain (loc, complaint, _("extra characters in character literal"));
- STRING_FREE;
+ STRING_FREE ();
return GRAM_error;
}
else
{
- STRING_FREE;
+ STRING_FREE ();
return CHAR;
}
}
@@ -630,18 +630,18 @@ eqopt ({sp}=)?
--nesting;
if (nesting < 0)
{
- STRING_FINISH;
+ STRING_FINISH ();
loc->start = token_start;
val->TAG = uniqstr_new (last_string);
- STRING_FREE;
+ STRING_FREE ();
BEGIN INITIAL;
return TAG;
}
- STRING_GROW;
+ STRING_GROW ();
}
- ([^<>]|->)+ STRING_GROW;
- "<"+ STRING_GROW; nesting += yyleng;
+ ([^<>]|->)+ STRING_GROW ();
+ "<"+ STRING_GROW (); nesting += yyleng;
<<EOF>> unexpected_eof (token_start, ">");
}
@@ -696,19 +696,19 @@ eqopt ({sp}=)?
<SC_CHARACTER,SC_STRING>
{
- {splice}|\\{splice}[^\n\[\]] STRING_GROW;
+ {splice}|\\{splice}[^\n\[\]] STRING_GROW ();
}
<SC_CHARACTER>
{
- "'" STRING_GROW; BEGIN context_state;
+ "'" STRING_GROW (); BEGIN context_state;
{eol} unexpected_newline (token_start, "'");
<<EOF>> unexpected_eof (token_start, "'");
}
<SC_STRING>
{
- "\"" STRING_GROW; BEGIN context_state;
+ "\"" STRING_GROW (); BEGIN context_state;
{eol} unexpected_newline (token_start, "\"");
<<EOF>> unexpected_eof (token_start, "\"");
}
@@ -721,25 +721,25 @@ eqopt ({sp}=)?
<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_PREDICATE>
{
"'" {
- STRING_GROW;
+ STRING_GROW ();
context_state = YY_START;
token_start = loc->start;
BEGIN SC_CHARACTER;
}
"\"" {
- STRING_GROW;
+ STRING_GROW ();
context_state = YY_START;
token_start = loc->start;
BEGIN SC_STRING;
}
"/"{splice}"*" {
- STRING_GROW;
+ STRING_GROW ();
context_state = YY_START;
token_start = loc->start;
BEGIN SC_COMMENT;
}
"/"{splice}"/" {
- STRING_GROW;
+ STRING_GROW ();
context_state = YY_START;
BEGIN SC_LINE_COMMENT;
}
@@ -754,12 +754,12 @@ eqopt ({sp}=)?
<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
(as '<' '<%'). */
- "<"{splice}"<" STRING_GROW;
+ "<"{splice}"<" STRING_GROW ();
<<EOF>> unexpected_eof (code_start, "}");
}
@@ -772,7 +772,7 @@ eqopt ({sp}=)?
--nesting;
if (nesting < 0)
{
- STRING_FINISH;
+ STRING_FINISH ();
loc->start = code_start;
BEGIN INITIAL;
RETURN_VALUE (BRACED_CODE, last_string);
@@ -786,7 +786,7 @@ eqopt ({sp}=)?
--nesting;
if (nesting < 0)
{
- STRING_FINISH;
+ STRING_FINISH ();
loc->start = code_start;
BEGIN INITIAL;
RETURN_VALUE (BRACED_PREDICATE, last_string);
@@ -803,7 +803,7 @@ eqopt ({sp}=)?
<SC_PROLOGUE>
{
"%}" {
- STRING_FINISH;
+ STRING_FINISH ();
loc->start = code_start;
BEGIN INITIAL;
RETURN_VALUE (PROLOGUE, last_string);
@@ -821,7 +821,7 @@ eqopt ({sp}=)?
<SC_EPILOGUE>
{
<<EOF>> {
- STRING_FINISH;
+ STRING_FINISH ();
loc->start = code_start;
BEGIN INITIAL;
RETURN_VALUE (EPILOGUE, last_string);
@@ -841,7 +841,7 @@ eqopt ({sp}=)?
Add a fallthrough "|." so that non UTF-8 input is still accepted
and does not jam the scanner. */
- {mbchar}|. STRING_GROW;
+ {mbchar}|. STRING_GROW ();
}
%%
diff --git a/src/scan-skel.l b/src/scan-skel.l
index d7e334d5..a5771639 100644
--- a/src/scan-skel.l
+++ b/src/scan-skel.l
@@ -100,7 +100,7 @@ static void output_mapped_file (char const *name);
<SC_AT_DIRECTIVE_ARGS>
{
- [^@]+ STRING_GROW;
+ [^@]+ STRING_GROW ();
"@@" obstack_1grow (&obstack_for_string, '@');
"@{" obstack_1grow (&obstack_for_string, '[');
diff --git a/tests/input.at b/tests/input.at
index 1dda9841..d152de31 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1690,8 +1690,8 @@ AT_CLEANUP
AT_SETUP([Unclosed constructs])
-# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed
-# constructs, so they were prepended to whatever it STRING_GROW'ed
+# Bison's scan-gram.l once forgot to STRING_FINISH () some unclosed
+# constructs, so they were prepended to whatever it STRING_GROW ()'ed
# next. It also threw them away rather than returning them to the
# parser. The effect was confusing subsequent error messages.