-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntax-custom.ts
39 lines (38 loc) · 2.08 KB
/
syntax-custom.ts
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
// Monarch syntax highlighting for the open-api-sl language.
export default {
keywords: [
'alias','array','at','binary','body','byte','cookie','date','date-time','default','delete','double','endpoints','extends','float','get','header','int32','int64','integer','meta','mul','number','password','patch','path','post','put','query','string','type','types','union'
],
operators: [
',',':','<','=','=>','>','?','|'
],
symbols: /\(|\)|,|:|<|=|=>|>|\?|\[|\]|\{|\||\}/,
tokenizer: {
initial: [
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"ID"} }} },
{ regex: /[0-9]+/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"number"} }} },
{ regex: /-\d+((\.\d+)?([eE][\-+]?\d+)?)?/, action: {"token":"number"} },
{ regex: /\d+((\.\d+)?([eE][\-+]?\d+)?)?/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"number"} }} },
{ regex: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/, action: {"token":"string"} },
{ include: '@whitespace' },
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
],
whitespace: [
{ regex: /\s+/, action: {"token":"white"} },
{ regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
{ regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
{ regex: /-- [^\n\r]*/, action: { "token": "comment.doc" } },
{ regex: /\/\-(?!\/)/, action: { "token" : 'comment.doc', "next": '@apidoc' } },
],
comment: [
{ regex: /[^/\*]+/, action: {"token":"comment"} },
{ regex: /\*\//, action: {"token":"comment","next":"@pop"} },
{ regex: /[/\*]/, action: {"token":"comment"} },
],
apidoc: [
{ regex: /[^\/-]+/, action: { token: 'comment.doc' }},
{ regex: /\-\//, action: { token: 'comment.doc', "next": '@pop'} },
{ regex: /[\/-]/, action: { token: 'comment.doc'} }
],
}
};