parser: Fix longstanding bug where "()" was required after CLI targets.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 11 Jan 2020 20:28:44 +0000 (20:28 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 11 Jan 2020 20:28:44 +0000 (20:28 +0000)
Makefile.in
TODO
src/parse.ml
src/parser.mly

index 29825e7..e05b14f 100644 (file)
@@ -18,9 +18,8 @@
 
 # Pass through normal targets to Goalfile.in
 
 
 # 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
 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
 
 # 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 (file)
--- 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.
 
 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
 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
index 34ed38b..da42b87 100644 (file)
@@ -38,7 +38,7 @@ let parse_file env lexbuf =
      failwithf "%a: parse error" string_position lexbuf
 
 let parse_expr 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
   with
   | SyntaxError msg ->
      failwithf "%a: %s" string_position lexbuf msg
index 9d6988b..57a0c5c 100644 (file)
@@ -87,7 +87,7 @@ let do_include env loc filename optflag file =
 
 (* Start nonterminals. *)
 %start <Ast.expr Ast.Env.t> file
 
 (* Start nonterminals. *)
 %start <Ast.expr Ast.Env.t> file
-%start <Ast.expr> expr
+%start <Ast.expr> expr_only
 %%
 
 file:
 %%
 
 file:
@@ -176,6 +176,13 @@ params:
     | LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 }
     ;
 
     | 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 *) { [] }
 (* http://gallium.inria.fr/blog/lr-lists/ *)
 right_flexible_list(delim, X):
     | (* nothing *) { [] }