Module Name:    src
Committed By:   rillig
Date:           Sat Aug  6 07:06:58 UTC 2022

Modified Files:
        src/usr.bin/make/unit-tests: varmod.exp varmod.mk

Log Message:
tests/make: document parsing behavior of modifiers

The table was created by manually inspecting the code of the various
ApplyModifier functions in var.c.

The modifiers are listed in alphabetical order, except for the SysV
modifier, which is listed at the end since it is used as a fallback
modifier for many other modifiers and because it does not have a fixed
prefix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod.exp
diff -u src/usr.bin/make/unit-tests/varmod.exp:1.4 src/usr.bin/make/unit-tests/varmod.exp:1.5
--- src/usr.bin/make/unit-tests/varmod.exp:1.4	Sat Dec 19 22:33:11 2020
+++ src/usr.bin/make/unit-tests/varmod.exp	Sat Aug  6 07:06:58 2022
@@ -1,8 +1,8 @@
-make: "varmod.mk" line 42: To escape a dollar, use \$, not $$, at "$$:L} != """
-make: "varmod.mk" line 42: Invalid variable name ':', at "$:L} != """
-make: "varmod.mk" line 47: Dollar followed by nothing
-make: "varmod.mk" line 56: Missing delimiter ':' after modifier "P"
-make: "varmod.mk" line 57: Missing argument for ".error"
+make: "varmod.mk" line 93: To escape a dollar, use \$, not $$, at "$$:L} != """
+make: "varmod.mk" line 93: Invalid variable name ':', at "$:L} != """
+make: "varmod.mk" line 98: Dollar followed by nothing
+make: "varmod.mk" line 107: Missing delimiter ':' after modifier "P"
+make: "varmod.mk" line 108: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod.mk
diff -u src/usr.bin/make/unit-tests/varmod.mk:1.5 src/usr.bin/make/unit-tests/varmod.mk:1.6
--- src/usr.bin/make/unit-tests/varmod.mk:1.5	Sat Dec 19 22:33:11 2020
+++ src/usr.bin/make/unit-tests/varmod.mk	Sat Aug  6 07:06:58 2022
@@ -1,7 +1,58 @@
-# $NetBSD: varmod.mk,v 1.5 2020/12/19 22:33:11 rillig Exp $
+# $NetBSD: varmod.mk,v 1.6 2022/08/06 07:06:58 rillig Exp $
 #
 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
 
+# As of 2022-08-06, the possible behaviors during parsing are:
+#
+# * `strict`: the parsing style used by most modifiers:
+#   * either uses `ParseModifierPart` or parses the modifier literal
+#   * other modifiers may follow, separated by a ':'
+#
+# * `greedy`: calls `ParseModifierPart` with `ch->endc`; this means
+#   that no further modifiers are parsed in that expression.
+#
+# * `no-colon`: after parsing this modifier, the following modifier
+#   does not need to be separated by a colon.
+#   Omitting this colon is bad style.
+#
+# * `individual`: parsing this modifier does not follow the common
+#   pattern of calling `ParseModifierPart`.
+#
+# The SysV column says whether a parse error in the modifier falls back
+# trying the `:from=to` System V modifier.
+#
+# | **Operator** | **Behavior** | **Remarks**        | **SysV** |
+# |--------------|--------------|--------------------|----------|
+# | `!`          | no-colon     |                    | no       |
+# | `:=`         | greedy       |                    | yes      |
+# | `?:`         | greedy       |                    | no       |
+# | `@`          | no-colon     |                    | no       |
+# | `C`          | no-colon     |                    | no       |
+# | `D`          | individual   | custom parser      | N/A      |
+# | `E`          | strict       |                    | yes      |
+# | `H`          | strict       |                    | yes      |
+# | `L`          | no-colon     |                    | N/A      |
+# | `M`          | individual   | custom parser      | N/A      |
+# | `N`          | individual   | custom parser      | N/A      |
+# | `O`          | strict       | only literal value | no       |
+# | `P`          | no-colon     |                    | N/A      |
+# | `Q`          | strict       |                    | yes      |
+# | `R`          | strict       |                    | yes      |
+# | `S`          | no-colon     |                    | N/A      |
+# | `T`          | strict       |                    | N/A      |
+# | `U`          | individual   | custom parser      | N/A      |
+# | `[`          | strict       |                    | no       |
+# | `_`          | individual   | strcspn            | yes      |
+# | `gmtime`     | strict       | only literal value | yes      |
+# | `hash`       | strict       |                    | N/A      |
+# | `localtime`  | strict       | only literal value | yes      |
+# | `q`          | strict       |                    | yes      |
+# | `range`      | strict       |                    | N/A      |
+# | `sh`         | strict       |                    | N/A      |
+# | `t`          | strict       |                    | no       |
+# | `u`          | strict       |                    | yes      |
+# | `from=to`    | greedy       | SysV, fallback     | N/A      |
+
 DOLLAR1=	$$
 DOLLAR2=	${:U\$}
 

Reply via email to