From: Ben Pfaff Date: Sat, 5 Nov 2011 20:07:44 +0000 (-0700) Subject: lexer: Drop lexer parameter from lex_sbc_missing(). X-Git-Tag: v0.7.9~107 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7e9711f020ba507719f1f21cac04ae1199a4ac0;p=pspp-builds.git lexer: Drop lexer parameter from lex_sbc_missing(). There's no point in passing in the lexer and using lex_error(), because the extra information that lex_error() outputs does not help the user find the error. --- diff --git a/src/language/control/loop.c b/src/language/control/loop.c index e4877b9e..cece7f68 100644 --- a/src/language/control/loop.c +++ b/src/language/control/loop.c @@ -261,7 +261,7 @@ parse_index_clause (struct dataset *ds, struct lexer *lexer, } if (loop->last_expr == NULL) { - lex_sbc_missing (lexer, "TO"); + lex_sbc_missing ("TO"); return false; } if (loop->by_expr == NULL) diff --git a/src/language/data-io/combine-files.c b/src/language/data-io/combine-files.c index e09b36ec..f306cad6 100644 --- a/src/language/data-io/combine-files.c +++ b/src/language/data-io/combine-files.c @@ -376,7 +376,7 @@ combine_files (enum comb_command_type command, { if (command == COMB_UPDATE) { - msg (SE, _("The BY subcommand is required.")); + lex_sbc_missing ("BY"); goto error; } if (n_tables) diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 9bf6a6bf..80fdacab 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -86,7 +86,7 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) properties = *fh_default_properties (); if (cmd.s_name == NULL) { - lex_sbc_missing (lexer, "NAME"); + lex_sbc_missing ("NAME"); goto exit_free_cmd; } diff --git a/src/language/data-io/get.c b/src/language/data-io/get.c index ea65b5c1..028cc3c6 100644 --- a/src/language/data-io/get.c +++ b/src/language/data-io/get.c @@ -106,7 +106,7 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command if (fh == NULL) { - lex_sbc_missing (lexer, "FILE"); + lex_sbc_missing ("FILE"); goto error; } diff --git a/src/language/data-io/save-translate.c b/src/language/data-io/save-translate.c index cbed4b10..bc68e553 100644 --- a/src/language/data-io/save-translate.c +++ b/src/language/data-io/save-translate.c @@ -237,12 +237,12 @@ cmd_save_translate (struct lexer *lexer, struct dataset *ds) if (type == 0) { - lex_sbc_missing (lexer, "TYPE"); + lex_sbc_missing ("TYPE"); goto error; } else if (handle == NULL) { - lex_sbc_missing (lexer, "OUTFILE"); + lex_sbc_missing ("OUTFILE"); goto error; } else if (!replace && fn_exists (fh_get_file_name (handle))) diff --git a/src/language/data-io/save.c b/src/language/data-io/save.c index 66cdd452..b930855e 100644 --- a/src/language/data-io/save.c +++ b/src/language/data-io/save.c @@ -279,7 +279,7 @@ parse_write_command (struct lexer *lexer, struct dataset *ds, if (handle == NULL) { - lex_sbc_missing (lexer, "OUTFILE"); + lex_sbc_missing ("OUTFILE"); goto error; } diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index a356b382..e3725681 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -337,20 +337,29 @@ lex_error_expecting (struct lexer *lexer, const char *option0, ...) } } -/* Reports an error to the effect that subcommand SBC may only be - specified once. */ +/* Reports an error to the effect that subcommand SBC may only be specified + once. + + This function does not take a lexer as an argument or use lex_error(), + because the result would ordinarily just be redundant: "Syntax error at + SUBCOMMAND: Subcommand SUBCOMMAND may only be specified once.", which does + not help the user find the error. */ void lex_sbc_only_once (const char *sbc) { msg (SE, _("Subcommand %s may only be specified once."), sbc); } -/* Reports an error to the effect that subcommand SBC is - missing. */ +/* Reports an error to the effect that subcommand SBC is missing. + + This function does not take a lexer as an argument or use lex_error(), + because a missing subcommand can normally be detected only after the whole + command has been parsed, and so lex_error() would always report "Syntax + error at end of command", which does not help the user find the error. */ void -lex_sbc_missing (struct lexer *lexer, const char *sbc) +lex_sbc_missing (const char *sbc) { - lex_error (lexer, _("missing required subcommand %s"), sbc); + msg (SE, _("Required subcommand %s was not specified."), sbc); } /* Prints a syntax error message containing the current token and diff --git a/src/language/lexer/lexer.h b/src/language/lexer/lexer.h index b0787e8f..2a7055a5 100644 --- a/src/language/lexer/lexer.h +++ b/src/language/lexer/lexer.h @@ -158,7 +158,7 @@ int lex_end_of_command (struct lexer *); void lex_error_expecting (struct lexer *, const char *, ...) SENTINEL(0); void lex_sbc_only_once (const char *); -void lex_sbc_missing (struct lexer *, const char *); +void lex_sbc_missing (const char *); void lex_error_valist (struct lexer *, const char *, va_list) PRINTF_FORMAT (2, 0);