syntax_test_js_regexp.js (6953B)
1 // SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" 2 3 /* LITERAL */ 4 5 // 6 // ^^ comment - string.regexp 7 8 /abc/; 9 // ^^^^^ string.regexp 10 // ^ punctuation.definition.string.begin 11 // ^ punctuation.definition.string.end 12 13 /ab\/c/; 14 // ^^^^^^^ string.regexp 15 // ^^ constant.character.escape.backslash 16 17 /ab\//; 18 // ^^^^^^ string.regexp - comment 19 // ^^ constant.character.escape.backslash 20 21 /ab\/*/; 22 // ^^^^^^^ string.regexp - comment 23 // ^^ constant.character.escape.backslash 24 // ^ keyword.operator.quantifier 25 26 /abc/gimuys; 27 // ^^^^^^^^^^^ string.regexp 28 // ^^^^^^ keyword.other.js 29 30 /abc/ 31 gimuys; 32 // ^^^^^^ variable.other.readwrite - string.regexp; 33 34 /abc//* 35 */gimuys; 36 // ^^^^^^ variable.other.readwrite - string.regexp; 37 38 /abc//i; 39 // ^^^^^ string.regexp 40 // ^^ - string.regexp 41 // ^ keyword.operator.arithmetic 42 // ^ variable.other.readwrite 43 44 /abc/*i; 45 // ^^^^^ string.regexp 46 // ^^ - string.regexp 47 // ^ keyword.operator.arithmetic - string.regexp 48 // ^ variable.other.readwrite 49 50 /abc/**i; 51 // ^^^^^ string.regexp 52 // ^^^ - string.regexp 53 // ^^ keyword.operator.arithmetic - string.regexp 54 // ^ variable.other.readwrite 55 56 57 /a|b/; 58 // ^ keyword.operator.or 59 60 /* ESCAPES */ 61 62 /a.c/; 63 // ^ constant.other.character-class.escape 64 65 /\d\D\w\W\s\S/; 66 // ^^^^^^^^^^^^ constant.other.character-class.escape.backslash 67 68 /\t\r\n\v\f\0/; 69 // ^^^^^^^^^^^^ constant.character.escape.backslash 70 71 /\cAB/; 72 // ^^^ constant.character.escape.backslash 73 // ^ - constant.character.escape 74 75 /\x0ff/; 76 // ^^^^ constant.character.escape.backslash 77 // ^ - constant.character.escape 78 79 /\x0/; 80 // ^^ constant.character.escape.backslash 81 // ^ - constant.character.escape 82 83 /\u12abc/; 84 // ^^^^^^ constant.character.escape.backslash 85 // ^ - constant.character.escape 86 87 /\u12a/; 88 // ^^ constant.character.escape.backslash 89 // ^^^ - constant.character.escape 90 91 /\b\B^$/; 92 // ^^^^^^ keyword.control.anchor 93 94 /\p{General_Category=Letter} \P{Letter}/; 95 // ^^ constant.other.character-class.escape.unicode-property 96 // ^ punctuation.definition.unicode-property.begin 97 // ^^^^^^^^^^^^^^^^ support.constant.unicode-property 98 // ^ punctuation.separator.key-value.unicode-property 99 // ^^^^^^ support.constant.unicode-property 100 // ^ punctuation.definition.unicode-property.end 101 // ^^ constant.other.character-class.escape.unicode-property 102 // ^ punctuation.definition.unicode-property.begin 103 // ^^^^^^ support.constant.unicode-property 104 // ^ punctuation.definition.unicode-property.end 105 106 /* QUANTIFIERS */ 107 108 /a*b+c?/; 109 // ^ keyword.operator.quantifier.regexp 110 // ^ keyword.operator.quantifier.regexp 111 // ^ keyword.operator.quantifier.regexp 112 113 /a*?b+?c??/; 114 // ^^ keyword.operator.quantifier.regexp 115 // ^^ keyword.operator.quantifier.regexp 116 // ^^ keyword.operator.quantifier.regexp 117 118 /a{10}b{1,2}c{1,}d{,2}/; 119 // ^^^^ keyword.operator.quantifier 120 // ^^^^^ keyword.operator.quantifier 121 // ^^^^ keyword.operator.quantifier 122 // ^^^^ keyword.operator.quantifier 123 124 125 /a{10}?b{1,2}?c{1,}?d{,2}?/; 126 // ^^^^^ keyword.operator.quantifier 127 // ^^^^^^ keyword.operator.quantifier 128 // ^^^^^ keyword.operator.quantifier 129 // ^^^^^ keyword.operator.quantifier 130 131 /a{b{}c{,}d{1, 2}/; 132 // ^^^^^^^^^^^^^^^^ - keyword.operator.quantifier 133 134 /* GROUPING */ 135 136 /a(bc)d/; 137 // ^^^^ meta.group 138 // ^ punctuation.definition.group 139 // ^ punctuation.definition.group 140 141 /a(?:bc)d/; 142 // ^^^^^^ meta.group 143 // ^^^ punctuation.definition.group 144 // ^^ punctuation.definition.group.no-capture 145 // ^ punctuation.definition.group 146 147 /a(b(c)d)e/; 148 // ^^^^^^^ meta.group 149 // ^^^ meta.group meta.group 150 // ^ punctuation.definition.group 151 // ^ punctuation.definition.group 152 // ^ punctuation.definition.group 153 // ^ punctuation.definition.group 154 155 /a(b)c\1/; 156 // ^^ keyword.other.back-reference 157 158 /a(?<foo>bc)d\k<foo>/; 159 // ^^^^^^^^^^ meta.group 160 // ^^ punctuation.definition.group 161 // ^ punctuation.definition.group.named.begin 162 // ^^^ entity.name.other.group 163 // ^ punctuation.definition.group.named.end 164 // ^ punctuation.definition.group 165 // ^^ keyword.other.back-reference 166 // ^ punctuation.definition.group.named.begin 167 // ^^^ variable.other.group 168 // ^ punctuation.definition.group.named.end 169 170 /* ASSERTIONS */ 171 172 /(?=foo)/; 173 // ^^^^^^^ meta.group.assertion 174 // ^ punctuation.definition.group 175 // ^^ punctuation.definition.group.assertion meta.assertion.look-ahead 176 // ^ punctuation.definition.group 177 178 /(?!foo)/; 179 // ^^^^^^^ meta.group.assertion 180 // ^ punctuation.definition.group 181 // ^^ punctuation.definition.group.assertion meta.assertion.negative-look-ahead 182 // ^ punctuation.definition.group 183 184 /(?<=foo)/; 185 // ^^^^^^^^ meta.group.assertion 186 // ^ punctuation.definition.group 187 // ^^^ punctuation.definition.group.assertion meta.assertion.look-behind 188 // ^ punctuation.definition.group 189 190 /(?<!foo)/; 191 // ^^^^^^^^ meta.group.assertion 192 // ^ punctuation.definition.group 193 // ^^^ punctuation.definition.group.assertion meta.assertion.negative-look-behind 194 // ^ punctuation.definition.group 195 196 /* CHARACTER CLASSES */ 197 198 /[abc]/; 199 // ^^^^^ constant.other.character-class.set 200 // ^ punctuation.definition.character-class 201 // ^ punctuation.definition.character-class 202 203 /[^abc]/; 204 // ^^^^^^ constant.other.character-class.set 205 // ^ punctuation.definition.character-class 206 // ^ keyword.operator.negation 207 // ^ punctuation.definition.character-class 208 209 /[\b]/; 210 // ^^ constant.character.escape.backslash - keyword.control.anchor 211 212 /[/]/; 213 // ^^^^^ string.regexp 214 // ^^^ constant.other.character-class.set 215 216 /][[]]/; 217 // ^ - punctuation 218 // ^^^ constant.other.character-class.set.regexp 219 // ^ punctuation.definition.character-class 220 // ^ punctuation.definition.character-class 221 // ^ - punctuation 222 223 /[a-z]/; 224 // ^^^^^ constant.other.character-class.set 225 // ^^^ constant.other.character-class.range 226 // ^ punctuation.definition.range 227 // ^ punctuation.definition.character-class 228 // ^ punctuation.definition.character-class 229 230 /[a-]/; 231 // ^^ - constant.other.character-class.range 232 // ^ - punctuation.definition.range 233 234 235 /[-z]/; 236 // ^^ - constant.other.character-class.range 237 // ^ - punctuation.definition.range 238 239 /[^-z]/; 240 // ^^^ - constant.other.character-class.range 241 // ^ - punctuation.definition.range