1 1.2 rillig # $NetBSD: varparse-mod.mk,v 1.2 2023/11/19 21:47:52 rillig Exp $ 2 1.1 rillig 3 1.2 rillig # Tests for parsing expressions with modifiers. 4 1.1 rillig 5 1.1 rillig # As of 2020-10-02, the below condition does not result in a parse error. 6 1.1 rillig # The condition contains two separate mistakes. The first mistake is that 7 1.1 rillig # the :!cmd! modifier is missing the closing '!'. The second mistake is that 8 1.1 rillig # there is a stray '}' at the end of the whole condition. 9 1.1 rillig # 10 1.1 rillig # As of 2020-10-02, the actual parse result of this condition is a single 11 1.2 rillig # expression with 2 modifiers. The first modifier is 12 1.1 rillig # ":!echo "\$VAR"} !". Afterwards, the parser optionally skips a ':' (at the 13 1.1 rillig # bottom of ApplyModifiers) and continues with the next modifier, in this case 14 1.1 rillig # "= "value"", which is interpreted as a SysV substitution modifier with an 15 1.1 rillig # empty left-hand side, thereby appending the string " "value"" to each word 16 1.1 rillig # of the expression. 17 1.1 rillig # 18 1.1 rillig # As of 2020-10-02, some modifiers ensure that they are followed by either a 19 1.1 rillig # ':' or the closing brace or parenthesis of the expression. The modifiers 20 1.1 rillig # that don't ensure this are (in order of appearance in ApplyModifier): 21 1.1 rillig # :@var@replacement@ 22 1.1 rillig # :_ 23 1.1 rillig # :L 24 1.1 rillig # :P 25 1.1 rillig # :!cmd! 26 1.1 rillig # :gmtime=... 27 1.1 rillig # :localtime=... 28 1.1 rillig # :M (because '}' and ')' are treated the same) 29 1.1 rillig # :N (because '}' and ')' are treated the same) 30 1.1 rillig # :S 31 1.1 rillig # :C 32 1.1 rillig # :range=... 33 1.1 rillig # On the other hand, these modifiers ensure that they are followed by a 34 1.1 rillig # delimiter: 35 1.1 rillig # :D 36 1.1 rillig # :U 37 1.1 rillig # :[...] 38 1.1 rillig # :gmtime (if not followed by '=') 39 1.1 rillig # :hash (if not followed by '=') 40 1.1 rillig # :localtime (if not followed by '=') 41 1.1 rillig # :t 42 1.1 rillig # :q 43 1.1 rillig # :Q 44 1.1 rillig # :T 45 1.1 rillig # :H 46 1.1 rillig # :E 47 1.1 rillig # :R 48 1.1 rillig # :range (if not followed by '=') 49 1.1 rillig # :O 50 1.1 rillig # :u 51 1.1 rillig # :sh 52 1.1 rillig # These modifiers don't care since they reach until the closing character 53 1.1 rillig # of the expression, which is either ')' or '}': 54 1.1 rillig # ::= (as well as the other assignment modifiers) 55 1.1 rillig # :? 56 1.1 rillig # 57 1.1 rillig .if ${:!echo "\$VAR"} != "value"} 58 1.1 rillig .endif 59 1.1 rillig 60 1.1 rillig all: 61 1.1 rillig @: 62