work on pivot-table-test
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 31 Dec 2020 00:49:41 +0000 (16:49 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 31 Dec 2020 03:58:11 +0000 (19:58 -0800)
tests/output/pivot-table-test.c

index 44347fb4f2009874d2ccbdd0bb1e384f2121d595..514ce7f8dca4143faae393f0d0a0410938ae80f8 100644 (file)
@@ -376,6 +376,54 @@ parse_bool_setting (struct lexer *lexer, const char *name,
     return false;
 }
 
+static bool
+parse_settings_value_show (struct lexer *lexer, const char *name,
+                           enum settings_value_show *show)
+{
+  if (lex_match_id (lexer, name))
+    {
+      if (!lex_force_match (lexer, T_EQUALS))
+        exit (1);
+
+      if (lex_match_id (lexer, "DEFAULT"))
+        *show = SETTINGS_VALUE_SHOW_DEFAULT;
+      else if (lex_match_id (lexer, "VALUE"))
+        *show = SETTINGS_VALUE_SHOW_VALUE;
+      else if (lex_match_id (lexer, "LABEL"))
+        *show = SETTINGS_VALUE_SHOW_LABEL;
+      else if (lex_match_id (lexer, "BOTH"))
+        *show = SETTINGS_VALUE_SHOW_BOTH;
+      else
+        {
+          lex_error_expecting (lexer, "DEFAULT", "VALUE", "LABEL", "BOTH");
+          exit (1);
+        }
+
+      return true;
+    }
+  else
+    return false;
+}
+
+static bool
+parse_string_setting (struct lexer *lexer, const char *name, char **stringp)
+{
+  if (lex_match_id (lexer, name))
+    {
+      lex_match (lexer, T_EQUALS);
+      if (!lex_force_string (lexer))
+        exit (1);
+
+      free (*stringp);
+      *stringp = xstrdup (lex_tokcstr (lexer));
+
+      lex_get (lexer);
+      return true;
+    }
+  else
+    return false;
+}
+
 static void
 read_look (struct lexer *lexer, struct pivot_table *pt)
 {
@@ -419,7 +467,9 @@ read_look (struct lexer *lexer, struct pivot_table *pt)
           && !parse_bool_setting (lexer, "TOPCONTINUATION", "YES", "NO",
                                   &look->top_continuation)
           && !parse_bool_setting (lexer, "BOTTOMCONTINUATION", "YES", "NO",
-                                  &look->bottom_continuation))
+                                  &look->bottom_continuation)
+          && !parse_string_setting (lexer, "CONTINUATION",
+                                    &look->continuation))
         break;
     }
   pivot_table_set_look (pt, look);
@@ -437,6 +487,23 @@ read_stroke (struct lexer *lexer)
   exit (1);
 }
 
+static bool
+parse_value_setting (struct lexer *lexer, const char *name,
+                     struct pivot_value **valuep)
+{
+  if (lex_match_id (lexer, name))
+    {
+      lex_match (lexer, T_EQUALS);
+
+      pivot_value_destroy (*valuep);
+      *valuep = read_value (lexer);
+
+      return true;
+    }
+  else
+    return false;
+}
+
 static void
 read_border (struct lexer *lexer, struct pivot_table *pt)
 {
@@ -537,13 +604,30 @@ read_table (struct lexer *lexer)
         {
           lex_match (lexer, T_EQUALS);
           while (lex_token (lexer) == T_ID)
-            if (!parse_bool_setting (lexer, "GRID", "YES", "NO",
-                                     &pt->show_grid_lines)
-                && !parse_bool_setting (lexer, "CAPTION", "YES", "NO",
-                                        &pt->show_caption)
-                && !parse_bool_setting (lexer, "TITLE", "YES", "NO",
-                                        &pt->show_caption))
+            {
+              if (parse_bool_setting (lexer, "GRID", "YES", "NO",
+                                      &pt->show_grid_lines)
+                  || parse_bool_setting (lexer, "CAPTION", "YES", "NO",
+                                         &pt->show_caption)
+                  || parse_bool_setting (lexer, "TITLE", "YES", "NO",
+                                         &pt->show_title))
+                continue;
+
+              if (parse_settings_value_show (lexer, "VALUES", &pt->show_values)
+                  || parse_settings_value_show (lexer, "VARIABLES",
+                                                &pt->show_variables))
+                continue;
+
               break;
+            }
+        }
+      else if (parse_value_setting (lexer, "TITLE", &pt->title)
+               || parse_value_setting (lexer, "SUBTYPE", &pt->subtype)
+               || parse_value_setting (lexer, "CORNER", &pt->corner_text)
+               || parse_value_setting (lexer, "CAPTION", &pt->caption)
+               || parse_string_setting (lexer, "NOTES", &pt->notes))
+        {
+          /* Nothing. */
         }
       else if (lex_match_id (lexer, "BORDER"))
         read_border (lexer, pt);