Use lex_error_expecting() in more places.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 6 Nov 2022 19:41:06 +0000 (11:41 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 6 Nov 2022 19:46:01 +0000 (11:46 -0800)
src/language/control/do-if.c
src/language/control/loop.c
src/language/data-io/combine-files.c
tests/language/control/do-if.at
tests/language/control/loop.at

index 69288e5c1497111d611558c9e9329c1074d49741..24a1e4f10661435ca691c9573184e9894013386f 100644 (file)
@@ -120,7 +120,7 @@ cmd_do_if (struct lexer *lexer, struct dataset *ds)
     {
       if (lex_token (lexer) == T_STOP)
         {
-          lex_error (lexer, NULL);
+          lex_error_expecting (lexer, "END IF");
           break;
         }
       else if (lex_match_phrase (lexer, "ELSE IF"))
index 0db3a491d391dc152aaeebc2f997e22198602b65..ed6d38dd6e2496e74caf4b7a5f3d224a89b3a958 100644 (file)
@@ -97,7 +97,7 @@ cmd_loop (struct lexer *lexer, struct dataset *ds)
     {
       if (lex_token (lexer) == T_STOP)
         {
-          lex_error (lexer, NULL);
+          lex_error_expecting (lexer, "END LOOP");
           ok = false;
           break;
         }
index dde261a68f5727d5d1b6c9ac95e6c0d64614e37d..3306ffec682842d94924230f2d341166edea4fcd 100644 (file)
@@ -357,7 +357,11 @@ combine_files (enum comb_command_type command,
         }
       else
        {
-         lex_error (lexer, NULL);
+          if (command == COMB_UPDATE)
+            lex_error_expecting (lexer, "BY", "MAP", "DROP", "KEEP");
+          else
+            lex_error_expecting (lexer, "BY", "FIRST", "LAST",
+                                 "MAP", "DROP", "KEEP");
          goto error;
        }
 
index b12cdaa4fdf3f0d3072011a91ba55f1f7e76fa80..6281a0fd680b1c60f5148bf9f4e831a7cc83b4ea 100644 (file)
@@ -132,6 +132,6 @@ AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
    20 | DO IF !.
       |       ^"
 
-error: DO IF: At end of input: Syntax error.
+error: DO IF: At end of input: Syntax error expecting END IF.
 ])
 AT_CLEANUP
index 8f4d2b422568f8ac9312bc6f0c897fbaee4ce6a0..23ab6b5b1873cd556f25c7661b70696ae9a6a195 100644 (file)
@@ -369,6 +369,6 @@ loop.sps:36.10: error: LOOP: Syntax error expecting end of command.
    36 | END LOOP !.
       |          ^
 
-error: LOOP: At end of input: Syntax error.
+error: LOOP: At end of input: Syntax error expecting END LOOP.
 ])
 AT_CLEANUP
\ No newline at end of file