56 lines
2.0 KiB
YAML
56 lines
2.0 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Zig 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: Zig
|
|
file_extensions: [zig, zon]
|
|
scope: source.zig
|
|
|
|
contexts:
|
|
main:
|
|
- match: '//.*'
|
|
scope: comment.line
|
|
- match: '@\w+'
|
|
scope: support.function.builtin
|
|
- match: '\\\\.*'
|
|
scope: string.unquoted.multiline
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-sq
|
|
- match: '\b(?:addrspace|align|allowzero|and|anyframe|anytype|asm|async|await|break|callconv|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|noalias|nosuspend|opaque|or|orelse|packed|pub|resume|return|struct|suspend|switch|test|threadlocal|try|union|unreachable|usingnamespace|var|volatile|while)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|undefined)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:bool|void|type|noreturn|anyerror|usize|isize|comptime_int|comptime_float|c_int|c_uint|[iuf]\d+)\b'
|
|
scope: support.type
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '\b[A-Za-z_]\w*(?=\s*\()'
|
|
scope: entity.name.function
|
|
- match: '\b[A-Z][A-Za-z0-9_]*\b'
|
|
scope: entity.name.type
|
|
- match: '[-+*/%=<>!&|^~?:]+'
|
|
scope: keyword.operator
|
|
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
|