lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

syntax_test_js_control.js (10553B)


      1 // SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax"
      2 
      3     if ( true ) { } ;
      4 //  ^^^^^^^^^^^^^^^ meta.conditional
      5 //  ^^ keyword.control.conditional.if
      6 //     ^^^^^^^^ meta.group
      7 //     ^ punctuation.section.group.begin
      8 //       ^^^^ constant.language.boolean.true
      9 //            ^ punctuation.section.group.end
     10 //              ^^^ meta.block
     11 //              ^ punctuation.section.block.begin
     12 //                ^ punctuation.section.block.end
     13 //                 ^ - meta.conditional
     14 //                  ^ punctuation.terminator.statement.empty
     15 
     16     if ( true ) null ;
     17 //  ^^^^^^^^^^^^^^^^^^ meta.conditional
     18 //  ^^ keyword.control.conditional.if
     19 //     ^^^^^^^^ meta.group
     20 //     ^ punctuation.section.group.begin
     21 //       ^^^^ constant.language.boolean.true
     22 //            ^ punctuation.section.group.end
     23 //              ^^^^ constant.language.null
     24 //                   ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
     25 //                    ^ - meta.conditional
     26 
     27     if (true) {}/**/
     28 //              ^^^^ - meta.conditional
     29 
     30     if (true) ;
     31 //  ^^^^^^^^^^ meta.conditional
     32 //            ^ punctuation.terminator.statement.empty
     33 
     34     if (true) ;
     35     else { } ;
     36 //  ^^^^^^^^ meta.conditional
     37 //  ^^^^ keyword.control.conditional.else
     38 //       ^^^ meta.block
     39 //       ^ punctuation.section.block.begin
     40 //         ^ punctuation.section.block.end
     41 //          ^ - meta.conditional
     42 //           ^ punctuation.terminator.statement.empty
     43 
     44     else if (true) { } ;
     45 //  ^^^^^^^^^^^^^^^^^^ meta.conditional
     46 //  ^^^^^^^ keyword.control.conditional.elseif
     47 //          ^^^^^^ meta.group
     48 //          ^ punctuation.section.group.begin
     49 //           ^^^^ constant.language.boolean.true
     50 //               ^ punctuation.section.group.end
     51 //                 ^^^ meta.block
     52 //                 ^ punctuation.section.block.begin
     53 //                   ^ punctuation.section.block.end
     54 //                    ^^^ - meta.conditional
     55 //                     ^ punctuation.terminator.statement.empty
     56 
     57     do { } while ( true ) ;
     58 //  ^^^^^^^^^^^^^^^^^^^^^ meta.do-while
     59 //  ^^ keyword.control.loop.do-while
     60 //     ^^^ meta.block
     61 //     ^ punctuation.section.block.begin
     62 //       ^ punctuation.section.block.end
     63 //         ^^^^^ keyword.control.loop.while
     64 //               ^^^^^^^^ meta.group
     65 //               ^ punctuation.section.group.begin
     66 //                 ^^^^ constant.language.boolean.true
     67 //                      ^ punctuation.section.group.end
     68 //                       ^ - meta.do-while
     69 //                        ^ punctuation.terminator.statement.empty
     70 
     71     do 42 ; while ( true ) ;
     72 //  ^^^^^^^^^^^^^^^^^^^^^^ meta.do-while
     73 //  ^^ keyword.control.loop.do-while
     74 //     ^^ meta.number.integer.decimal constant.numeric.value
     75 //        ^ punctuation.terminator.statement
     76 //          ^^^^^ keyword.control.loop.while
     77 //                ^^^^^^^^ meta.group
     78 //                ^ punctuation.section.group.begin
     79 //                  ^^^^ constant.language.boolean.true
     80 //                       ^ punctuation.section.group.end
     81 //                         ^ punctuation.terminator.statement.empty
     82 
     83     do {} while (false)/**/
     84 //                     ^ - meta.do-while
     85 
     86     for (var i = 0; i < 10; i++) { } ;
     87 //  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
     88 //  ^^^ keyword.control.loop.for
     89 //      ^^^^^^^^^^^^^^^^^^^^^^^^ meta.group
     90 //      ^ punctuation.section.group
     91 //       ^^^ storage.type
     92 //           ^ meta.binding.name variable.other.readwrite
     93 //             ^ keyword.operator.assignment
     94 //               ^ meta.number.integer.decimal constant.numeric.value
     95 //                ^ punctuation.separator.expression
     96 //                  ^ variable.other.readwrite
     97 //                    ^ keyword.operator.comparison
     98 //                      ^^ meta.number.integer.decimal constant.numeric.value
     99 //                        ^ punctuation.separator.expression
    100 //                          ^ variable.other.readwrite
    101 //                           ^^ keyword.operator.arithmetic
    102 //                             ^ punctuation.section.group
    103 //                               ^^^ meta.block
    104 //                               ^ punctuation.section.block.begin
    105 //                                 ^ punctuation.section.block.end
    106 //                                  ^ - meta.for
    107 //                                   ^ punctuation.terminator.statement.empty
    108 
    109     for (;;) 42;
    110 //  ^^^^^^^^^ meta.for
    111 //  ^^^ keyword.control.loop.for
    112 //      ^^^^ meta.group
    113 //      ^ punctuation.section.group
    114 //       ^^ punctuation.separator.expression
    115 //         ^ punctuation.section.group
    116 //           ^^ meta.number.integer.decimal constant.numeric.value
    117 //             ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
    118 //              ^ - meta.for
    119 
    120     for (; x in list;) {}
    121 //  ^^^^^^^^^^^^^^^^^^^^^ meta.for
    122 //  ^^^ keyword.control.loop.for
    123 //      ^^^^^^^^^^^^^^ meta.group
    124 //       ^ punctuation.separator.expression
    125 //           ^^ keyword.operator
    126 //                  ^ punctuation.separator.expression
    127 
    128     for (a[x in list];;) {}
    129 //  ^^^^^^^^^^^^^^^^^^^^^^^ meta.for
    130 //  ^^^ keyword.control.loop.for
    131 //      ^^^^^^^^^^^^^^^^ meta.group
    132 //        ^^^^^^^^^^^ meta.brackets
    133 //           ^^ keyword.operator
    134 //                   ^ punctuation.separator.expression
    135 //                    ^ punctuation.separator.expression
    136 
    137     for (;function () {}/a/g;) {}
    138 //                      ^ keyword.operator
    139 
    140     for (const x in list) {}
    141 //  ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
    142 //  ^^^ keyword.control.loop.for
    143 //      ^^^^^^^^^^^^^^^^^ meta.group
    144 //       ^^^^^ storage.type
    145 //               ^^ keyword.operator.word
    146 
    147     for (const x of list) {}
    148 //  ^^^^^^^^^^^^^^^^^^^^^^^^ meta.for
    149 //  ^^^ keyword.control.loop.for
    150 //      ^^^^^^^^^^^^^^^^^ meta.group
    151 //       ^^^^^ storage.type
    152 //               ^^ keyword.operator.word
    153 
    154     for (x in list) {}
    155 //  ^^^^^^^^^^^^^^^^^^ meta.for
    156 //  ^^^ keyword.control.loop.for
    157 //      ^^^^^^^^^^^ meta.group
    158 //         ^^ keyword.operator.word
    159 
    160     for (x of list) {}
    161 //  ^^^^^^^^^^^^^^^^^^ meta.for
    162 //  ^^^ keyword.control.loop.for
    163 //      ^^^^^^^^^^^ meta.group
    164 //         ^^ keyword.operator.word
    165 
    166     for await (const x of list) {}
    167 //  ^^^ keyword.control.loop.for
    168 //      ^^^^^ keyword.control.flow.await
    169 
    170 for
    171     42;
    172 //  ^^ constant.numeric - meta.for
    173 
    174 for(;;){}/**/
    175 //       ^ - meta.for
    176 
    177 {}/**/
    178 //^ - meta.block
    179 
    180 while (true)
    181 // ^^^^^^^^^ meta.while
    182 //     ^^^^ meta.group
    183 {
    184 // <- meta.block
    185     x = yield;
    186 //      ^^^^^ keyword.control.flow.yield
    187 
    188     x = yield * 42;
    189 //      ^^^^^ keyword.control.flow.yield
    190 //            ^ keyword.generator.asterisk
    191 
    192     x = yield
    193     function f() {}
    194     [];
    195 //  ^^ meta.sequence - meta.brackets
    196 
    197 
    198     x = yield*
    199     function f() {}
    200     [];
    201 //  ^^ meta.brackets - meta.sequence
    202 
    203     y = await 42;
    204 //      ^^^^^ keyword.control.flow.await
    205 
    206     y = yield await 42;
    207 //      ^^^^^ keyword.control.flow.yield
    208 //            ^^^^^ keyword.control.flow.await
    209 
    210     yield (parenthesized_expression);
    211 //  ^^^^^ keyword.control.flow.yield
    212 
    213     yield `template`;
    214 //  ^^^^^ keyword.control.flow.yield
    215 
    216     break;
    217 //  ^^^^^ keyword.control.flow.break
    218 
    219     break foo;
    220 //  ^^^^^ keyword.control.flow.break
    221 //        ^^^ variable.label
    222 
    223     break
    224     foo;
    225 //  ^^^ variable.other.readwrite - variable.label
    226 
    227     break/**/foo;
    228 //           ^^^ variable.label - variable.other.readwrite
    229 
    230     break/*
    231     */foo;
    232 //    ^^^ variable.other.readwrite - variable.label
    233 
    234     break function;
    235 //        ^^^^^^^^ invalid.illegal.identifier variable.label
    236 
    237     continue;
    238 //  ^^^^^^^^ keyword.control.flow.continue
    239 
    240     continue foo;
    241 //  ^^^^^^^^ keyword.control.flow.continue
    242 //           ^^^ variable.label
    243 
    244     continue
    245     foo;
    246 //  ^^^ variable.other.readwrite - variable.label
    247 
    248     continue/**/foo;
    249 //              ^^^ variable.label - variable.other.readwrite
    250 
    251     continue/*
    252     */ foo;
    253 //     ^^^ variable.other.readwrite - variable.label
    254 
    255     goto;
    256 //  ^^^^ variable.other.readwrite - keyword
    257 }
    258 // <- meta.block
    259 
    260     while (true) 42 ;
    261 //  ^^^^^^^^^^^^^ meta.while
    262 //  ^^^^^ keyword.control.loop.while
    263 //        ^^^^^^ meta.group
    264 //        ^ punctuation.section.group.begin
    265 //         ^^^^ constant.language.boolean.true
    266 //             ^ punctuation.section.group.end
    267 //               ^^ meta.number.integer.decimal constant.numeric.value
    268 //                  ^ punctuation.terminator.statement - punctuation.terminator.statement.empty
    269 
    270 while // Incomplete statement
    271     42;
    272 //  ^^ constant.numeric - meta.while
    273 
    274 while(false){}/**/
    275 //            ^ - meta.while
    276 
    277 with (undefined) {
    278 // <- keyword.control.import.with
    279 //^^^^^^^^^^ meta.with
    280 //    ^^^^^^^^^ constant.language.undefined
    281     return;
    282 //  ^^^^^^ meta.with.js meta.block.js keyword.control.flow.return
    283 }
    284 
    285 with // Incomplete statement
    286     42;
    287 //  ^^ constant.numeric - meta.while
    288 
    289 with(false){}/**/
    290 //           ^ - meta.with
    291 
    292 switch ($foo) {
    293 // <- meta.switch.js keyword.control.conditional.switch
    294 // ^^^^^^^^^^^^ meta.switch
    295 //^^^^ keyword.control.conditional.switch
    296 //      ^^^^ meta.group
    297 //            ^ meta.block punctuation.section.block.begin
    298     case foo:
    299     // ^ meta.switch meta.block keyword.control.conditional.case
    300     //      ^ - punctuation.separator.key-value
    301         qux = 1;
    302         break;
    303         // ^ keyword.control.flow.break
    304     case "baz":
    305     // ^ keyword.control.conditional.case
    306     //        ^ - punctuation.separator.key-value string
    307         qux = 2;
    308         break;
    309         // ^ keyword.control.flow.break
    310     default:
    311     // ^ meta.switch meta.block keyword.control.conditional.default
    312     //     ^ - punctuation.separator.key-value
    313         qux = 3;
    314 
    315     case$
    316 //  ^^^^^ - keyword
    317     ;
    318 
    319     default$
    320 //  ^^^^^^^^ - keyword
    321     ;
    322 
    323     case 0: {}
    324     case 1:
    325 //  ^^^^ keyword.control.conditional.case
    326 }
    327 // <- meta.block punctuation.section.block.end
    328 
    329 try {
    330 // <- meta.try keyword.control.exception.try
    331 // ^^ meta.try
    332 //  ^ meta.block
    333     foobar = qux.bar();
    334 //  ^^^^^^^^^^^^^^^^^^^ meta.try meta.block
    335 } catch (e) {
    336 // <- meta.block
    337 //^^^^^^^^^^^^ meta.catch
    338 //^^^^^ keyword.control.exception.catch
    339 //       ^ meta.group
    340 //          ^ meta.block
    341     foobar = 0
    342 //  ^^^^^^^^^^ meta.catch meta.block
    343 } finally {
    344 // <- meta.block
    345 //^^^^^^^^^^ meta.finally
    346 //^^^^^^^ keyword.control.exception.finally
    347 //        ^ meta.block
    348     foobar += 1
    349 //  ^^^^^^^^^^^ meta.finally meta.block
    350 }
    351 // <- meta.block
    352 
    353 switch // Incomplete statement
    354     42;
    355 //  ^^ constant.numeric - meta.switch
    356 
    357 switch(x){}/**/
    358 //         ^^ - meta.switch
    359 
    360 try{}/**/
    361 //   ^ - meta.try
    362 catch{}/**/
    363 //     ^ - meta.catch
    364 finally{}/**/
    365 //       ^ - meta.finally