Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libcurses/director tests/libcurses: indent lexer c...



details:   https://anonhg.NetBSD.org/src/rev/f4f3dfa29337
branches:  trunk
changeset: 959289:f4f3dfa29337
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 07 11:52:43 2021 +0000

description:
tests/libcurses: indent lexer code consistently

Several of the braces were misaligned.  For the simple keywords, there
is no need to write these braces at all, they only made the code look
more complicated than it really is.

I stumbled upon this because syntax errors in the test cases currently
let the test case succeed instead of fail, which is another ingredient
for unreliable tests, besides the loose output matching.

diffstat:

 tests/lib/libcurses/director/testlang_conf.l |  135 ++++++--------------------
 1 files changed, 32 insertions(+), 103 deletions(-)

diffs (195 lines):

diff -r 264a35dc01a6 -r f4f3dfa29337 tests/lib/libcurses/director/testlang_conf.l
--- a/tests/lib/libcurses/director/testlang_conf.l      Sun Feb 07 11:25:56 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_conf.l      Sun Feb 07 11:52:43 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_conf.l,v 1.9 2020/10/24 04:46:17 blymn Exp $  */
+/*     $NetBSD: testlang_conf.l,v 1.10 2021/02/07 11:52:43 rillig Exp $        */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -172,8 +172,8 @@
 
 include                BEGIN(incl);
 
-<incl>[ \t]*      /* eat the whitespace */
-<incl>[^ \t\n]+   { /* got the include file name */
+<incl>[ \t]*   /* eat the whitespace */
+<incl>[^ \t\n]+ { /* got the include file name */
                char inc_file[MAXPATHLEN];
 
                if (include_ptr > MAX_INCLUDES) {
@@ -218,10 +218,8 @@
 <<EOF>>        {
                yypop_buffer_state();
 
-               if ( !YY_CURRENT_BUFFER )
-               {
+               if (!YY_CURRENT_BUFFER)
                        yyterminate();
-               }
 
                if (--include_ptr < 0)
                        err(2, "Include stack underflow");
@@ -231,97 +229,29 @@
                line = include_stack[include_ptr];
        }
 
-{ASSIGN}       {
-                       return ASSIGN;
-               }
-
-{CALL2}                {
-                       return CALL2;
-               }
-
-{CALL3}                {
-                       return CALL3;
-               }
-
-{CALL4}                {
-                       return CALL4;
-               }
-
-{CALL}         {
-                       return CALL;
-               }
-
-{CHECK}                {
-                       return CHECK;
-               }
-
-{DELAY}                {
-                       return DELAY;
-               }
-
-{INPUT}                {
-                       return INPUT;
-               }
-
-{NOINPUT}              {
-                       return NOINPUT;
-               }
-
-{COMPARE}      {
-                       return COMPARE;
-               }
-
-{COMPAREND}    {
-                       return COMPAREND;
-               }
-
-{NON_NULL}     {
-                       return NON_NULL;
-               }
-
-{NULL_RET}             {
-                       return NULL_RET;
-               }
-
-{OK_RET}               {
-                       return OK_RET;
-               }
-
-{ERR_RET}              {
-                       return ERR_RET;
-               }
-
-{MULTIPLIER}   {
-                       return MULTIPLIER;
-               }
-
-{CCHAR}                {
-                       return CCHAR;
-               }
-
-{WCHAR}                {
-                       return WCHAR;
-               }
-
-{OR}           {
-                       return OR;
-               }
-
-{LHB}          {
-                       return LHB;
-               }
-
-{RHB}          {
-                       return RHB;
-               }
-
-{LHSB}         {
-                       return LHSB;
-               }
-
-{RHSB}         {
-                       return RHSB;
-               }
+{ASSIGN}       return ASSIGN;
+{CALL2}                return CALL2;
+{CALL3}                return CALL3;
+{CALL4}                return CALL4;
+{CALL}         return CALL;
+{CHECK}                return CHECK;
+{DELAY}                return DELAY;
+{INPUT}                return INPUT;
+{NOINPUT}      return NOINPUT;
+{COMPARE}      return COMPARE;
+{COMPAREND}    return COMPAREND;
+{NON_NULL}     return NON_NULL;
+{NULL_RET}     return NULL_RET;
+{OK_RET}       return OK_RET;
+{ERR_RET}      return ERR_RET;
+{MULTIPLIER}   return MULTIPLIER;
+{CCHAR}                return CCHAR;
+{WCHAR}                return WCHAR;
+{OR}           return OR;
+{LHB}          return LHB;
+{RHB}          return RHB;
+{LHSB}         return LHSB;
+{RHSB}         return RHSB;
 
 {HEX}          {
                        /* Hex value, convert to decimal and return numeric */
@@ -334,12 +264,11 @@
                        return numeric;
                }
 
-
-{numeric}              {
+{numeric}      {
                        if ((yylval.string = strdup(yytext)) == NULL)
                                err(1, "Cannot allocate numeric string");
                        return numeric;
-}
+               }
 
 {VARNAME}      {
                        if ((yylval.string = strdup(yytext)) == NULL)
@@ -434,15 +363,14 @@
                                err(1, "Cannot allocate string for varname");
                        return VARIABLE;
                }
-       
+
        /* comments, white-outs */
 [ \t\r]                |
 #.*            ;
 ^#.*\n         |
 #.*\n          |
 \\\n           |
-^\n            { 
-line++; }
+^\n            line++;
 
        /* eol on a line with data. need to process, return eol */
 \n             {
@@ -451,6 +379,7 @@
                }
 
 .              {
+                       /* FIXME: report syntax error */
                }
 
 %%



Home | Main Index | Thread Index | Old Index