-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.mermaid.state-diagram.js
145 lines (143 loc) · 4.54 KB
/
source.mermaid.state-diagram.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-mermaid>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
dependencies: ['source.mermaid'],
extensions: [],
names: [],
patterns: [{include: '#main'}],
repository: {
'composite-state': {
begin: '^\\s*(state)(?:\\s+([^-:\\s{]+))?\\s*({)',
beginCaptures: {
1: {name: 'storage.type.state.mermaid'},
2: {name: 'variable.state.name.mermaid'},
3: {patterns: [{include: 'source.mermaid#brace'}]}
},
end: '}',
endCaptures: {0: {patterns: [{include: 'source.mermaid#brace'}]}},
name: 'meta.state.composite.mermaid',
patterns: [{include: '#main'}]
},
concurrency: {
match: '--',
name: 'keyword.control.flow.concurrency.mermaid'
},
main: {
patterns: [
{include: 'source.mermaid#a11y'},
{include: 'source.mermaid#directive'},
{include: 'source.mermaid#comment'},
{include: 'source.mermaid#direction'},
{include: '#terminal'},
{include: '#transition'},
{include: '#composite-state'},
{include: '#note'},
{include: '#concurrency'},
{include: '#state'}
]
},
marker: {
captures: {
1: {name: 'punctuation.definition.marker.begin.mermaid'},
2: {name: 'sublimelinter.gutter-mark'},
4: {name: 'punctuation.definition.marker.end.mermaid'},
5: {name: 'sublimelinter.gutter-mark'}
},
match: '((<<))(choice|fork|join)((>>))',
name: 'entity.name.tag.modifier.$2.mermaid'
},
note: {
begin: '^\\s*(note)\\s+((?:left|right)\\s+of)\\s+([^-:\\s{]+)',
beginCaptures: {
1: {name: 'storage.type.note.mermaid'},
2: {name: 'constant.language.note-position.mermaid'},
3: {name: 'variable.state.name.mermaid'}
},
end: '(?!\\G)',
name: 'meta.note.mermaid',
patterns: [
{
begin: '\\G[ \\t]*$',
contentName: 'string.unquoted.note-text.mermaid',
end: '^\\s*(end)\\s+(note)(?=$|\\s)',
endCaptures: {
1: {name: 'keyword.operator.end-note.mermaid'},
2: {name: 'storage.type.note.mermaid'}
}
},
{
begin: '\\G\\s*(:)[ \\t]*',
beginCaptures: {1: {patterns: [{include: 'source.mermaid#colon'}]}},
contentName: 'string.unquoted.note-text.mermaid',
end: '(?=\\s*$)'
}
]
},
state: {
patterns: [
{
begin: '^\\s*(state)(?=$|\\s)[ \\t]*',
beginCaptures: {1: {name: 'storage.type.state.mermaid'}},
end: '(?=\\s*$)',
name: 'meta.state.statement.mermaid',
patterns: [
{
begin: '\\G"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.mermaid'}
},
end: '"',
endCaptures: {
0: {name: 'punctuation.definition.string.end.mermaid'}
},
name: 'string.quoted.double.state-description.mermaid'
},
{
match: '\\G(?:[^-:\\s{%]|%(?!%))++',
name: 'variable.state.name.mermaid'
},
{
begin: '(?<=")\\s*(as)(?=$|\\s)',
beginCaptures: {1: {name: 'keyword.operator.alias.mermaid'}},
end: '[^-:\\s{]+|(?=\\s*(?:$|%%))',
endCaptures: {0: {name: 'variable.state.name.mermaid'}}
},
{include: '#marker'}
]
},
{
begin: '([^-:\\s{]+)\\s*(:)[ \\t]*',
beginCaptures: {
1: {name: 'variable.state.name.mermaid'},
2: {patterns: [{include: 'source.mermaid#colon'}]}
},
contentName: 'string.unquoted.state-description.mermaid',
end: '(?=\\s*(?:$|%%))'
},
{match: '[^-:\\s{]+', name: 'variable.state.name.mermaid'}
]
},
terminal: {
patterns: [
{
match: '\\[\\*\\](?=\\s*-->)',
name: 'constant.language.state.initial.mermaid'
},
{
captures: {1: {name: 'constant.language.state.final.mermaid'}},
match: '(?<=-->)\\s*(\\[\\*\\])'
}
]
},
transition: {match: '-->', name: 'keyword.operator.transition.mermaid'}
},
scopeName: 'source.mermaid.state-diagram'
}
export default grammar