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: use a single i...



details:   https://anonhg.NetBSD.org/src/rev/012ea0b62e6f
branches:  trunk
changeset: 951898:012ea0b62e6f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 07 12:48:34 2021 +0000

description:
tests/libcurses: use a single indentation style in the test grammar

The grammar rule 'args' has been left as-is since it needs to be split
into 'args' and 'arg' first, to avoid the redundancy.

The braces in "if (create_check_file)" were misleading.  It's strange that
GCC didn't reject this.

diffstat:

 tests/lib/libcurses/director/testlang_parse.y |  257 +++++++++++++------------
 1 files changed, 136 insertions(+), 121 deletions(-)

diffs (truncated from 405 to 300 lines):

diff -r 365f8b1ef6a8 -r 012ea0b62e6f tests/lib/libcurses/director/testlang_parse.y
--- a/tests/lib/libcurses/director/testlang_parse.y     Sun Feb 07 12:24:18 2021 +0000
+++ b/tests/lib/libcurses/director/testlang_parse.y     Sun Feb 07 12:48:34 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_parse.y,v 1.22 2021/02/07 12:24:18 rillig Exp $       */
+/*     $NetBSD: testlang_parse.y,v 1.23 2021/02/07 12:48:34 rillig Exp $       */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -216,60 +216,72 @@
                | /* empty */
                ;
 
-assign         : ASSIGN VARNAME numeric {set_var(data_number, $2, $3);}
-               | ASSIGN VARNAME LHB expr RHB {set_var(data_number, $2, $<string>4);}
-               | ASSIGN VARNAME STRING {set_var(data_string, $2, $3);}
-               | ASSIGN VARNAME BYTE {set_var(data_byte, $2, $3);}
+assign         : ASSIGN VARNAME numeric {
+                       set_var(data_number, $2, $3);
+               }
+               | ASSIGN VARNAME LHB expr RHB {
+                       set_var(data_number, $2, $<string>4);
+               }
+               | ASSIGN VARNAME STRING {
+                       set_var(data_string, $2, $3);
+               }
+               | ASSIGN VARNAME BYTE {
+                       set_var(data_byte, $2, $3);
+               }
                ;
 
-cchar          : CCHAR VARNAME attributes char_vals
-                       {
-                               set_cchar($2, $<string>3);
-                       }
+cchar          : CCHAR VARNAME attributes char_vals {
+                       set_cchar($2, $<string>3);
+               }
                ;
 
-wchar          : WCHAR VARNAME char_vals
-                       {
-                               set_wchar($2);
-                       }
+wchar          : WCHAR VARNAME char_vals {
+                       set_wchar($2);
+               }
                ;
 
 attributes     : numeric
-               | LHB expr RHB
-                       { $<string>$ = $<string>2; }
-               | VARIABLE
-                       { $<string>$ = get_numeric_var($1); }
+               | LHB expr RHB {
+                       $<string>$ = $<string>2;
+               }
+               | VARIABLE {
+                       $<string>$ = get_numeric_var($1);
+               }
                ;
 
-char_vals      : numeric
-                       { add_to_vals(data_number, $1); }
+char_vals      : numeric {
+                       add_to_vals(data_number, $1);
+               }
                | LHSB array RHSB
-               | VARIABLE
-                       { add_to_vals(data_var, $1); }
-               | STRING
-                       { add_to_vals(data_string, $1); }
-               | BYTE
-                       { add_to_vals(data_byte, $1); }
+               | VARIABLE {
+                       add_to_vals(data_var, $1);
+               }
+               | STRING {
+                       add_to_vals(data_string, $1);
+               }
+               | BYTE {
+                       add_to_vals(data_byte, $1);
+               }
                ;
 
 call           : CALL result fn_name args {
-       do_function_call(1);
-}
+                       do_function_call(1);
+               }
                ;
 
 call2          : CALL2 result result fn_name args {
-       do_function_call(2);
-}
+                       do_function_call(2);
+               }
                ;
 
 call3          : CALL3 result result result fn_name args {
-       do_function_call(3);
-}
+                       do_function_call(3);
+               }
                ;
 
 call4          : CALL4 result result result result fn_name args {
-       do_function_call(4);
- }
+                       do_function_call(4);
+               }
                ;
 
 check          : CHECK var returns {
@@ -280,7 +292,7 @@
                err(1, "Undefined variable in check statement, line %zu"
                    " of file %s", line, cur_file);
 
-       if (command.returns[1].data_type == data_var){
+       if (command.returns[1].data_type == data_var) {
                vptr = &vars[command.returns[1].data_index];
                command.returns[1].data_type = vptr->type;
                command.returns[1].data_len = vptr->len;
@@ -363,7 +375,7 @@
        }
 
        init_parse_variables(0);
- }
+}
        ;
 
 delay          : DELAY numeric {
@@ -417,22 +429,21 @@
        }
 
        no_input = true;
- }
+}
 
 compare                : COMPARE PATH
