79 lines
2.6 KiB
YAML
79 lines
2.6 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Dart 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: Dart
|
|
file_extensions: [dart]
|
|
scope: source.dart
|
|
|
|
contexts:
|
|
main:
|
|
- match: '/\*'
|
|
scope: punctuation.definition.comment.begin
|
|
push: block0
|
|
- match: '//.*'
|
|
scope: comment.line
|
|
- match: '@\w+'
|
|
scope: entity.other.attribute-name
|
|
- match: ''''''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-tsq
|
|
- match: '"""'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-tdq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-sq
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: '\b(?:abstract|as|assert|async|await|base|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extends|extension|external|factory|final|finally|for|Function|get|hide|if|implements|import|in|interface|is|late|library|mixin|new|on|operator|part|required|rethrow|return|sealed|set|show|static|super|switch|sync|this|throw|try|typedef|var|void|when|while|with|yield)\b'
|
|
scope: keyword.control
|
|
- match: '\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: '\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
|
|
block0:
|
|
- meta_scope: comment.block
|
|
- match: '\*/'
|
|
pop: true
|
|
str-tsq:
|
|
- meta_scope: string.quoted.triple-single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
str-tdq:
|
|
- meta_scope: string.quoted.triple
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"""'
|
|
scope: punctuation.definition.string.end
|
|
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
|
|
str-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|