61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own PowerShell 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: PowerShell
|
|
file_extensions: [ps1, psm1, psd1, pwsh, powershell]
|
|
scope: source.powershell
|
|
|
|
contexts:
|
|
main:
|
|
- match: '<#'
|
|
scope: punctuation.definition.comment.begin
|
|
push: block0
|
|
- match: '#.*'
|
|
scope: comment.line
|
|
- match: '\$(?:true|false|null)\b'
|
|
scope: constant.language
|
|
- match: '(?i)-(?:eq|ne|gt|ge|lt|le|like|notlike|match|notmatch|contains|notcontains|in|notin|and|or|not|is|isnot|as|replace|split|join|f)\b'
|
|
scope: keyword.operator.word
|
|
- match: '\b[A-Z][a-z]+-[A-Za-z]+\b'
|
|
scope: entity.name.function
|
|
- match: '\$\{?[\w:]+\}?'
|
|
scope: variable.other.powershell
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-sq
|
|
- match: '(?i)\b(?:begin|break|catch|class|continue|data|do|dynamicparam|else|elseif|end|enum|exit|filter|finally|for|foreach|from|function|if|in|param|process|return|switch|throw|trap|try|until|using|while|workflow)\b'
|
|
scope: keyword.control
|
|
- match: '(?i)\b(?:true|false|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: '[-+*/%=<>!&|^~?:]+'
|
|
scope: keyword.operator
|
|
block0:
|
|
- meta_scope: comment.block
|
|
- match: '#>'
|
|
pop: true
|
|
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
|