lectures.alex.balgavy.eu

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

Regular Expressions (JavaScript).sublime-syntax (4394B)


      1 %YAML 1.2
      2 ---
      3 name: Regular Expressions (Javascript)
      4 scope: source.regexp.js
      5 hidden: true
      6 variables:
      7   identifier: '[_$[:alpha:]][_$[:alnum:]]*'
      8 contexts:
      9   main:
     10     - include: anchor
     11     - include: backref
     12     - include: quantifier
     13     - include: operator
     14     - include: group-assertion
     15     - include: group-definition
     16     - include: character-class
     17     - include: character-class-definition
     18 
     19   anchor:
     20     - match: '\\[bB]|\^|\$'
     21       scope: keyword.control.anchor.regexp
     22 
     23   backref:
     24     - match: '\\[1-9][0-9]*'
     25       scope: keyword.other.back-reference.regexp
     26 
     27     - match: (\\k)(<)({{identifier}})(>)
     28       captures:
     29         1: keyword.other.back-reference.regexp
     30         2: punctuation.definition.group.named.begin.regexp
     31         3: variable.other.group.regexp
     32         4: punctuation.definition.group.named.end.regexp
     33 
     34   character-class:
     35     - match: '\\[wWsSdD]|\.'
     36       scope: constant.other.character-class.escape.backslash.regexp
     37     - match: '(\\[pP])(\{)([[:alpha:]_]+)(?:(=)([[:alpha:]_]+)?)?(\})'
     38       captures:
     39         1: constant.other.character-class.escape.unicode-property.regexp
     40         2: punctuation.definition.unicode-property.begin.regexp
     41         3: support.constant.unicode-property.regexp
     42         4: punctuation.separator.key-value.unicode-property.regexp
     43         5: support.constant.unicode-property.regexp
     44         6: punctuation.definition.unicode-property.end.regexp
     45     - match: '\\([trnvf0\\]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.)'
     46       scope: constant.character.escape.backslash.regexp
     47 
     48   character-class-definition:
     49     - match: '(\[)(\^)?'
     50       captures:
     51         1: punctuation.definition.character-class.begin.regexp
     52         2: keyword.operator.negation.regexp
     53       push:
     54         - meta_scope: constant.other.character-class.set.regexp
     55         - match: '\]'
     56           scope: punctuation.definition.character-class.end.regexp
     57           pop: true
     58         - match: |-
     59             (?x)
     60             (?:
     61               (\\[wWsSdD]|\.)|
     62               (\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
     63               .
     64             )
     65             (\-)
     66             (?:
     67               (\\[wWsSdD]|\.)|
     68               (\\(?:[trnvf0]|c[A-Z]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|.))|
     69               [^]]
     70             )
     71           scope: constant.other.character-class.range.regexp
     72           captures:
     73             1: constant.other.character-class.escape.backslash.regexp
     74             2: constant.character.escape.backslash.regexp
     75             3: punctuation.definition.range.regexp
     76             4: constant.other.character-class.escape.backslash.regexp
     77             5: constant.character.escape.backslash.regexp
     78         - include: character-class
     79 
     80   group-assertion:
     81     - match: (\()((\?=)|(\?!)|(\?<=)|(\?<!))
     82       captures:
     83         1: punctuation.definition.group.begin.regexp
     84         2: punctuation.definition.group.assertion.regexp
     85         3: meta.assertion.look-ahead.regexp
     86         4: meta.assertion.negative-look-ahead.regexp
     87         5: meta.assertion.look-behind.regexp
     88         6: meta.assertion.negative-look-behind.regexp
     89       push:
     90         - meta_scope: meta.group.assertion.regexp
     91         - match: \)
     92           scope: punctuation.definition.group.end.regexp
     93           pop: true
     94         - include: main
     95 
     96   group-definition:
     97     - match: (\()(?:(\?:)|(\?)(<)({{identifier}})(>))?
     98       captures:
     99         1: punctuation.definition.group.begin.regexp
    100         2: punctuation.definition.group.no-capture.regexp
    101         3: punctuation.definition.group.begin.regexp
    102         4: punctuation.definition.group.named.begin.regexp
    103         5: entity.name.other.group.regexp
    104         6: punctuation.definition.group.named.end.regexp
    105       push:
    106         - meta_scope: meta.group.regexp
    107         - match: \)
    108           scope: punctuation.definition.group.end.regexp
    109           pop: true
    110         - include: main
    111 
    112   operator:
    113     - match: \|
    114       scope: keyword.operator.or.regexp
    115 
    116   quantifier:
    117     - match: '[?*+]\??'
    118       scope: keyword.operator.quantifier.regexp
    119 
    120     - match: '\{(\d+)(?:(,)(\d+)?)?\}'
    121       scope: keyword.operator.quantifier.regexp
    122       captures:
    123         1: constant.literal.numeric.regexp
    124         2: punctuation.separator.comma.regexp
    125         3: constant.literal.numeric.regexp
    126 
    127     - match: \{(,)(\d+)\}
    128       scope: keyword.operator.quantifier.regexp
    129       captures:
    130         1: punctuation.separator.comma.regexp
    131         2: constant.literal.numeric.regexp