style changes in the scanners

* src/scan-code.l, src/scan-skel.l: Use a more traditional indentation
style for start-conditions.
Prefer "continue" to a comment, for empty actions.
Strip useless {}.
Remove useless start-condition clauses.
This commit is contained in:
Akim Demaille
2012-07-27 11:11:19 +02:00
parent a74a3158d4
commit 4d24ffb75e
2 changed files with 29 additions and 25 deletions

View File

@@ -98,11 +98,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
int braces_level = 0; int braces_level = 0;
/* Whether a semicolon is probably needed. /* Whether a semicolon is probably needed.
The heuristic is that a semicolon is not needed after '{', '}', ';',
or a C preprocessor directive, and that whitespaces and comments The heuristic is that a semicolon is not needed after '{', '}',
do not affect this flag. ';', or a C preprocessor directive, and that whitespaces and
Note that '{' does not need a semicolon because of '{}'. comments do not affect this flag. Note that '{' does not need a
A semicolon may be needed before a cpp direcive, but don't bother. */ semicolon because of '{}'. A semicolon may be needed before a
cpp directive, but don't bother. */
bool need_semicolon = false; bool need_semicolon = false;
/* Whether in a C preprocessor directive. Don't use a start condition /* Whether in a C preprocessor directive. Don't use a start condition
@@ -160,7 +161,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
} }
<SC_RULE_ACTION,SC_SYMBOL_ACTION>{ <SC_RULE_ACTION,SC_SYMBOL_ACTION>
{
"'" { "'" {
STRING_GROW; STRING_GROW;
BEGIN SC_CHARACTER; BEGIN SC_CHARACTER;

View File

@@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at);
"@@" fputc ('@', yyout); "@@" fputc ('@', yyout);
"@{" fputc ('[', yyout); "@{" fputc ('[', yyout);
"@}" fputc (']', yyout); "@}" fputc (']', yyout);
"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */ "@`" continue; /* Used by b4_cat in ../data/bison.m4. */
@\n /* Likewise. */ @\n continue;
"@oline@" fprintf (yyout, "%d", out_lineno + 1); "@oline@" fprintf (yyout, "%d", out_lineno + 1);
"@ofile@" QPUTS (outname); "@ofile@" QPUTS (outname);
@@ -87,11 +87,11 @@ static void fail_for_invalid_at (char const *at);
} }
/* This pattern must not match more than the previous @ patterns. */ /* This pattern must not match more than the previous @ patterns. */
@[^@{}`(\n]* fail_for_invalid_at (yytext); @[^@{}`(\n]* fail_for_invalid_at (yytext);
\n out_lineno++; ECHO; \n out_lineno++; ECHO;
[^@\n]+ ECHO; [^@\n]+ ECHO;
<INITIAL><<EOF>> { <<EOF>> {
if (outname) if (outname)
{ {
free (outname); free (outname);
@@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at);
return EOF; return EOF;
} }
<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, '[');
"@}" { obstack_1grow (&obstack_for_string, ']'); } "@}" obstack_1grow (&obstack_for_string, ']');
"@`" /* Empty. Useful for starting an argument "@`" continue; /* For starting an argument that begins with whitespace. */
that begins with whitespace. */ @\n continue;
@\n /* Empty. */
@[,)] { @[,)] {
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX) if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)
@@ -131,15 +131,17 @@ static void fail_for_invalid_at (char const *at);
} }
} }
@.? { fail_for_invalid_at (yytext); } @.? fail_for_invalid_at (yytext);
} }
<SC_AT_DIRECTIVE_SKIP_WS>{ <SC_AT_DIRECTIVE_SKIP_WS>
[ \t\r\n] {
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } [ \t\r\n] continue;
. { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; }
} }
<SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>{ <SC_AT_DIRECTIVE_ARGS,SC_AT_DIRECTIVE_SKIP_WS>
{
<<EOF>> { <<EOF>> {
fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]); fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]);
} }