|
| 1 | +# [PackageDev] target_format: plist, ext: tmLanguage |
| 2 | +--- |
| 3 | +name: MagicRegExp |
| 4 | +scopeName: source.regexp |
| 5 | +fileTypes: [regexp] |
| 6 | +uuid: 39e15186-71e6-11e5-b82c-7c6d62900c7c |
| 7 | +author: Victor Petrovykh victor@magic.io |
| 8 | + |
| 9 | +patterns: |
| 10 | + - include: '#expression' |
| 11 | + |
| 12 | +repository: |
| 13 | + expression: |
| 14 | + patterns: |
| 15 | + - name: support.type.match.any.regexp |
| 16 | + match: \. |
| 17 | + - name: support.type.match.begin.regexp |
| 18 | + match: \^ |
| 19 | + - name: support.type.match.end.regexp |
| 20 | + match: \$ |
| 21 | + - name: keyword.operator.quantifier.regexp |
| 22 | + match: '[+*?]\??' |
| 23 | + - name: keyword.operator.disjunction.regexp |
| 24 | + match: \| |
| 25 | + - name: keyword.operator.quantifier.regexp |
| 26 | + match: | |
| 27 | + (?x) |
| 28 | + \{( |
| 29 | + \d+ | \d+,(\d+)? | ,\d+ |
| 30 | + )\} |
| 31 | + - include: '#escape-sequence' |
| 32 | + - include: '#character-set' |
| 33 | + - include: '#comments' |
| 34 | + - include: '#flags' |
| 35 | + - include: '#named-group' |
| 36 | + - include: '#backreference' |
| 37 | + - include: '#lookahead' |
| 38 | + - include: '#lookahead-negative' |
| 39 | + - include: '#lookbehind' |
| 40 | + - include: '#lookbehind-negative' |
| 41 | + - include: '#conditional' |
| 42 | + - include: '#parentheses-non-capturing' |
| 43 | + - include: '#parentheses' |
| 44 | + |
| 45 | + escape-sequence: |
| 46 | + patterns: |
| 47 | + - include: '#escape-special' |
| 48 | + - include: '#escape-character' |
| 49 | + - include: '#escape-unicode' |
| 50 | + - include: '#backreference-number' |
| 51 | + - include: '#escape-catchall' |
| 52 | + |
| 53 | + charecter-set-escapes: |
| 54 | + patterns: |
| 55 | + - name: support.type.escape.character.regexp |
| 56 | + match: \\[abfnrtv\\] |
| 57 | + - include: '#escape-special' |
| 58 | + - name: constant.character.escape.regexp |
| 59 | + match: \\([0-7]{1,3}) |
| 60 | + - include: '#escape-character' |
| 61 | + - include: '#escape-unicode' |
| 62 | + - include: '#escape-catchall' |
| 63 | + |
| 64 | + escape-special: |
| 65 | + name: support.type.escape.special.regexp |
| 66 | + match: \\([AbBdDsSwWZ]) |
| 67 | + |
| 68 | + escape-character: |
| 69 | + name: constant.character.escape.regexp |
| 70 | + match: | |
| 71 | + (?x) |
| 72 | + \\ ( |
| 73 | + x[0-9A-Fa-f]{2} |
| 74 | + | 0[0-7]{1,2} |
| 75 | + | [0-7]{3} |
| 76 | + ) |
| 77 | +
|
| 78 | + escape-unicode: |
| 79 | + name: constant.character.unicode.regexp |
| 80 | + match: | |
| 81 | + (?x) |
| 82 | + \\ ( |
| 83 | + u[0-9A-Fa-f]{4} |
| 84 | + | U[0-9A-Fa-f]{8} |
| 85 | + ) |
| 86 | +
|
| 87 | + backreference-number: |
| 88 | + name: meta.backreference.regexp |
| 89 | + match: (\\[1-9]\d?) |
| 90 | + captures: |
| 91 | + '1': {name: entity.name.function.backreference.regexp} |
| 92 | + |
| 93 | + escape-catchall: |
| 94 | + name: constant.character.escape.regexp |
| 95 | + match: \\(.|\n) |
| 96 | + |
| 97 | + character-set: |
| 98 | + name: meta.character.set.regexp |
| 99 | + begin: (\[)(\^)?(\])? |
| 100 | + end: (\]) |
| 101 | + beginCaptures: |
| 102 | + '1': {name: constant.character.set.regexp |
| 103 | + punctuation.character.set.begin.regexp} |
| 104 | + '2': {name: keyword.operator.negation.regexp} |
| 105 | + '3': {name: constant.character.set.regexp} |
| 106 | + endCaptures: |
| 107 | + '1': {name: constant.character.set.regexp |
| 108 | + punctuation.character.set.end.regexp} |
| 109 | + patterns: |
| 110 | + - include: '#charecter-set-escapes' |
| 111 | + - name: constant.character.set.regexp |
| 112 | + match: '[^\n]' |
| 113 | + |
| 114 | + flags: |
| 115 | + name: entity.name.function.flag.regexp |
| 116 | + match: \(\?[aiLmsux]+\) |
| 117 | + |
| 118 | + named-group: |
| 119 | + name: meta.named.regexp |
| 120 | + begin: | |
| 121 | + (?x) |
| 122 | + (\() (\?P <\w+(?:\s+[[:alnum:]]+)?>) |
| 123 | + end: \) |
| 124 | + beginCaptures: |
| 125 | + '1': {name: punctuation.parenthesis.named.begin.regexp |
| 126 | + support.type.parenthesis.regexp} |
| 127 | + '2': {name: entity.name.function.named.group.regexp} |
| 128 | + endCaptures: |
| 129 | + '0': {name: punctuation.parenthesis.named.end.regexp |
| 130 | + support.type.parenthesis.regexp} |
| 131 | + patterns: |
| 132 | + - include: '#expression' |
| 133 | + |
| 134 | + backreference: |
| 135 | + name: meta.backreference.named.regexp |
| 136 | + match: | |
| 137 | + (?x) |
| 138 | + (\() (\?P= \w+(?:\s+[[:alnum:]]+)?) (\)) |
| 139 | + captures: |
| 140 | + '1': {name: punctuation.parenthesis.backreference.named.begin.regexp |
| 141 | + support.type.parenthesis.regexp} |
| 142 | + '2': {name: entity.name.function.named.backreference.regexp} |
| 143 | + '3': {name: punctuation.parenthesis.backreference.named.end.regexp |
| 144 | + support.type.parenthesis.regexp} |
| 145 | + |
| 146 | + comments: |
| 147 | + name: comment.regexp |
| 148 | + begin: \(\?# |
| 149 | + end: \) |
| 150 | + beginCaptures: |
| 151 | + '0': {name: punctuation.comments.begin.regexp} |
| 152 | + endCaptures: |
| 153 | + '0': {name: punctuation.comments.end.regexp} |
| 154 | + |
| 155 | + lookahead: |
| 156 | + begin: '(\()\?=' |
| 157 | + end: \) |
| 158 | + beginCaptures: |
| 159 | + '0': {name: keyword.operator.lookahead.regexp} |
| 160 | + '1': {name: punctuation.parenthesis.lookahead.begin.regexp} |
| 161 | + endCaptures: |
| 162 | + '0': {name: punctuation.parenthesis.lookahead.end.regexp |
| 163 | + keyword.operator.lookahead.regexp} |
| 164 | + patterns: |
| 165 | + - include: '#expression' |
| 166 | + |
| 167 | + lookahead-negative: |
| 168 | + begin: '(\()\?!' |
| 169 | + end: \) |
| 170 | + beginCaptures: |
| 171 | + '0': {name: keyword.operator.lookahead.negative.regexp} |
| 172 | + '1': {name: punctuation.parenthesis.lookahead.begin.regexp} |
| 173 | + endCaptures: |
| 174 | + '0': {name: punctuation.parenthesis.lookahead.end.regexp |
| 175 | + keyword.operator.lookahead.negative.regexp} |
| 176 | + patterns: |
| 177 | + - include: '#expression' |
| 178 | + |
| 179 | + lookbehind: |
| 180 | + begin: '(\()\?<=' |
| 181 | + end: \) |
| 182 | + beginCaptures: |
| 183 | + '0': {name: keyword.operator.lookbehind.regexp} |
| 184 | + '1': {name: punctuation.parenthesis.lookbehind.begin.regexp} |
| 185 | + endCaptures: |
| 186 | + '0': {name: punctuation.parenthesis.lookbehind.end.regexp |
| 187 | + keyword.operator.lookbehind.regexp} |
| 188 | + patterns: |
| 189 | + - include: '#expression' |
| 190 | + |
| 191 | + lookbehind-negative: |
| 192 | + begin: '(\()\?<!' |
| 193 | + end: \) |
| 194 | + beginCaptures: |
| 195 | + '0': {name: keyword.operator.lookbehind.negative.regexp} |
| 196 | + '1': {name: punctuation.parenthesis.lookbehind.begin.regexp} |
| 197 | + endCaptures: |
| 198 | + '0': {name: punctuation.parenthesis.lookbehind.end.regexp |
| 199 | + keyword.operator.lookbehind.negative.regexp} |
| 200 | + patterns: |
| 201 | + - include: '#expression' |
| 202 | + |
| 203 | + conditional: |
| 204 | + begin: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)' |
| 205 | + end: \) |
| 206 | + beginCaptures: |
| 207 | + '0': {name: keyword.operator.conditional.regexp} |
| 208 | + '1': {name: punctuation.parenthesis.conditional.begin.regexp} |
| 209 | + endCaptures: |
| 210 | + '0': {name: punctuation.parenthesis.conditional.end.regexp |
| 211 | + keyword.operator.conditional.negative.regexp} |
| 212 | + patterns: |
| 213 | + - include: '#expression' |
| 214 | + |
| 215 | + parentheses-non-capturing: |
| 216 | + begin: '\(\?:' |
| 217 | + end: \) |
| 218 | + beginCaptures: |
| 219 | + '0': {name: punctuation.parenthesis.non-capturing.begin.regexp |
| 220 | + support.type.parenthesis.regexp} |
| 221 | + endCaptures: |
| 222 | + '0': {name: punctuation.parenthesis.non-capturing.end.regexp |
| 223 | + support.type.parenthesis.regexp} |
| 224 | + patterns: |
| 225 | + - include: '#expression' |
| 226 | + |
| 227 | + parentheses: |
| 228 | + begin: \( |
| 229 | + end: \) |
| 230 | + beginCaptures: |
| 231 | + '0': {name: punctuation.parenthesis.begin.regexp |
| 232 | + support.type.parenthesis.regexp} |
| 233 | + endCaptures: |
| 234 | + '0': {name: punctuation.parenthesis.end.regexp |
| 235 | + support.type.parenthesis.regexp} |
| 236 | + patterns: |
| 237 | + - include: '#expression' |
| 238 | +... |
0 commit comments