101 lines
3.7 KiB
YAML
101 lines
3.7 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Blade 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: Blade
|
|
file_extensions: [blade.php, blade]
|
|
scope: text.html.blade
|
|
|
|
contexts:
|
|
main:
|
|
- match: '\{\{--'
|
|
scope: comment.block
|
|
push: blade-comment
|
|
- match: '@\{\{'
|
|
scope: constant.character.escape
|
|
- match: '(?<![\w@.])@(?:if|elseif|else|endif|unless|endunless|isset|endisset|empty|endempty|foreach|endforeach|for|endfor|forelse|endforelse|while|endwhile|switch|case|default|endswitch|break|continue|extends|section|endsection|yield|parent|show|include|includeIf|includeWhen|includeUnless|each|component|endcomponent|slot|endslot|props|php|endphp|push|endpush|stack|prepend|endprepend|once|endonce|auth|endauth|guest|endguest|can|endcan|cannot|endcannot|env|endenv|production|endproduction|csrf|method|error|enderror|livewire|vite|json|class|style|checked|selected|disabled|required|readonly|lang|endlang|verbatim|endverbatim|stop|overwrite|inject|use|hasSection|sectionMissing|pushIf|pushOnce|endPushOnce|dd|dump|aware|fragment|endfragment)\b'
|
|
scope: keyword.control
|
|
- match: '\{!!'
|
|
scope: keyword.operator.template.begin
|
|
push: raw
|
|
- match: '\{\{'
|
|
scope: keyword.operator.template.begin
|
|
push: expr
|
|
blade-comment:
|
|
- meta_scope: comment.block
|
|
- match: '--\}\}'
|
|
pop: true
|
|
raw:
|
|
- match: '!!\}'
|
|
scope: keyword.operator.template.end
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: raw-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: raw-sq
|
|
- match: '\b(?:as|new|fn|function|return|instanceof|and|or|xor|echo|print|array|list|static|clone)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|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
|
|
raw-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
raw-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
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: '\b(?:as|new|fn|function|return|instanceof|and|or|xor|echo|print|array|list|static|clone)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|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
|
|
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
|