@@ -35,12 +35,17 @@ Keywords={
35
35
{ Id=4,
36
36
Regex=[[(\w+)\s*\(]],
37
37
},
38
+
39
+ --see OnStateChange
40
+ { Id=5,
41
+ Regex = [[ [#]\{[^}]*?\} ]],
42
+ },
38
43
}
39
44
40
45
-- hereDoc opening delimiter, see OnStateChange to handle end of string
41
46
Strings={
42
- Delimiter=[["|'|`|<<[\-"'`]?[\w_]+["'`]?]],
43
- Interpolation = [[ % \{[^}]*?\} ]],
47
+ Delimiter=[["|'|`|<<[\-~ "'`]?[\w_]+["'`]?]],
48
+ Interpolation = [[ [%] \{[^}]*?\} ]],
44
49
45
50
DelimiterPairs= {
46
51
{ Open=[[%q\(]], Close=[[\)]] },
@@ -73,7 +78,6 @@ Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\.|\&|<|>|\!|\-|\+|\/|\*|\=|\?|\%|\|]]
73
78
function OnStateChange(oldState, newState, token, groupID)
74
79
75
80
-- https://fossies.org/linux/misc/puppet-5.3.2.tar.gz/puppet-5.3.2/lib/puppet/indirector/hiera.rb?m=t
76
-
77
81
78
82
if token==")" or token=="}" or token=="{" and oldState~=HL_STRING then
79
83
return HL_OPERATOR
@@ -87,23 +91,26 @@ function OnStateChange(oldState, newState, token, groupID)
87
91
hereDoc = nil
88
92
return HL_STRING_END
89
93
end
90
-
91
-
92
-
94
+
93
95
if hereDoc~=nil then
94
96
return HL_STRING
95
97
end
96
98
99
+ --resolve issue with #{} sequence within strings
100
+ if oldState==HL_STRING and newState==HL_KEYWORD and groupID==5 then
101
+ return HL_INTERPOLATION
102
+ end
103
+
97
104
-- resolve issue with regex expression which spans strings like "</i>" + VAR + "</i>"
98
105
if string.sub(token,1,1)=="/" and oldState==HL_STRING and newState==HL_KEYWORD then
99
106
return HL_REJECT
100
107
end
101
108
102
- --recognize hereDoc multine strings
109
+ --recognize hereDoc multine strings (including squiggly heredoc)
103
110
--do not clear hereDoc if token is ",' or `
104
111
if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING
105
112
and not string.find("\"'`", token) then
106
- hereDoc = string.match(token, "<<[%-\"'`]?([%a_]+)" )
113
+ hereDoc = string.match(token, "<<[%-~ \"'`]?([%a_]+)" )
107
114
end
108
115
109
116
-- fix quoted string termination
0 commit comments