50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Nginx 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: Nginx
|
|
file_extensions: [nginx, conf.nginx, nginxconf]
|
|
scope: source.nginx
|
|
|
|
contexts:
|
|
main:
|
|
- match: '#.*'
|
|
scope: comment.line
|
|
- match: '\$\w+'
|
|
scope: variable.other.nginx
|
|
- match: '\b\d+[kKmMgGsdhwy]?\b'
|
|
scope: constant.numeric
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-sq
|
|
- match: '\b(?:http|server|location|events|upstream|stream|mail|if|map|geo|types|limit_except|include)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:on|off|true|false|default|none|any)\b'
|
|
scope: constant.language
|
|
- match: '^\s*[a-z_][a-z0-9_]*'
|
|
scope: support.function.directive
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
str-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
str-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|