From 4d24ffb75ebfc7c4fae027e23132c6d3630998b5 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 27 Jul 2012 11:11:19 +0200 Subject: [PATCH] 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. --- src/scan-code.l | 14 ++++++++------ src/scan-skel.l | 40 +++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/scan-code.l b/src/scan-code.l index e30bf9db..31b44298 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -98,11 +98,12 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" int braces_level = 0; /* 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 - do not affect this flag. - Note that '{' does not need a semicolon because of '{}'. - A semicolon may be needed before a cpp direcive, but don't bother. */ + + The heuristic is that a semicolon is not needed after '{', '}', + ';', or a C preprocessor directive, and that whitespaces and + comments do not affect this flag. Note that '{' does not need a + semicolon because of '{}'. A semicolon may be needed before a + cpp directive, but don't bother. */ bool need_semicolon = false; /* Whether in a C preprocessor directive. Don't use a start condition @@ -160,7 +161,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$" } -{ + +{ "'" { STRING_GROW; BEGIN SC_CHARACTER; diff --git a/src/scan-skel.l b/src/scan-skel.l index 24339057..862b34fd 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -72,8 +72,8 @@ static void fail_for_invalid_at (char const *at); "@@" fputc ('@', yyout); "@{" fputc ('[', yyout); "@}" fputc (']', yyout); -"@`" /* Empty. Used by b4_cat in ../data/bison.m4. */ -@\n /* Likewise. */ +"@`" continue; /* Used by b4_cat in ../data/bison.m4. */ +@\n continue; "@oline@" fprintf (yyout, "%d", out_lineno + 1); "@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. */ -@[^@{}`(\n]* fail_for_invalid_at (yytext); -\n out_lineno++; ECHO; -[^@\n]+ ECHO; +@[^@{}`(\n]* fail_for_invalid_at (yytext); +\n out_lineno++; ECHO; +[^@\n]+ ECHO; -<> { +<> { if (outname) { free (outname); @@ -100,15 +100,15 @@ static void fail_for_invalid_at (char const *at); return EOF; } -{ - [^@]+ { STRING_GROW; } + +{ + [^@]+ STRING_GROW; - "@@" { obstack_1grow (&obstack_for_string, '@'); } - "@{" { obstack_1grow (&obstack_for_string, '['); } - "@}" { obstack_1grow (&obstack_for_string, ']'); } - "@`" /* Empty. Useful for starting an argument - that begins with whitespace. */ - @\n /* Empty. */ + "@@" obstack_1grow (&obstack_for_string, '@'); + "@{" obstack_1grow (&obstack_for_string, '['); + "@}" obstack_1grow (&obstack_for_string, ']'); + "@`" continue; /* For starting an argument that begins with whitespace. */ + @\n continue; @[,)] { 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); } -{ - [ \t\r\n] - . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } + +{ + [ \t\r\n] continue; + . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } } -{ + +{ <> { fatal (_("unclosed %s directive in skeleton"), at_directive_argv[0]); } -- 2.47.2