Skip to content

Commit

Permalink
match '#' characters correctly in unquoted tag attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
jcberquist committed Mar 7, 2016
1 parent b269298 commit 31bc2bb
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 49 deletions.
4 changes: 4 additions & 0 deletions messages/0.6.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ CFML v0.6.0 Changelog:
previous version of the CFScript syntax took ~150ms to parse FW/1's `one.cfc`
(at 2883 lines) on my desktop and ~210ms on my laptop. The new version takes
~45ms on my desktop and ~70ms on my laptop.

- Unquoted tag attribute values should now correctly highlight CFScript contained
between `#` characters

19 changes: 12 additions & 7 deletions syntaxes/cfml.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,18 @@ repository:
- match: \b([a-zA-Z0-9:-]+)\b
captures:
'1': {name: entity.other.attribute-name.cfml}
- match: (=)\s*((?:[^\s<>/'"{;]|/(?!/>))+)
captures:
'1': {name: punctuation.separator.key-value.cfml}
'2': {name: string.unquoted.cfml}
- name: punctuation.separator.key-value.cfml
match: '='
- include: '#string'
- begin: '='
beginCaptures:
'0': {name: punctuation.separator.key-value.cfml}
end: (?<=[^\s=])|(?=[</>{;])
patterns:
- include: '#comments'
- include: '#string'
- name: string.unquoted.cfml
begin: (?=[^\s</>{;\'"])
end: (?=[\s</>{;])
patterns:
- include: '#hash-delimiters'

tags-with-script:
name: meta.tag.cfml
Expand Down
45 changes: 29 additions & 16 deletions syntaxes/cfml.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1180,31 +1180,44 @@
<string>\b([a-zA-Z0-9:-]+)\b</string>
</dict>
<dict>
<key>captures</key>
<key>begin</key>
<string>=</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.separator.key-value.cfml</string>
</dict>
<key>2</key>
</dict>
<key>end</key>
<string>(?&lt;=[^\s=])|(?=[&lt;/&gt;{;])</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>begin</key>
<string>(?=[^\s&lt;/&gt;{;\'"])</string>
<key>end</key>
<string>(?=[\s&lt;/&gt;{;])</string>
<key>name</key>
<string>string.unquoted.cfml</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#hash-delimiters</string>
</dict>
</array>
</dict>
</dict>
<key>match</key>
<string>(=)\s*((?:[^\s&lt;&gt;/'"{;]|/(?!/&gt;))+)</string>
</dict>
<dict>
<key>match</key>
<string>=</string>
<key>name</key>
<string>punctuation.separator.key-value.cfml</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</array>
</dict>
</array>
</dict>
Expand Down
20 changes: 13 additions & 7 deletions syntaxes/cfml.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ contexts:
scope: constant.character.hash.cfml.start
pop: true
- include: scope:source.cfml.script#comments
- include: scope:source.cfml.script#expression
- include: scope:source.cfml.script#expressions
string:
- match: "'"
scope: punctuation.definition.string.begin.cfml
Expand Down Expand Up @@ -358,13 +358,19 @@ contexts:
- match: =
scope: punctuation.separator.key-value.cfml
push:
- match: (?=[;/>{])
pop: true
- match: (?<=[^\s=])
- match: (?=[\'"])
set:
- include: string
- match: ""
pop: true
- match: (?=[^\s</>{;])
set:
- meta_scope: string.unquoted.cfml
- match: (?=[\s</>{;])
pop: true
- include: hash-delimiters
- match: '(?=\S)'
pop: true
- include: string
- match: '(?:[^\s<>/''"{;]|/(?!/>))+'
scope: string.unquoted.cfml
tags-with-script:
- match: (?i)(<)(cfset|cfreturn)(?=\s|/?>)
captures:
Expand Down
47 changes: 30 additions & 17 deletions syntaxes/cfml.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -3385,7 +3385,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;=\))|(\})|(?:([A-Z][_$\dA-Z]*)|([_$a-zA-Z][$\w]*))\b(?!(\s*\(|\s*(=)\s*\bfunction\b))</string>
<string>(?&lt;=\))|(\})|(?:([A-Z][_$\dA-Z]*)|([_$a-zA-Z][$\w]*))(?=$|[^$\w])(?!(\s*\(|\s*(=)\s*\bfunction\b))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -9127,31 +9127,44 @@
<string>\b([a-zA-Z0-9:-]+)\b</string>
</dict>
<dict>
<key>captures</key>
<key>begin</key>
<string>=</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.separator.key-value.cfml</string>
</dict>
<key>2</key>
</dict>
<key>end</key>
<string>(?&lt;=[^\s=])|(?=[&lt;/&gt;{;])</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>begin</key>
<string>(?=[^\s&lt;/&gt;{;\'"])</string>
<key>end</key>
<string>(?=[\s&lt;/&gt;{;])</string>
<key>name</key>
<string>string.unquoted.cfml</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#hash-delimiters</string>
</dict>
</array>
</dict>
</dict>
<key>match</key>
<string>(=)\s*((?:[^\s&lt;&gt;/'"{;]|/(?!/&gt;))+)</string>
</dict>
<dict>
<key>match</key>
<string>=</string>
<key>name</key>
<string>punctuation.separator.key-value.cfml</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</array>
</dict>
</array>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ type = "string" default = "hello">
<cfparam name
= "test" type = "string" default = "hello">
<!--- <- embedding.cfml meta.tag.cfml punctuation.separator.key-value.cfml --->
<!--- <- embedding.cfml meta.tag.cfml string.quoted.double.cfml --->
<!--- <- embedding.cfml meta.tag.cfml string.quoted.double.cfml --->

<cfhttp url=#some_url_var#>
<!--- ^ constant.character.hash.cfml.start --->
<!--- ^ variable.other.readwrite.cfml --->
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ type = "string" default = "hello">
<cfparam name
= "test" type = "string" default = "hello">
<!--- <- embedding.cfml meta.tag.cfml punctuation.separator.key-value.cfml --->
<!--- <- embedding.cfml meta.tag.cfml string.quoted.double.cfml --->
<!--- <- embedding.cfml meta.tag.cfml string.quoted.double.cfml --->

<cfhttp url=#some_url_var#>
<!--- ^ constant.character.hash.cfml.start --->
<!--- ^ variable.other.readwrite.cfml --->

0 comments on commit 31bc2bb

Please sign in to comment.