Add source.regexp.python rules

This commit is contained in:
Martin Aeschlimann 2015-11-13 18:25:18 +01:00
Родитель 8f82b037fe
Коммит ef99de7936
2 изменённых файлов: 302 добавлений и 0 удалений

Просмотреть файл

@ -15,6 +15,9 @@
"language": "python",
"scopeName": "source.python",
"path": "./syntaxes/Python.tmLanguage"
},{
"scopeName": "source.regexp.python",
"path": "./syntaxes/Regular Expressions (Python).tmLanguage"
}]
}
}

Просмотреть файл

@ -0,0 +1,299 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>Matches Python's regular expression syntax.</string>
<key>fileTypes</key>
<array>
<string>re</string>
</array>
<key>foldingStartMarker</key>
<string>(/\*|\{|\()</string>
<key>foldingStopMarker</key>
<string>(\*/|\}|\))</string>
<key>name</key>
<string>Regular Expressions (Python)</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\[bBAZzG]|\^|\$</string>
<key>name</key>
<string>keyword.control.anchor.regexp</string>
</dict>
<dict>
<key>match</key>
<string>\\[1-9][0-9]?</string>
<key>name</key>
<string>keyword.other.back-reference.regexp</string>
</dict>
<dict>
<key>match</key>
<string>[?+*][?+]?|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??</string>
<key>name</key>
<string>keyword.operator.quantifier.regexp</string>
</dict>
<dict>
<key>match</key>
<string>\|</string>
<key>name</key>
<string>keyword.operator.or.regexp</string>
</dict>
<dict>
<key>begin</key>
<string>\(\?\#</string>
<key>end</key>
<string>\)</string>
<key>name</key>
<string>comment.block.regexp</string>
</dict>
<dict>
<key>comment</key>
<string>We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.</string>
<key>match</key>
<string>(?&lt;=^|\s)#\s[[a-zA-Z0-9,. \t?!-:][^\x{00}-\x{7F}]]*$</string>
<key>name</key>
<string>comment.line.number-sign.regexp</string>
</dict>
<dict>
<key>match</key>
<string>\(\?[iLmsux]+\)</string>
<key>name</key>
<string>keyword.other.option-toggle.regexp</string>
</dict>
<dict>
<key>match</key>
<string>(\()(\?P=([a-zA-Z_][a-zA-Z_0-9]*\w*))(\))</string>
<key>name</key>
<string>keyword.other.back-reference.named.regexp</string>
</dict>
<dict>
<key>begin</key>
<string>(\()((\?=)|(\?!)|(\?&lt;=)|(\?&lt;!))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.regexp</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.assertion.regexp</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>meta.assertion.look-ahead.regexp</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>meta.assertion.negative-look-ahead.regexp</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>meta.assertion.look-behind.regexp</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>meta.assertion.negative-look-behind.regexp</string>
</dict>
</dict>
<key>end</key>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.regexp</string>
</dict>
</dict>
<key>name</key>
<string>meta.group.assertion.regexp</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(\()(\?\(([1-9][0-9]?|[a-zA-Z_][a-zA-Z_0-9]*)\))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.regexp</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.assertion.conditional.regexp</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>entity.name.section.back-reference.regexp</string>
</dict>
</dict>
<key>comment</key>
<string>we can make this more sophisticated to match the | character that separates yes-pattern from no-pattern, but it's not really necessary.</string>
<key>end</key>
<string>(\))</string>
<key>name</key>
<string>meta.group.assertion.conditional.regexp</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(\()((\?P&lt;)([a-z]\w*)(&gt;)|(\?:))?</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.regexp</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.capture.regexp</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>entity.name.section.group.regexp</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.capture.regexp</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.no-capture.regexp</string>
</dict>
</dict>
<key>end</key>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.group.regexp</string>
</dict>
</dict>
<key>name</key>
<string>meta.group.regexp</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#character-class</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>character-class</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\[wWsSdDhH]|\.</string>
<key>name</key>
<string>constant.character.character-class.regexp</string>
</dict>
<dict>
<key>match</key>
<string>\\.</string>
<key>name</key>
<string>constant.character.escape.backslash.regexp</string>
</dict>
<dict>
<key>begin</key>
<string>(\[)(\^)?</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.character-class.regexp</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.operator.negation.regexp</string>
</dict>
</dict>
<key>end</key>
<string>(\])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.character-class.regexp</string>
</dict>
</dict>
<key>name</key>
<string>constant.other.character-class.set.regexp</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#character-class</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>constant.character.escape.backslash.regexp</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>constant.character.escape.backslash.regexp</string>
</dict>
</dict>
<key>match</key>
<string>((\\.)|.)\-((\\.)|[^\]])</string>
<key>name</key>
<string>constant.other.character-class.range.regexp</string>
</dict>
</array>
</dict>
</array>
</dict>
</dict>
<key>scopeName</key>
<string>source.regexp.python</string>
<key>uuid</key>
<string>DD867ABF-1EC6-415D-B047-687F550A1D51</string>
</dict>
</plist>