diff --git a/package.json b/package.json index 4768dce..cec6bf1 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,16 @@ "language": "yaml-tmlanguage", "scopeName": "source.yaml-tmlanguage", "path": "./syntaxes/yaml-tmlanguage.tmLanguage" + }, + { + "scopeName": "source.escapedregexp", + "path": "./syntaxes/Regular Expression (Escaped).tmLanguage", + "injectTo": ["source.json-tmlanguage"] + }, + { + "scopeName": "source.oniregexp", + "path": "./syntaxes/Oniguruma Regular Expression.tmLanguage", + "injectTo": ["source.yaml-tmlanguage"] } ], "snippets": [ diff --git a/syntaxes/Oniguruma Regular Expression.tmLanguage b/syntaxes/Oniguruma Regular Expression.tmLanguage new file mode 100644 index 0000000..5ab3dc1 --- /dev/null +++ b/syntaxes/Oniguruma Regular Expression.tmLanguage @@ -0,0 +1,279 @@ + + + + + comment + Version 5.9.1 2007/09/05, Specification used: http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt + fileTypes + + ore + + name + Oniguruma Regular Expression + patterns + + + match + \| + name + keyword.operator.regexp + + + match + \\[bBAZzG]|[$^] + name + entity.other.control.anchors.regexp + + + include + #character_class + + + include + #character_property + + + include + #set + + + begin + \(\?# + end + (?<!\\)\) + name + comment.block.number-sign.regexp + + + begin + (?x) ((?#1)\() +((?#2)\? + (?: + <[=!] + |[>=:!] + |[imx]{,3}(?:-[imx]{1,3})?(?::(?!\))|(?=\))) + |[<']((?#3)\w+)[>'] + ) +)? + + beginCaptures + + 1 + + name + storage.type.regexp.group.begin + + 2 + + name + string.regexp constant.other.assertion.regexp + + 3 + + name + variable.other.regexp + + + end + \) + endCaptures + + 0 + + name + storage.type.regexp.group.end + + + name + meta.regexp.group + patterns + + + include + source.oniregexp + + + + + include + #special_escapes + + + captures + + 1 + + name + variable.other.regexp + + 2 + + name + keyword.other.backref.regexp + + 3 + + name + variable.other.regexp + + + match + (?x) + (\\\d+) +|(\\k[<'](-?\d+|\w+([-+]\d+)?)[>']) + + name + keyword.other.backref.regexp + + + captures + + 1 + + name + variable.other.regexp + + + match + \\g[<'](-?\d+|\w+)[>'] + name + keyword.other.subexp-call.regexp + + + match + ((?<!\()[?*+][?+]?)|\{\d*(,\d*)?\} + name + support.operator.quantifier.regexp + + + include + #escaped_char + + + repository + + character_class + + match + \\[wWsSdDhH]|\. + name + keyword.control.character-class.regexp + + character_property + + captures + + 1 + + name + constant.other.property.regexp + + + match + (?x) +\\(?:p\{\^?|P\{)( + (?#all encodings) + (?>Alnum|Alpha|Blank|Cntrl|Digit|Graph|Lower| + Print|Punct|Space|Upper|XDigit|Word|ASCII) + (?#EUC_JP, Shift_JIS) + |(?>Hiragana|Katakana) + (?#UTF8, UTF16, UTF32) + |(?>Any|Assigned) + |(?>C|Cc|Cf|Cn|Co|Cs|L|Ll|Lm|Lo|Lt|Lu| + M|Mc|Me|Mn|N|Nd|Nl|No|P|Pc|Pd|Pe|Pf|Pi|Po|Ps| + S|Sc|Sk|Sm|So|Z|Zl|Zp|Zs) + |(?>Arabic|Armenian|Bengali|Bopomofo|Braille|Buginese| + Buhid|Canadian_Aboriginal|Cherokee|Common|Coptic| + Cypriot|Cyrillic|Deseret|Devanagari|Ethiopic|Georgian| + Glagolitic|Gothic|Greek|Gujarati|Gurmukhi|Han|Hangul| + Hanunoo|Hebrew|Hiragana|Inherited|Kannada|Katakana| + Kharoshthi|Khmer|Lao|Latin|Limbu|Linear_B|Malayalam| + Mongolian|Myanmar|New_Tai_Lue|Ogham|Old_Italic|Old_Persian| + Oriya|Osmanya|Runic|Shavian|Sinhala|Syloti_Nagri|Syriac| + Tagalog|Tagbanwa|Tai_Le|Tamil|Telugu|Thaana|Thai|Tibetan| + Tifinagh|Ugaritic|Yi) +)\} + + name + keyword.contol.character-property.regexp + + escaped_char + + match + \\. + name + constant.character.escape.general.regexp + + set + + begin + \[(\^?\])? + end + \] + name + string.regexp.set + patterns + + + match + \[:\^?(?>alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|xdigit|word):\] + name + constant.other.posix-bracket.regexp + + + include + #set + + + include + #character_class + + + include + #character_property + + + include + #special_escapes + + + include + #escaped_char + + + match + .-[^\]] + name + constant.other.range.regexp + + + match + (?<!\[)&&(?!\]) + name + keyword.operator.intersection.regexp + + + + special_escapes + + match + (?x)\\ +([tvnrbfae] (?# general chars) +|[0-8]{3} (?# octal) +|x\h\h (?# hexadecimal) +|x\{7\h{7}\} (?# wide hexadecimal) +|c\d+ (?# control char) +|M-(\\C-)?\d+ (?# meta control char) +|C-\d+ (?# control char 2) +) + + name + constant.character.escape.special.regexp + + + scopeName + source.oniregexp + uuid + 516c608b-ce09-4e6f-a2db-caedc8d1fbff + + \ No newline at end of file diff --git a/syntaxes/Regular Expression (Escaped).tmLanguage b/syntaxes/Regular Expression (Escaped).tmLanguage new file mode 100644 index 0000000..083def0 --- /dev/null +++ b/syntaxes/Regular Expression (Escaped).tmLanguage @@ -0,0 +1,275 @@ + + + + + name + Regular Expression (Escaped) + scopeName + source.escapedregexp + patterns + + + include + #classes + + + include + #anchorsWithBackslash + + + include + #allEscapes + + + include + #anchors + + + include + #quantifiers + + + include + #granularQuantifier + + + include + #operators + + + include + #sets + + + include + #groups + + + repository + + allEscapes + + comment + Order matters. + patterns + + + include + #regexpEscapeSequences + + + include + #regexpEscapedBackslash + + + include + #jsonEscapeSequences + + + + regexpEscapeSequences + + match + (?<!\\\\)\\\\(?:[]^+?*.(){}$\[]) + name + constant.character.escape.sequence.regexp.escapedregexp + comment + Escape next char if the slash isn't being escaped itself. + + regexpEscapedBackslash + + match + \\\\ + name + constant.character.escape.sequence.regexp.escapedregexp + + jsonEscapeSequences + + match + \\[bfntr"/] + name + entity.other.attribute-name.escape.sequence.json.escapedregexp + + quantifiers + + match + (\+|\*|\?)(\?)? + name + keyword.other.quantifier.escapedregexp + + granularQuantifier + + match + (\{)([0-9]+)(,)?([0-9]+)?(\}) + name + meta.granular.quantifier.escapedregexp + captures + + 1 + + name + keyword.other.punctuation.quantifier.start.escapedregexp + + 2 + + name + constant.numeric.escapedregexp + + 3 + + name + keyword.other.separator.escapedregexp + + 4 + + name + constant.numeric.escapedregexp + + 5 + + name + keyword.other.punctuation.quantifier.end.escapedregexp + + + + classes + + match + \\\\[dDsSwW] + name + keyword.other.character-class.escapedregexp + comment + XXX: Add unicode escapes \x00 and escapes within comments. + + operators + + match + [|.] + name + keyword.other.operator.escapedregexp + + sets + + begin + (\[)(\^)?(\])? + beginCaptures + + 1 + + name + keyword.other.set.escapedregexp + + 2 + + name + keyword.other.set.operator.negate.escapedregexp + + 3 + + name + string.set.element.escapedregexp + + + end + ] + endCaptures + + 0 + + name + keyword.other.set.escapedregexp + + + patterns + + + name + support.function.set.range.escapedregexp + match + [A-Za-z0-9](-)[A-Za-z0-9] + captures + + 1 + + name + keyword.operator.other.set.range.separator.escapedregexp + + + + + include + #regexpEscapeSequences + + + include + #classes + + + include + #jsonEscapeSequences + + + name + string.set.element.escapedregexp + match + .*? + + + + groups + + begin + \( + beginCaptures + + 0 + + name + string.regexp.group.escapedregexp + + + endCaptures + + 0 + + name + string.regexp.group.escapedregexp + + + end + \) + patterns + + + name + support.function.assertion.escapedregexp + match + (\?(?:[:=!>]|<[=!])) + + + include + $self + + + comment + XXX: Implement named groups, options and yes/no groups. + + anchorsWithBackslash + + match + (?:\\\\[AbBZ]) + name + entity.other.attribute-name.anchor.escapedregexp + + anchors + + match + [$^] + name + entity.other.attribute-name.anchor.escapedregexp + + + uuid + 26c6799e-6824-4926-b2e5-87140300b97b + + \ No newline at end of file