forked from
stavola.xyz/mlf
A human-friendly DSL for ATProto Lexicons
1%YAML 1.2
2---
3name: MLF
4file_extensions:
5 - mlf
6scope: source.mlf
7
8contexts:
9 main:
10 - include: comments
11 - include: annotations
12 - include: keywords
13 - include: types
14 - include: strings
15 - include: numbers
16 - include: operators
17
18 comments:
19 - match: '///'
20 scope: punctuation.definition.comment.mlf
21 push:
22 - meta_scope: comment.line.documentation.mlf
23 - match: $
24 pop: true
25 - match: '//'
26 scope: punctuation.definition.comment.mlf
27 push:
28 - meta_scope: comment.line.double-slash.mlf
29 - match: $
30 pop: true
31
32 annotations:
33 # Annotation with selectors and args: @rust,typescript:deprecated(true)
34 - match: '@([a-zA-Z_][a-zA-Z0-9_]*(?:,[a-zA-Z_][a-zA-Z0-9_]*)*):([a-zA-Z_][a-zA-Z0-9_]*)'
35 scope: meta.annotation.mlf
36 captures:
37 1: entity.name.namespace.mlf
38 2: entity.name.function.annotation.mlf
39 push:
40 - match: '\('
41 scope: punctuation.section.arguments.begin.mlf
42 set:
43 - meta_scope: meta.annotation.arguments.mlf
44 - match: '\)'
45 scope: punctuation.section.arguments.end.mlf
46 pop: true
47 - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*(:)'
48 captures:
49 1: variable.parameter.mlf
50 2: punctuation.separator.mlf
51 - include: strings
52 - include: numbers
53 - match: '\b(true|false)\b'
54 scope: constant.language.mlf
55 - match: ','
56 scope: punctuation.separator.mlf
57 - match: '(?=\S)'
58 pop: true
59 # Bare annotation with args: @deprecated(true)
60 - match: '@([a-zA-Z_][a-zA-Z0-9_]*)'
61 scope: meta.annotation.mlf
62 captures:
63 1: entity.name.function.annotation.mlf
64 push:
65 - match: '\('
66 scope: punctuation.section.arguments.begin.mlf
67 set:
68 - meta_scope: meta.annotation.arguments.mlf
69 - match: '\)'
70 scope: punctuation.section.arguments.end.mlf
71 pop: true
72 - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*(:)'
73 captures:
74 1: variable.parameter.mlf
75 2: punctuation.separator.mlf
76 - include: strings
77 - include: numbers
78 - match: '\b(true|false)\b'
79 scope: constant.language.mlf
80 - match: ','
81 scope: punctuation.separator.mlf
82 - match: '(?=\S)'
83 pop: true
84
85 keywords:
86 - match: '\b(namespace|use|as|record|inline|def|type|token|query|procedure|subscription|throws|constrained|error)\b'
87 scope: keyword.control.mlf
88 - match: '\b(main|defs)\b'
89 scope: keyword.other.mlf
90
91 types:
92 # Primitive types
93 - match: '\b(null|boolean|integer|string|bytes|blob|unknown)\b'
94 scope: storage.type.builtin.mlf
95
96 # Format types
97 - match: '\b(Datetime|Uri|AtUri|Did|Handle|Nsid|Cid|AtIdentifier|Language|Tid|RecordKey)\b'
98 scope: storage.type.format.mlf
99
100 # User-defined types (capitalized identifiers)
101 - match: '\b[A-Z][a-zA-Z0-9_]*\b'
102 scope: entity.name.type.mlf
103
104 strings:
105 - match: '"'
106 scope: punctuation.definition.string.begin.mlf
107 push:
108 - meta_scope: string.quoted.double.mlf
109 - match: '\\.'
110 scope: constant.character.escape.mlf
111 - match: '"'
112 scope: punctuation.definition.string.end.mlf
113 pop: true
114
115 numbers:
116 - match: '\b\d+\b'
117 scope: constant.numeric.integer.mlf
118
119 operators:
120 - match: '[{}()\[\]]'
121 scope: punctuation.section.mlf
122 - match: '[,;:.]'
123 scope: punctuation.separator.mlf
124 - match: '!'
125 scope: keyword.operator.required.mlf
126 - match: '\|'
127 scope: keyword.operator.union.mlf
128 - match: '\*'
129 scope: keyword.operator.wildcard.mlf
130 - match: '='
131 scope: keyword.operator.assignment.mlf