72 lines
2.1 KiB
YAML
72 lines
2.1 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own EJS grammar. Original work written for this project; not copied
|
|
# from any other grammar. Regexes stay linear: no nested quantifiers, so nothing backtracks far.
|
|
# Strings end at their line unless the language allows multi-line ones.
|
|
name: EJS
|
|
file_extensions: [ejs]
|
|
scope: text.html.ejs
|
|
|
|
contexts:
|
|
main:
|
|
- match: '<%#'
|
|
scope: keyword.operator.template.begin comment.block
|
|
push: ejs-comment
|
|
- match: '<%%'
|
|
scope: constant.character.escape
|
|
- match: '<%[-=_]?'
|
|
scope: keyword.operator.template.begin
|
|
push: expr
|
|
ejs-comment:
|
|
- meta_scope: comment.block
|
|
- match: '[-_]?%>'
|
|
pop: true
|
|
expr:
|
|
- match: '[-_]?%>'
|
|
scope: keyword.operator.template.end
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: expr-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: expr-sq
|
|
- match: '`'
|
|
scope: punctuation.definition.string.begin
|
|
push: expr-bt
|
|
- match: '\b(?:var|let|const|if|else|for|while|do|switch|case|default|break|continue|return|function|new|typeof|instanceof|in|of|try|catch|finally|throw|await|async|include|forEach|this)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|undefined)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '[-+*/%=<>!&|^~?:.,]+'
|
|
scope: keyword.operator
|
|
expr-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
expr-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
expr-bt:
|
|
- meta_scope: string.quoted.backtick
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '`'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|