-               | COMPARE FILENAME
-{
-       compare_streams($2, true);
-}
-       ;
-
+                       /* FIXME: missing action */
+               | COMPARE FILENAME {
+                       compare_streams($2, true);
+               }
+               ;
 
 comparend      : COMPAREND PATH
-               | COMPAREND FILENAME
-{
-       compare_streams($2, false);
-}
-       ;
+                       /* FIXME: missing action */
+               | COMPAREND FILENAME {
+                       compare_streams($2, false);
+               }
+               ;
 
 
 result         : returns
@@ -451,87 +462,89 @@
                ;
 
 var            : VARNAME {
-       assign_rets(data_var, $1);
- }
+                       assign_rets(data_var, $1);
+               }
                ;
 
 reference      : VARIABLE {
-       assign_rets(data_ref, $1);
- }
+                       assign_rets(data_ref, $1);
+               }
+               /* XXX: missing semicolon; how does yacc interpret this? */
 
 fn_name                : VARNAME {
-       if (command.function != NULL)
-               free(command.function);
+                       if (command.function != NULL)
+                               free(command.function);
 
-       command.function = malloc(strlen($1) + 1);
-       if (command.function == NULL)
-               err(1, "Could not allocate memory for function name");
-       strcpy(command.function, $1);
- }
+                       command.function = malloc(strlen($1) + 1);
+                       if (command.function == NULL)
+                               err(1, "Could not allocate memory for function name");
+                       strcpy(command.function, $1);
+               }
                ;
 
-array          : numeric { $<vals>$ = add_to_vals(data_number, $1); };
-               | VARIABLE
-                       { $<vals>$ = add_to_vals(data_number,
-                               get_numeric_var($1)); }
-               | BYTE
-                       {
+array          : numeric {
+                       $<vals>$ = add_to_vals(data_number, $1);
+               }
+               ; /* XXX: extra semicolon; yacc seems to ignore this. */
+               | VARIABLE {
+                       $<vals>$ = add_to_vals(data_number,
+                           get_numeric_var($1));
+               }
+               | BYTE {
+                       $<vals>$ = add_to_vals(data_byte, (void *) $1);
+               }
+               | STRING {
+                       $<vals>$ = add_to_vals(data_string, (void *) $1);
+               }
+               | numeric MULTIPLIER numeric {
+                       unsigned long i;
+                       unsigned long acount;
+
+                       acount = strtoul($3, NULL, 10);
+                       for (i = 0; i < acount; i++) {
+                               $<vals>$ = add_to_vals(data_number, $1);
+                       }
+               }
+               | VARIABLE MULTIPLIER numeric {
+                       unsigned long i, acount;
+                       char *val;
+
+                       acount = strtoul($3, NULL, 10);
+                       val = get_numeric_var($1);
+                       for (i = 0; i < acount; i++) {
+                               $<vals>$ = add_to_vals(data_number, val);
+                       }
+               }
+               | BYTE MULTIPLIER numeric {
+                       unsigned long i, acount;
+
+                       acount = strtoul($3, NULL, 10);
+                       for (i = 0; i < acount; i++) {
                                $<vals>$ = add_to_vals(data_byte, (void *) $1);
                        }
-               | STRING
-                       {
-                               $<vals>$ = add_to_vals(data_string, (void *) $1);
-                       }
-               | numeric MULTIPLIER numeric
-                       {
-                               unsigned long i;
-                               unsigned long acount;
-
-                               acount = strtoul($3, NULL, 10);
-                               for (i = 0; i < acount; i++) {
-                                       $<vals>$ = add_to_vals(data_number, $1);
-                               }
-                       }
-               | VARIABLE MULTIPLIER numeric
-                       {
-                               unsigned long i, acount;
-                               char *val;
+               }
+               | STRING MULTIPLIER numeric {
+                       unsigned long i, acount;
 
-                               acount = strtoul($3, NULL, 10);
-                               val = get_numeric_var($1);
-                               for (i = 0; i < acount; i++) {
-                                       $<vals>$ = add_to_vals(data_number, val);
-                               }
+                       acount = strtoul($3, NULL, 10);
+                       for (i = 0; i < acount; i++) {
+                               $<vals>$ = add_to_vals(data_string,
+                                   (void *) $1);
                        }
-               | BYTE MULTIPLIER numeric
-                       {
-                               unsigned long i, acount;
-
-                               acount = strtoul($3, NULL, 10);
-                               for (i = 0; i < acount; i++) {
-                                       $<vals>$ = add_to_vals(data_byte, (void *) $1); 
-                               }
-                       }
-               | STRING MULTIPLIER numeric
-                       {
-                               unsigned long i, acount;
-
-                               acount = strtoul($3, NULL, 10);
-                               for (i = 0; i < acount; i++) {
-                                       $<vals>$ = add_to_vals(data_string,
-                                           (void *) $1); 
-                               }
-                       }
+               }



Home | Main Index | Thread Index | Old Index