DEF_CMD (S_ANY, 0, "N OF CASES", cmd_n_of_cases)
DEF_CMD (S_ANY, F_ABBREV, "N", cmd_n_of_cases)
DEF_CMD (S_ANY, 0, "NEW FILE", cmd_new_file)
-DEF_CMD (S_ANY, 0, "OUTPUT", cmd_output)
+DEF_CMD (S_ANY, 0, "OUTPUT MODIFY", cmd_output_modify)
DEF_CMD (S_ANY, 0, "PERMISSIONS", cmd_permissions)
DEF_CMD (S_ANY, 0, "PRESERVE", cmd_preserve)
DEF_CMD (S_ANY, F_ABBREV, "Q", cmd_finish)
#define _(msgid) gettext (msgid)
int
-cmd_output (struct lexer *lexer, struct dataset *ds UNUSED)
+cmd_output_modify (struct lexer *lexer, struct dataset *ds UNUSED)
{
struct string_set rc_names = STRING_SET_INITIALIZER (rc_names);
- if (!lex_force_match_id (lexer, "MODIFY"))
- {
- lex_error (lexer, NULL);
- goto error;
- }
-
while (lex_token (lexer) != T_ENDCMD)
{
lex_match (lexer, T_SLASH);
if (lex_match_id (lexer, "SELECT"))
{
- if (!lex_match_id (lexer, "TABLES"))
- {
- lex_error (lexer, NULL);
- goto error;
- }
+ if (!lex_force_match_id (lexer, "TABLES"))
+ goto error;
}
else if (lex_match_id (lexer, "TABLECELLS"))
{
{
if (lex_match_id (lexer, "SELECT"))
{
- if (! lex_force_match (lexer, T_EQUALS))
+ if (!lex_force_match (lexer, T_EQUALS))
goto error;
- if (! lex_force_match (lexer, T_LBRACK))
+ if (!lex_force_match (lexer, T_LBRACK))
goto error;
while (lex_token (lexer) == T_ID)
lex_get (lexer);
}
- if (! lex_force_match (lexer, T_RBRACK))
+ if (!lex_force_match (lexer, T_RBRACK))
goto error;
}
else if (lex_match_id (lexer, "FORMAT"))
uint16_t width;
uint8_t decimals;
- if (! lex_force_match (lexer, T_EQUALS))
- goto error;
- if (! parse_abstract_format_specifier (lexer, type, &width, &decimals))
- {
- lex_error (lexer, NULL);
- goto error;
- }
+ if (!lex_force_match (lexer, T_EQUALS)
+ || !parse_abstract_format_specifier (lexer, type,
+ &width, &decimals))
+ goto error;
if (width <= 0)
{
}
else
{
- lex_error (lexer, NULL);
+ lex_error_expecting (lexer, "SELECT", "FORMAT");
goto error;
}
}
}
else
{
- lex_error (lexer, NULL);
+ lex_error_expecting (lexer, "SELECT", "TABLECELLS");
goto error;
}
}
error:
string_set_destroy (&rc_names);
- return CMD_SUCCESS;
+ return CMD_FAILURE;
}
tests/language/utilities/date.at \
tests/language/utilities/host.at \
tests/language/utilities/insert.at \
+ tests/language/utilities/output.at \
tests/language/utilities/permissions.at \
tests/language/utilities/set.at \
tests/language/utilities/show.at \
--- /dev/null
+AT_BANNER([OUTPUT MODIFY])
+
+AT_SETUP([OUTPUT MODIFY syntax errors])
+AT_DATA([output.sps], [dnl
+OUTPUT MODIFY/SELECT **.
+OUTPUT MODIFY/TABLECELLS SELECT **.
+OUTPUT MODIFY/TABLECELLS SELECT=**.
+OUTPUT MODIFY/TABLECELLS SELECT=[[**]].
+OUTPUT MODIFY/TABLECELLS FORMAT **.
+OUTPUT MODIFY/TABLECELLS FORMAT=ASDF5.
+OUTPUT MODIFY/TABLECELLS **.
+OUTPUT MODIFY/TABLECELLS SELECT="xyzzy" FORMAT=F8.2.
+])
+AT_CHECK([pspp -O format=csv output.sps], [1], [dnl
+"output.sps:1.22-1.23: error: OUTPUT MODIFY: Syntax error expecting TABLES.
+ 1 | OUTPUT MODIFY/SELECT **.
+ | ^~"
+
+"output.sps:2.33-2.34: error: OUTPUT MODIFY: Syntax error expecting `='.
+ 2 | OUTPUT MODIFY/TABLECELLS SELECT **.
+ | ^~"
+
+"output.sps:3.33-3.34: error: OUTPUT MODIFY: Syntax error expecting `[['.
+ 3 | OUTPUT MODIFY/TABLECELLS SELECT=**.
+ | ^~"
+
+"output.sps:4.34-4.35: error: OUTPUT MODIFY: Syntax error expecting `]]'.
+ 4 | OUTPUT MODIFY/TABLECELLS SELECT=[[**]].
+ | ^~"
+
+"output.sps:5.33-5.34: error: OUTPUT MODIFY: Syntax error expecting `='.
+ 5 | OUTPUT MODIFY/TABLECELLS FORMAT **.
+ | ^~"
+
+"output.sps:6.38: error: OUTPUT MODIFY: Unknown format type `ASDF'.
+ 6 | OUTPUT MODIFY/TABLECELLS FORMAT=ASDF5.
+ | ^"
+
+"output.sps:7.26-7.27: error: OUTPUT MODIFY: Syntax error expecting SELECT or FORMAT.
+ 7 | OUTPUT MODIFY/TABLECELLS **.
+ | ^~"
+
+"output.sps:8.33-8.39: error: OUTPUT MODIFY: Syntax error expecting `@<:@'.
+ 8 | OUTPUT MODIFY/TABLECELLS SELECT=""xyzzy"" FORMAT=F8.2.
+ | ^~~~~~~"
+])
+AT_CLEANUP
\ No newline at end of file