Repository navigation
Expand file tree
/
Copy pathagg.sublime-syntax
More file actions
177 lines (151 loc) · 6.84 KB
/
Copy pathagg.sublime-syntax
File metadata and controls
177 lines (151 loc) · 6.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
%YAML 1.2
---
# Sublime Text colorer for DecL, the second hand-maintained mirror of
# src/aggregate/decl.lark (the first is src/aggregate/decl_pygments.py).
# tests/test_grammar_sync.py asserts that the reserved words named here are
# exactly the grammar's, so adding a keyword to decl.lark fails the suite until
# this file follows.
name: DecL
file_extensions:
- agg
- decl
scope: source.decl
variables:
name_char: '[a-zA-Z0-9._:~\-]'
name_tail: '[._:~a-zA-Z0-9\-]*'
# The grammar's own word boundary. NOT \b: `.` `_` `:` `~` and `-` are all
# name characters in DecL, so \b would peel `loss` off `loss-ratio`.
keyword_boundary: '(?![a-zA-Z0-9._:~\-])'
contexts:
prototype:
- include: comments
main:
- include: trailer
- include: strings
- include: builtins
- include: keywords
- include: frequencies
- include: discrete
- include: operators
- include: identifiers
- include: numbers
# note{...} / tags{...} / hints{...} / doc{{{...}}}, the four trailer clauses.
trailer:
- match: '\b(note)(\{)'
captures:
1: keyword.other.note.decl
2: punctuation.section.braces.begin.decl
push:
- meta_content_scope: comment.block.note.decl
- match: '\}'
scope: punctuation.section.braces.end.decl
pop: true
- match: '\b(tags)(\{)'
captures:
1: keyword.other.tags.decl
2: punctuation.section.braces.begin.decl
push:
- match: '\}'
scope: punctuation.section.braces.end.decl
pop: true
- match: '[,;:]'
scope: punctuation.separator.decl
- match: '[^}:,;\s]+'
scope: entity.other.attribute-name.tag.decl
- match: '\b(hints)(\{)'
captures:
1: keyword.other.hints.decl
2: punctuation.section.braces.begin.decl
push:
- match: '\}'
scope: punctuation.section.braces.end.decl
pop: true
# Any key, known or not. Mirroring underwriter._HINT_KEYS here would
# create a third copy to keep in sync for no visual gain.
- match: '\b[a-zA-Z][._:~a-zA-Z0-9\-]*\b(?=\s*=)'
scope: variable.parameter.hints.decl
- match: '='
scope: keyword.operator.assignment.decl
- match: ';'
scope: punctuation.separator.decl
- match: '\b(?:True|False|None)\b'
scope: constant.language.decl
- include: numbers
- include: identifiers
# doc{{{...}}} in the preprocessed form: the body has been lifted out and
# replaced with URL-safe base64, so it is opaque and sits on one line.
- match: '\b(doc)(\{\{\{)([A-Za-z0-9_=\-]*)(\}\}\})'
captures:
1: keyword.other.doc.decl
2: punctuation.section.block.begin.decl
3: comment.block.documentation.decl
4: punctuation.section.block.end.decl
# doc{{{...}}} in source form: the opening fence ends its line, the body is
# markdown, and the closing fence is alone on its line.
- match: '\b(doc)(\{\{\{)[ \t]*$'
captures:
1: keyword.other.doc.decl
2: punctuation.section.block.begin.decl
embed: scope:text.html.markdown
escape: '^[ \t]*(\}\}\})'
escape_captures:
1: punctuation.section.block.end.decl
builtins:
- match: '\bagg\.[a-zA-Z][._:~a-zA-Z0-9\-]*'
scope: support.type.builtin.aggregate.decl
- match: '\bport\.[a-zA-Z][._:~a-zA-Z0-9\-]*'
scope: support.type.builtin.portfolio.decl
- match: '\bsev\.[a-zA-Z][._:~a-zA-Z0-9\-]*'
scope: support.type.builtin.severity.decl
- match: '\b(?:distortion|dist)\.[a-zA-Z][._:~a-zA-Z0-9\-]*'
scope: support.type.builtin.distortion.decl
keywords:
- match: '\b(?:aad|aggregate|agglimit|agg|and|approximate|approx|as|at|basic|bivariate|bv|cede|ceded|clash|claims|claim|copula|corridor|cv|deposit|derive|disappearing|distortion|dist|exposure|expenses|expense|exp|franchise|free|grossceded|grossnet|inherit|lcm|less|loss|lr|max|min|mixed|netceded|net|no|occurrence|of|payoff|pc|peel|picks|pnl|xpnl|po|port|premium|prem|rate|reinstatements|reinstatement|retro|rol|sev|slide|splice|ssev|swing|to|tower|tweedie|after|wait|wts|xps|xs|years|year|zm|zt){{keyword_boundary}}'
scope: keyword.control.decl
frequencies:
- match: '\b(?:binomial|pascal|poisson|bernoulli|geometric|fixed|neymanA|neymana|neyman|logarithmic|negbin){{keyword_boundary}}'
scope: support.function.frequency.decl
# The discrete declaration heads. dfreq belongs with its dsev siblings, not
# with the frequency DISTRIBUTION names above: it declares an outcome and
# probability pair, it is not a named distribution.
discrete:
- match: '\b(?:dfreq|dsev|dbvsev|dwait|nttagg){{keyword_boundary}}'
scope: storage.type.discrete.decl
operators:
- match: '\*\*|\^'
scope: keyword.operator.exponent.decl
- match: '@'
scope: keyword.operator.inhomogeneous-multiply.decl
- match: '[+\-*/=]'
scope: keyword.operator.arithmetic.decl
- match: ':'
scope: keyword.operator.range.decl
- match: '[\[\]()]'
scope: punctuation.section.brackets.decl
# Comma and pipe are whitespace to the parser (%ignore), but they read as
# separators. The backslash is NOT here: line continuation was removed from
# the language, so a stray backslash must show as an error.
- match: '[,|;]'
scope: punctuation.separator.decl
- match: '!'
scope: keyword.operator.unconditional.decl
identifiers:
# Mirrors the Lark ID token. Placing this before numbers prevents
# names such as mydist.1 from splitting and coloring .1 as a number.
- match: '\b(?!agg\.|sev\.|dist\.|distortion\.|port\.)(?!(?:aad|agg|aggregate|agglimit|and|as|approximate|approx|at|bernoulli|binomial|bivariate|bv|cede|ceded|claim|claims|clash|copula|cv|dbvsev|deposit|derive|dfreq|disappearing|dist|distortion|dsev|dwait|exp|expense|expenses|exposure|fixed|franchise|free|geometric|grossceded|grossnet|inherit|less|logarithmic|loss|lr|mixed|negbin|net|netceded|neyman|neymana|neymanA|no|nttagg|occurrence|of|pascal|payoff|peel|picks|pnl|xpnl|po|poisson|port|prem|premium|rate|reinstatements|reinstatement|rol|sev|splice|ssev|to|tower|tweedie|wait|wts|xps|xs|years|year|zm|zt|after|basic|corridor|lcm|max|min|pc|retro|slide|swing)(?![a-zA-Z0-9._:~\-]))[a-zA-Z][._:~a-zA-Z0-9\-]*'
scope: variable.other.identifier.decl
numbers:
- match: '(?<![a-zA-Z0-9._:~\-])-?(?:inf{{keyword_boundary}}|(?:\d(?:_?\d)*\.?(?:\d(?:_?\d)*)?|\.\d(?:_?\d)*)(?:[eE][+\-]?\d(?:_?\d)*)?%?)'
scope: constant.numeric.decl
strings:
# A quoted display label: no escapes and no embedded newline, matching the
# grammar's STRING terminal.
- match: '"[^"\n]*"'
scope: string.quoted.double.decl
comments:
- match: '(?:#|//)'
scope: punctuation.definition.comment.decl
push:
- meta_scope: comment.line.decl
- match: '$\n?'
pop: true