52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own INI 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: INI
|
|
file_extensions: [ini, cfg, conf, inf, editorconfig, desktop, gitconfig]
|
|
scope: source.ini
|
|
|
|
contexts:
|
|
main:
|
|
- match: '[;#].*'
|
|
scope: comment.line
|
|
- match: '^\s*\[[^\]\n]*\]?'
|
|
scope: entity.name.tag
|
|
- match: '^\s*[^=;#\[\s][^=\n]*?(?=\s*[=:])'
|
|
scope: meta.mapping.key
|
|
- match: '[=:]'
|
|
scope: keyword.operator
|
|
push: value
|
|
value:
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: value-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: value-sq
|
|
- match: '(?i)\b(?:true|false|yes|no|on|off|null)\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: '\s[;#].*'
|
|
scope: comment.line
|
|
value-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
value-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|