-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrunoff.cson
212 lines (186 loc) · 5.35 KB
/
runoff.cson
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: "RUNOFF"
scopeName: "text.runoff"
fileTypes: [
"rnb"
"rnc"
"rnd"
"rne"
"rnh"
"rnl"
"rnm"
"rno"
"rnp"
"rns"
"rnt"
"rnx"
"run"
]
patterns: [include: "#main"]
repository:
# Common patterns
main:
patterns: [
{include: "#comment"}
{include: "#underline"}
{include: "#commands"}
{include: "#special-characters"}
]
# Comment lines
comment:
name: "comment.line.runoff"
begin: "^\\.[!*~]"
end: "$"
beginCaptures:
0: name: "punctuation.definition.comment.runoff"
# Single underlined character
underline:
name: "markup.underline.link.runoff"
match: "[^_]\x08(?=_)|(?<=_)\x08[^_]"
# Parameters passed to control lines
arguments:
patterns: [{
name: "constant.numeric.runoff"
match: "[-+]?\\d+(?:\\.\\d+)?"
},{
name: "punctuation.separator.comma.runoff"
match: ","
},{
# Double-quoted string
name: "string.quoted.runoff"
begin: '"'
end: '"'
beginCaptures: 0: name: "punctuation.definition.string.begin.runoff"
endCaptures: 0: name: "punctuation.definition.string.end.runoff"
},{
# Unquoted string
name: "variable.parameter.runoff"
match: "(?!\\.)([^\\s;,]+)"
captures:
0: name: "string.unquoted.runoff"
1: patterns: [include: "#name-innards"]
}]
# Control lines
commands:
name: "meta.control-line.runoff"
begin: "^\x0C*(?=\\.)"
end: "$|;(?!\\.)"
endCaptures:
0: name: "punctuation.terminator.statement.runoff"
patterns: [{
# Trailing comment
name: "comment.line.runoff"
begin: "!"
end: "$"
beginCaptures:
0: name: "punctuation.definition.comment.runoff"
},{
# .if/.endif: Control flow
name: "meta.condition.runoff"
begin: "(?i)(?:^|(?<=;))((\\.)(?:IF|ELSE|ENDIF))(?=$|\\s|;)"
end: "$|(;)|(?=!)"
beginCaptures:
1: name: "keyword.control.runoff"
2: name: "punctuation.definition.function.runoff"
endCaptures:
1: name: "punctuation.terminator.statement.runoff"
patterns: [include: "#arguments"]
},{
# .literal: Monospaced text (DIGITAL Standard Runoff)
contentName: "markup.raw.runoff"
begin: "(?i)((\\.)LITERAL\\s*)(?:$|\\R)"
end: "(?i)((\\.)END\\s+LITERAL)\\b"
beginCaptures:
0: name: "keyword.function.name.runoff"
1: name: "entity.name.function.runoff"
2: name: "punctuation.definition.function.runoff"
endCaptures:
0: name: "keyword.function.name.runoff"
1: name: "entity.name.function.runoff"
2: name: "punctuation.definition.function.runoff"
},{
# .LIT: Literal/monospaced text
contentName: "markup.raw.runoff"
begin: "(?i)((\\.)LIT)\\s*(?:$|\\R)"
end: "(?i)^(?=\\.(?:EL|END\\s+LIT)(?:$|[\\s;!]))"
beginCaptures:
0: name: "keyword.function.name.runoff"
1: name: "entity.name.function.runoff"
2: name: "punctuation.definition.function.runoff"
},{
# "Comment" command (debugging feedback?)
name: "meta.function.debugging-comment.runoff"
begin: "(?i)((\\.)COMMENT)\\b"
end: "$|(;)|(?=!)"
contentName: "string.unquoted.runoff"
beginCaptures:
0: name: "keyword.function.name.runoff"
1: name: "entity.name.function.runoff"
2: name: "punctuation.definition.function.runoff"
endCaptures:
1: name: "punctuation.terminator.statement.runoff"
},{
# Generic command
name: "meta.function.runoff"
begin: "(?i)((\\.)(?:END\\s+)?([^;\\s\\-+]+))"
end: """(?x)
$ | # EOL
(;)?\\s*(?=\\.) | # Followed by another command
(?=;\\s*[^.]) # No more commands, don’t highlight trailing text as arguments
"""
patterns: [include: "#arguments"]
beginCaptures:
0: name: "keyword.function.name.runoff"
1: name: "entity.name.function.runoff"
2: name: "punctuation.definition.function.runoff"
3: patterns: [include: "#name-innards"]
endCaptures:
1: name: "punctuation.terminator.statement.runoff"
}]
# Stuff to highlight inside words (which might also be a chain of commands without spaces)
"name-innards":
patterns: [
{include: "#special-characters"}
{match: "\\.", name: "punctuation.delimiter.period.full-stop.runoff"}
{match: "\\,", name: "punctuation.separator.comma.runoff"}
{match: "\\d+(?=$|\\R|,|\\.(?!\\d))", name: "constant.numeric.runoff"}
]
# Characters which affect processing of printed text
"special-characters":
patterns: [{
# Escaped special character
name: "constant.character.escape.special-character.runoff"
match: "(_)[!^\\\\#&_.]"
captures:
1: name: "punctuation.definition.escape.runoff"
},{
# End of footnote
name: "keyword.operator.end-footnote.runoff"
match: "^!"
},{
# ^ Uppercase next character
# ^^ Uppercase next word
name: "constant.character.escape.uppercase.runoff"
match: "\\^{1,2}"
captures:
0: name: "punctuation.definition.escape.runoff"
},{
# \ Lowercase next character
# \\ Lowercase next word
name: "constant.character.escape.lowercase.runoff"
match: "\\\\{1,2}"
captures:
0: name: "punctuation.definition.escape.runoff"
},{
# & Underline next word
match: "(&)([!^\\\\#&_.]*)(\\S+)"
captures:
1: name: "punctuation.definition.entity.runoff"
2: patterns: [include: "#special-characters"]
3: name: "markup.underline.link.runoff"
},{
# # "Quoted" space (no filling/justification)
name: "constant.character.escape.space.runoff"
match: "#"
captures:
0: name: "punctuation.definition.escape.runoff"
}]