Skip to content

Commit

Permalink
Use the javascript regular expressions grammar
Browse files Browse the repository at this point in the history
This matches the individual components of the regular expression and prevents escaping issues.

Fixes jashkenas#26 & jashkenas#105.
  • Loading branch information
infininight authored and ttilley committed Apr 2, 2013
1 parent 77deb26 commit 0e13872
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 18 deletions.
72 changes: 63 additions & 9 deletions Syntaxes/CoffeeScript (Literate).tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
|^\s*-->
|(^|\s)\}
)</string>
<key>injections</key>
<dict>
<key>string.regexp.block.coffee</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
</dict>
</array>
</dict>
</dict>
<key>name</key>
<string>CoffeeScript (Literate)</string>
<key>patterns</key>
Expand Down Expand Up @@ -728,27 +745,64 @@
<dict>
<key>begin</key>
<string>/{3}</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>/{3}[imgy]{0,4}</string>
<string>(/{3})[imgy]{0,4}</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<string>string.regexp.block.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>/(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>begin</key>
<string>/(?![\s=/*+{}?])</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>(/)[igmy]*(?![a-zA-Z0-9])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
Expand Down
72 changes: 63 additions & 9 deletions Syntaxes/CoffeeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
<string>^\s*class\s+\S.*$|.*(-&gt;|=&gt;)\s*$|.*[\[{]\s*$</string>
<key>foldingStopMarker</key>
<string>^\s*$|^\s*[}\]]\s*$</string>
<key>injections</key>
<dict>
<key>string.regexp.block.coffee</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
</dict>
</array>
</dict>
</dict>
<key>keyEquivalent</key>
<string>^~C</string>
<key>name</key>
Expand Down Expand Up @@ -198,27 +215,64 @@
<dict>
<key>begin</key>
<string>/{3}</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>/{3}[imgy]{0,4}</string>
<string>(/{3})[imgy]{0,4}</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<string>string.regexp.block.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>/(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>begin</key>
<string>/(?![\s=/*+{}?])</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>(/)[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
Expand Down

0 comments on commit 0e13872

Please sign in to comment.