17a05a715SSimon J. Gerraty# $NetBSD: varparse-mod.mk,v 1.2 2023/11/19 21:47:52 rillig Exp $ 2302da1a3SSimon J. Gerraty 37a05a715SSimon J. Gerraty# Tests for parsing expressions with modifiers. 4302da1a3SSimon J. Gerraty 5302da1a3SSimon J. Gerraty# As of 2020-10-02, the below condition does not result in a parse error. 6302da1a3SSimon J. Gerraty# The condition contains two separate mistakes. The first mistake is that 7302da1a3SSimon J. Gerraty# the :!cmd! modifier is missing the closing '!'. The second mistake is that 8302da1a3SSimon J. Gerraty# there is a stray '}' at the end of the whole condition. 9302da1a3SSimon J. Gerraty# 10302da1a3SSimon J. Gerraty# As of 2020-10-02, the actual parse result of this condition is a single 117a05a715SSimon J. Gerraty# expression with 2 modifiers. The first modifier is 12302da1a3SSimon J. Gerraty# ":!echo "\$VAR"} !". Afterwards, the parser optionally skips a ':' (at the 13302da1a3SSimon J. Gerraty# bottom of ApplyModifiers) and continues with the next modifier, in this case 14302da1a3SSimon J. Gerraty# "= "value"", which is interpreted as a SysV substitution modifier with an 15302da1a3SSimon J. Gerraty# empty left-hand side, thereby appending the string " "value"" to each word 16302da1a3SSimon J. Gerraty# of the expression. 17302da1a3SSimon J. Gerraty# 18302da1a3SSimon J. Gerraty# As of 2020-10-02, some modifiers ensure that they are followed by either a 19302da1a3SSimon J. Gerraty# ':' or the closing brace or parenthesis of the expression. The modifiers 20302da1a3SSimon J. Gerraty# that don't ensure this are (in order of appearance in ApplyModifier): 21302da1a3SSimon J. Gerraty# :@var@replacement@ 22302da1a3SSimon J. Gerraty# :_ 23302da1a3SSimon J. Gerraty# :L 24302da1a3SSimon J. Gerraty# :P 25302da1a3SSimon J. Gerraty# :!cmd! 26302da1a3SSimon J. Gerraty# :gmtime=... 27302da1a3SSimon J. Gerraty# :localtime=... 28302da1a3SSimon J. Gerraty# :M (because '}' and ')' are treated the same) 29302da1a3SSimon J. Gerraty# :N (because '}' and ')' are treated the same) 30302da1a3SSimon J. Gerraty# :S 31302da1a3SSimon J. Gerraty# :C 32302da1a3SSimon J. Gerraty# :range=... 33302da1a3SSimon J. Gerraty# On the other hand, these modifiers ensure that they are followed by a 34302da1a3SSimon J. Gerraty# delimiter: 35302da1a3SSimon J. Gerraty# :D 36302da1a3SSimon J. Gerraty# :U 37302da1a3SSimon J. Gerraty# :[...] 38302da1a3SSimon J. Gerraty# :gmtime (if not followed by '=') 39302da1a3SSimon J. Gerraty# :hash (if not followed by '=') 40302da1a3SSimon J. Gerraty# :localtime (if not followed by '=') 41302da1a3SSimon J. Gerraty# :t 42302da1a3SSimon J. Gerraty# :q 43302da1a3SSimon J. Gerraty# :Q 44302da1a3SSimon J. Gerraty# :T 45302da1a3SSimon J. Gerraty# :H 46302da1a3SSimon J. Gerraty# :E 47302da1a3SSimon J. Gerraty# :R 48302da1a3SSimon J. Gerraty# :range (if not followed by '=') 49302da1a3SSimon J. Gerraty# :O 50302da1a3SSimon J. Gerraty# :u 51302da1a3SSimon J. Gerraty# :sh 52302da1a3SSimon J. Gerraty# These modifiers don't care since they reach until the closing character 53302da1a3SSimon J. Gerraty# of the expression, which is either ')' or '}': 54302da1a3SSimon J. Gerraty# ::= (as well as the other assignment modifiers) 55302da1a3SSimon J. Gerraty# :? 56302da1a3SSimon J. Gerraty# 57302da1a3SSimon J. Gerraty.if ${:!echo "\$VAR"} != "value"} 58302da1a3SSimon J. Gerraty.endif 59302da1a3SSimon J. Gerraty 60302da1a3SSimon J. Gerratyall: 61302da1a3SSimon J. Gerraty @: 62