From: Richard W.M. Jones Date: Sat, 11 Jan 2020 20:28:44 +0000 (+0000) Subject: parser: Fix longstanding bug where "()" was required after CLI targets. X-Git-Tag: v'0.2'~41 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=e23952e03c37201fe805ad3d1635e7d2d41e5908;p=goals.git parser: Fix longstanding bug where "()" was required after CLI targets. --- diff --git a/Makefile.in b/Makefile.in index 29825e7..e05b14f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,9 +18,8 @@ # Pass through normal targets to Goalfile.in -# XXX Why can't this parse "all" instead of "all ()"? all clean depend install check maintainer-clean: src/goals - ./run src/goals "$@ ()" + ./run src/goals $@ # If src/goals doesn't exist then brute-force build it. Once we have # src/goals we can rebuild it and other parts of the project using diff --git a/TODO b/TODO index 3f32571..51bd05a 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,6 @@ Default parameters, ie: You might only allow defaults to be added to the end, or you might allow goals to be called with labelled parameters. -Fix: You must use 'all ()' on the command line. - Deleting target files if goals is interrupted, but only if the timestamp changes (what about non-*files?). Also: atomic code. This will delete the target if the code doesn't run to completion. (make diff --git a/src/parse.ml b/src/parse.ml index 34ed38b..da42b87 100644 --- a/src/parse.ml +++ b/src/parse.ml @@ -38,7 +38,7 @@ let parse_file env lexbuf = failwithf "%a: parse error" string_position lexbuf let parse_expr lexbuf = - try Parser.expr Lexer.read lexbuf + try Parser.expr_only Lexer.read lexbuf with | SyntaxError msg -> failwithf "%a: %s" string_position lexbuf msg diff --git a/src/parser.mly b/src/parser.mly index 9d6988b..57a0c5c 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -87,7 +87,7 @@ let do_include env loc filename optflag file = (* Start nonterminals. *) %start file -%start expr +%start expr_only %% file: @@ -176,6 +176,13 @@ params: | LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 } ; +(* This is used by Parse.parse_expr where we have to parse + * a standalone string (eg. from the command line). + *) +expr_only: + | expr EOF { $1 } + ; + (* http://gallium.inria.fr/blog/lr-lists/ *) right_flexible_list(delim, X): | (* nothing *) { [] }