-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.mermaid.er-diagram.js
79 lines (77 loc) · 3.28 KB
/
source.mermaid.er-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
// 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: {
attribute: {
captures: {
1: {name: 'storage.type.attribute.mermaid'},
2: {name: 'entity.name.attribute.mermaid'},
3: {name: 'constant.language.other.key-type.mermaid'},
4: {patterns: [{include: '#string'}]}
},
match:
'(?x)\n((?=[a-zA-Z])[-\\w]+) # Attribute type\n\\s+\n((?=[a-zA-Z])[-\\w]+) # Attribute name\n(?:\\s+ (PK|FK))? # Primary/foreign key\n(?:\\s* ("[^"]*"))? # Comment',
name: 'meta.attribute.mermaid'
},
attributes: {
begin: '((?=[a-zA-Z])[-\\w]+)\\s*({)',
beginCaptures: {
1: {name: 'entity.name.assignee.mermaid'},
2: {patterns: [{include: 'source.mermaid#brace'}]}
},
end: '}',
endCaptures: {0: {patterns: [{include: 'source.mermaid#brace'}]}},
name: 'meta.attributes.mermaid',
patterns: [
{include: '#attribute'},
{include: 'source.mermaid#a11y'},
{include: 'source.mermaid#directive'},
{include: 'source.mermaid#comment'}
]
},
main: {
patterns: [
{include: 'source.mermaid#a11y'},
{include: 'source.mermaid#directive'},
{include: 'source.mermaid#comment'},
{include: '#attributes'},
{include: '#relationship'}
]
},
relationship: {
captures: {
1: {name: 'entity.name.operand.first.mermaid'},
2: {name: 'keyword.operator.cardinality.mermaid'},
3: {name: 'entity.name.operand.second.mermaid'},
4: {patterns: [{include: 'source.mermaid#colon'}]},
5: {patterns: [{include: '#string'}]},
6: {name: 'string.unquoted.label-text.mermaid'},
7: {name: 'invalid.illegal.unexpected-characters.mermaid'}
},
match:
'(?x)\n((?=[a-zA-Z])[-\\w]+) # Entity 1\n\n(?:\n\t\\s*\n\t# Cardinality configuration thingie\n\t(\n\t\t# Entity 1\'s cardinality\n\t\t(?: \\|o # Zero or one\n\t\t| \\|\\| # Exactly one\n\t\t| }o # Zero or more\n\t\t| }\\| # One or more\n\t\t)\n\t\t\n\t\t# Stroke style\n\t\t(?: -- # Solid\n\t\t| \\.\\. # Dashed\n\t\t)\n\t\t\n\t\t# Entity 2\'s cardinality\n\t\t(?: o\\| # Zero or one\n\t\t| \\|\\| # Exactly one\n\t\t| o{ # Zero or more\n\t\t| \\|{ # One or more\n\t\t)\n\t)\n\t\\s*\n\t((?=[a-zA-Z])[-\\w]+) # Entity 2\n\t\n\t# Relationship label\n\t\\s* (:) \\s*\n\t(?: ("[^"]*") # Quoted\n\t| ((?=[a-zA-Z])[-\\w]+) # Unquoted\n\t| ((?:[^\\s%]|%(?!%))+) # Invalid\n\t)?\n)?',
name: 'meta.relationship.mermaid'
},
string: {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.mermaid'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.mermaid'}},
name: 'string.quoted.double.label-text.mermaid',
patterns: [{include: 'source.mermaid#entity'}]
}
},
scopeName: 'source.mermaid.er-diagram'
}
export default grammar