-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
minilogo.monarch.ts
30 lines (29 loc) · 1.2 KB
/
minilogo.monarch.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
// Monarch syntax highlighting for the minilogo language.
export default {
keywords: [
'color','def','down','for','move','pen','to','up'
],
operators: [
'*','+',',','-','/','='
],
symbols: /\(|\)|\*|\+|,|-|\/|=|\{|\}/,
tokenizer: {
initial: [
{ regex: /#(\d|[a-fA-F]){3,6}/, action: {"token":"string"} },
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"string"} }} },
{ regex: /(?:(?:-?[0-9]+)?\.[0-9]+)|-?[0-9]+/, action: {"token":"number"} },
{ 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"} },
],
comment: [
{ regex: /[^/\*]+/, action: {"token":"comment"} },
{ regex: /\*\//, action: {"token":"comment","next":"@pop"} },
{ regex: /[/\*]/, action: {"token":"comment"} },
],
}
};