-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAWK.sublime-syntax
187 lines (187 loc) · 5.55 KB
/
AWK.sublime-syntax
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
178
179
180
181
182
183
184
185
186
187
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: AWK
file_extensions:
- awk
scope: source.awk
contexts:
main:
- include: comment
- include: procedure
- include: pattern
comment:
- match: "#.*"
scope: comment.line.number-sign.awk
builtin-pattern:
- match: \b(BEGINFILE|BEGIN|ENDFILE|END)\b
scope: constant.language.awk
command:
- match: \b(?:next|print|printf)\b
scope: keyword.other.command.awk
- match: \b(?:close|getline|delete|system)\b
scope: keyword.other.command.nawk
- match: \b(?:fflush|nextfile)\b
scope: keyword.other.command.bell-awk
constant:
- include: numeric-constant
- include: string-constant
escaped-char:
- match: '\\(?:[\\abfnrtv/"]|x[0-9A-Fa-f]{2}|[0-7]{3})'
scope: constant.character.escape.awk
expression:
- include: command
- include: function
- include: constant
- include: variable
- include: regexp-in-expression
- include: operator
- include: groupings
function:
- match: \b(?:exp|int|log|sqrt|index|length|split|sprintf|substr)\b
scope: support.function.awk
- match: \b(?:atan2|cos|rand|sin|srand|gsub|match|sub|tolower|toupper)\b
scope: support.function.nawk
- match: \b(?:gensub|strftime|systime)\b
scope: support.function.gawk
function-definition:
- match: \b(function)\s+(\w+)(\()
captures:
1: storage.type.function.awk
2: entity.name.function.awk
3: punctuation.definition.parameters.begin.awk
push:
- match: \)
captures:
0: punctuation.definition.parameters.end.awk
pop: true
- match: \b(\w+)\b
scope: variable.parameter.function.awk
- match: \b(,)\b
scope: punctuation.separator.parameters.awk
groupings:
- match: \(
scope: meta.brace.round.awk
- match: \)
scope: meta.brace.round.awk
- match: \,
scope: punctuation.separator.parameters.awk
keyword:
- match: \b(?:break|continue|do|while|exit|for|if|else|return)\b
scope: keyword.control.awk
numeric-constant:
- match: '\b[0-9]+(?:\.[0-9]+)?(?:e[+-][0-9]+)?\b'
scope: constant.numeric.awk
operator:
- match: "(!?~|[=<>!]=|[<>])"
scope: keyword.operator.comparison.awk
- match: \b(in)\b
scope: keyword.operator.comparison.awk
- match: '([+\-*/%^]=|\+\+|--|>>|=)'
scope: keyword.operator.assignment.awk
- match: (\|\||&&|!)
scope: keyword.operator.boolean.awk
- match: '([+\-*/%^])'
scope: keyword.operator.arithmetic.awk
- match: "([?:])"
scope: keyword.operator.trinary.awk
- match: '(\[|\])'
scope: keyword.operator.index.awk
pattern:
- include: regexp-as-pattern
- include: function-definition
- include: builtin-pattern
- include: expression
procedure:
- match: '\{'
push:
- match: '\}'
pop: true
- include: comment
- include: procedure
- include: keyword
- include: expression
regex-as-assignment:
- match: '([^=<>!+\-*/%^]=)\s*(/)'
captures:
1: keyword.operator.assignment.awk
2: punctuation.definition.regex.begin.awk
push:
- meta_content_scope: string.regexp
- match: /
captures:
0: punctuation.definition.regex.end.awk
pop: true
- include: scope:source.regexp
regex-as-comparison:
- match: (!?~)\s*(/)
captures:
1: keyword.operator.comparison.awk
2: punctuation.definition.regex.begin.awk
push:
- meta_content_scope: string.regexp
- match: /
captures:
0: punctuation.definition.regex.end.awk
pop: true
- include: scope:source.regexp
regex-as-first-argument:
- match: (\()\s*(/)
captures:
1: meta.brace.round.awk
2: punctuation.definition.regex.begin.awk
push:
- meta_content_scope: string.regexp
- match: /
captures:
0: punctuation.definition.regex.end.awk
pop: true
- include: scope:source.regexp
regex-as-nth-argument:
- match: (,)\s*(/)
captures:
1: punctuation.separator.parameters.awk
2: punctuation.definition.regex.begin.awk
push:
- meta_content_scope: string.regexp
- match: /
captures:
0: punctuation.definition.regex.end.awk
pop: true
- include: scope:source.regexp
regexp-as-pattern:
- match: /
captures:
0: punctuation.definition.regex.begin.awk
push:
- meta_content_scope: string.regexp
- match: /
captures:
0: punctuation.definition.regex.end.awk
pop: true
- include: scope:source.regexp
regexp-in-expression:
- include: regex-as-assignment
- include: regex-as-comparison
- include: regex-as-first-argument
- include: regex-as-nth-argument
string-constant:
- match: '"'
captures:
0: punctuation.definition.string.begin.awk
push:
- meta_scope: string.quoted.double.awk
- match: '"'
captures:
0: punctuation.definition.string.end.awk
pop: true
- include: escaped-char
variable:
- match: '\$[0-9]+'
scope: variable.language.awk
- match: \b(?:FILENAME|FS|NF|NR|OFMT|OFS|ORS|RS)\b
scope: variable.language.awk
- match: \b(?:ARGC|ARGV|CONVFMT|ENVIRON|FNR|RLENGTH|RSTART|SUBSEP)\b
scope: variable.language.nawk
- match: \b(?:ARGIND|ERRNO|FIELDWIDTHS|IGNORECASE|RT)\b
scope: variable.language.gawk