/
Dot.rsc
105 lines (72 loc) · 2.72 KB
/
Dot.rsc
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
@license{
Copyright (c) 2009-2013 CWI
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
}
@contributor{Bert Lisser - Bert.Lisser@cwi.nl}
module lang::dot::\syntax::Dot
start syntax DOT = LAYOUT* Graph Id "{" StatementList "}" "\n"?;
keyword Reserved = "graph"|"digraph"|"node"|"edge"|"subgraph";
syntax Graph = "graph"|"digraph"|AttrTag;
syntax AttrTag = "node"|"edge"|"graph";
syntax Nod = NodeId|Subgraph;
lexical Id = ([A-Z a-z 0-9 _] !<< [A-Z a-z 0-9 _]+ !<< [a-z A-Z 0-9 _][a-z A-Z 0-9 _]* !>> [0-9 A-Z _ a-z]) \ Reserved
| [\"] (![\"] | "\\\"")* [\"]
| [\-]? "." [0-9]+
| [\-]? [0-9]+ "." [0-9]*
;
syntax StatementList = StatementOptional*;
syntax Statement = NodeStatement
|EdgeStatement
|AttrStatement
>Id "=" Id
;
syntax StatementOptional = Statement ";"?;
syntax NodeStatement = Nod AttrList;
syntax EdgeStatement = Nod EdgeRhs AttrList ;
syntax Edg = EdgeOp Nod;
syntax EdgeOp = "-\>" | "--";
syntax EdgeRhs = Edg+;
syntax NodeId = Id
| Id Port
;
syntax Port = ":" Id Id?
// | ":" Id
// | ":" CompassPt
;
// syntax CompassPt = "n" | "ne" | "e" | "se" | "s" | "sw" | "w"| "nw" | "c" |"_";
syntax AttrList = AttrList0*;
syntax AttrList0 = "[" DotAttr* "]";
syntax DotAttr = Id "=" Id | Id "=" Id "," ;
syntax AttrStatement = AttrTag AttrList;
syntax Subgraph = ("subgraph" Id? )? "{" StatementList "}";
lexical Comment = "/*" (![*] | [*] !>> "/")* "*/"
| "//" ![\n]* $
;
layout LAYOUTLIST = LAYOUT* !>> [\ \t\n\r] !>> "//" !>> "/*"
;
lexical LAYOUT = Whitespace: [\ \t\n\r]
| @category="Comment" Comment
;
/*
graph : [ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'
stmt_list : [ stmt [ ';' ] [ stmt_list ] ]
stmt : node_stmt
| edge_stmt
| attr_stmt
| ID '=' ID
| subgraph
attr_stmt : (graph | node | edge) attr_list
attr_list : '[' [ a_list ] ']' [ attr_list ]
a_list : ID [ '=' ID ] [ ',' ] [ a_list ]
edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
node_stmt : node_id [ attr_list ]
node_id : ID [ port ]
port : ':' ID [ ':' compass_pt ]
| ':' compass_pt
subgraph : [ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt : (n | ne | e | se | s | sw | w | nw | c | _)
*/