-
Notifications
You must be signed in to change notification settings - Fork 2
/
tree-sitter-dot.ebnf
83 lines (60 loc) · 1.32 KB
/
tree-sitter-dot.ebnf
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
//
// From tree-sitter-dot/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
[sS][tT][rR][iI][cC][tT]? ( [gG][rR][aA][pP][hH] | [dD][iI][gG][rR][aA][pP][hH] ) id? block
block ::=
'{' stmt_list? '}'
stmt_list ::=
( _stmt ';'? )+
_stmt ::=
subgraph
| node_stmt
| edge_stmt
| attr_stmt
| attribute
subgraph ::=
( [sS][uU][bB][gG][rR][aA][pP][hH] id? )? block
node_stmt ::=
node_id attr_list?
edge_stmt ::=
( node_id | subgraph ) ( edgeop ( node_id | subgraph ) )+ attr_list?
attr_stmt ::=
( [gG][rR][aA][pP][hH] | [nN][oO][dD][eE] | [eE][dD][gG][eE] ) attr_list
node_id ::=
id port?
port ::=
':' id ( ':' id )?
attr_list ::=
( '[' _a_list? ']' )+
_a_list ::=
( attribute ( ';' | ',' )? )+
attribute ::=
id '=' id
id ::=
identifier
| number_literal
| html_string
| string_literal ( '+' string_literal )*
identifier ::=
[_\p{XID_Start}][_\p{XID_Continue}]*
number_literal ::=
'-'?('.'[0-9]+|[0-9]+('.'[0-9]*)?)
string_literal ::=
'"' ([^"\]+|'\.')*'"'
html_string ::=
'<' _html_internal? '>'
_html_internal ::=
( [^<>]+ | '<' _html_internal? '>' )+
edgeop ::=
'->'
| '--'
comment ::=
( '//' '.'* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' )
preproc ::=
'#' '.'*