Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add rationale for evaluatin...



details:   https://anonhg.NetBSD.org/src/rev/7bf87192d51d
branches:  trunk
changeset: 938564:7bf87192d51d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 11 05:29:46 2020 +0000

description:
make(1): add rationale for evaluating expression after parse error

diffstat:

 usr.bin/make/unit-tests/cond-op.exp |   6 +++---
 usr.bin/make/unit-tests/cond-op.mk  |  15 +++++++++++++--
 2 files changed, 16 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r 73b4595364fa -r 7bf87192d51d usr.bin/make/unit-tests/cond-op.exp
--- a/usr.bin/make/unit-tests/cond-op.exp       Fri Sep 11 05:24:14 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.exp       Fri Sep 11 05:29:46 2020 +0000
@@ -1,7 +1,7 @@
 make: "cond-op.mk" line 45: Malformed conditional ("!word" == !word)
-make: "cond-op.mk" line 59: Malformed conditional (0 ${ERR::=evaluated})
-make: "cond-op.mk" line 63: warning: After detecting a parse error, the rest is evaluated.
-make: "cond-op.mk" line 67: Parsing continues until here.
+make: "cond-op.mk" line 70: Malformed conditional (0 ${ERR::=evaluated})
+make: "cond-op.mk" line 74: warning: After detecting a parse error, the rest is evaluated.
+make: "cond-op.mk" line 78: Parsing continues until here.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 73b4595364fa -r 7bf87192d51d usr.bin/make/unit-tests/cond-op.mk
--- a/usr.bin/make/unit-tests/cond-op.mk        Fri Sep 11 05:24:14 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-op.mk        Fri Sep 11 05:29:46 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.6 2020/09/11 05:12:08 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.7 2020/09/11 05:29:46 rillig Exp $
 #
 # Tests for operators like &&, ||, ! in .if conditions.
 #
@@ -55,7 +55,18 @@
 
 # As soon as the parser sees the '$', it knows that the condition will
 # be malformed.  Therefore there is no point in evaluating it.
-# As of 2020-09-11, that part of the condition is evaluated nevertheless.
+#
+# As of 2020-09-11, that part of the condition is evaluated nevertheless,
+# since CondParser_Expr just requests the next token, without restricting
+# the token to the expected tokens.  If the parser were to restrict the
+# valid follow tokens for the token "0" to those that can actually produce
+# a correct condition (which in this case would be comparison operators,
+# TOK_AND, TOK_OR or TOK_RPAREN), the variable expression would not have
+# to be evaluated.
+#
+# This would add a good deal of complexity to the code though, for almost
+# no benefit, especially since most expressions and conditions are side
+# effect free.
 .if 0 ${ERR::=evaluated}
 .  error
 .endif



Home | Main Index | Thread Index | Old Index