Skip to content
This repository was archived by the owner on Jul 21, 2018. It is now read-only.

Commit c85b546

Browse files
committed
fixed interpolation and added squiggly heredocs in ruby.lang
1 parent b40d303 commit c85b546

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

langDefs/ruby.lang

+15-8
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ Keywords={
3535
{ Id=4,
3636
Regex=[[(\w+)\s*\(]],
3737
},
38+
39+
--see OnStateChange
40+
{ Id=5,
41+
Regex = [[ [#]\{[^}]*?\} ]],
42+
},
3843
}
3944

4045
-- hereDoc opening delimiter, see OnStateChange to handle end of string
4146
Strings={
42-
Delimiter=[["|'|`|<<[\-"'`]?[\w_]+["'`]?]],
43-
Interpolation = [[ %\{[^}]*?\} ]],
47+
Delimiter=[["|'|`|<<[\-~"'`]?[\w_]+["'`]?]],
48+
Interpolation = [[ [%]\{[^}]*?\} ]],
4449

4550
DelimiterPairs= {
4651
{ Open=[[%q\(]], Close=[[\)]] },
@@ -73,7 +78,6 @@ Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\.|\&|<|>|\!|\-|\+|\/|\*|\=|\?|\%|\|]]
7378
function OnStateChange(oldState, newState, token, groupID)
7479

7580
-- https://fossies.org/linux/misc/puppet-5.3.2.tar.gz/puppet-5.3.2/lib/puppet/indirector/hiera.rb?m=t
76-
7781

7882
if token==")" or token=="}" or token=="{" and oldState~=HL_STRING then
7983
return HL_OPERATOR
@@ -87,23 +91,26 @@ function OnStateChange(oldState, newState, token, groupID)
8791
hereDoc = nil
8892
return HL_STRING_END
8993
end
90-
91-
92-
94+
9395
if hereDoc~=nil then
9496
return HL_STRING
9597
end
9698

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+
97104
-- resolve issue with regex expression which spans strings like "</i>" + VAR + "</i>"
98105
if string.sub(token,1,1)=="/" and oldState==HL_STRING and newState==HL_KEYWORD then
99106
return HL_REJECT
100107
end
101108

102-
--recognize hereDoc multine strings
109+
--recognize hereDoc multine strings (including squiggly heredoc)
103110
--do not clear hereDoc if token is ",' or `
104111
if (oldState==HL_STANDARD or oldState==HL_STRING) and newState==HL_STRING
105112
and not string.find("\"'`", token) then
106-
hereDoc = string.match(token, "<<[%-\"'`]?([%a_]+)" )
113+
hereDoc = string.match(token, "<<[%-~\"'`]?([%a_]+)" )
107114
end
108115

109116
-- fix quoted string termination

0 commit comments

Comments
 (0)