flowink 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,635 @@
1
+ /** mermaid
2
+ * https://mermaidjs.github.io/
3
+ * (c) 2015 Knut Sveidqvist
4
+ * MIT license.
5
+ */
6
+
7
+ /* lexical grammar */
8
+ %lex
9
+ %x string
10
+ %x md_string
11
+ %x acc_title
12
+ %x acc_descr
13
+ %x acc_descr_multiline
14
+ %x dir
15
+ %x vertex
16
+ %x text
17
+ %x ellipseText
18
+ %x trapText
19
+ %x edgeText
20
+ %x thickEdgeText
21
+ %x dottedEdgeText
22
+ %x click
23
+ %x href
24
+ %x callbackname
25
+ %x callbackargs
26
+ %x shapeData
27
+ %x shapeDataStr
28
+ %x shapeDataEndBracket
29
+
30
+ %%
31
+ accTitle\s*":"\s* { this.begin("acc_title");return 'acc_title'; }
32
+ <acc_title>(?!\n|;|#)*[^\n]* { this.popState(); return "acc_title_value"; }
33
+ accDescr\s*":"\s* { this.begin("acc_descr");return 'acc_descr'; }
34
+ <acc_descr>(?!\n|;|#)*[^\n]* { this.popState(); return "acc_descr_value"; }
35
+ accDescr\s*"{"\s* { this.begin("acc_descr_multiline");}
36
+ <acc_descr_multiline>[\}] { this.popState(); }
37
+ <acc_descr_multiline>[^\}]* return "acc_descr_multiline_value";
38
+ // <acc_descr_multiline>.*[^\n]* { return "acc_descr_line"}
39
+
40
+
41
+ \@\{ {
42
+ // console.log('=> shapeData', yytext);
43
+ this.pushState("shapeData"); yytext=""; return 'SHAPE_DATA' }
44
+ <shapeData>["] {
45
+ // console.log('=> shapeDataStr', yytext);
46
+ this.pushState("shapeDataStr");
47
+ return 'SHAPE_DATA';
48
+ }
49
+ <shapeDataStr>["] {
50
+ // console.log('shapeData <==', yytext);
51
+ this.popState(); return 'SHAPE_DATA'}
52
+ <shapeDataStr>[^\"]+ {
53
+ // console.log('shapeData', yytext);
54
+ const re = /\n\s*/g;
55
+ yytext = yytext.replace(re,"<br/>");
56
+ return 'SHAPE_DATA'}
57
+ <shapeData>[^}^"]+ {
58
+ // console.log('shapeData', yytext);
59
+ return 'SHAPE_DATA';
60
+ }
61
+ <shapeData>"}" {
62
+ // console.log('<== root', yytext)
63
+ this.popState();
64
+ }
65
+
66
+ /*
67
+ ---interactivity command---
68
+ 'call' adds a callback to the specified node. 'call' can only be specified when
69
+ the line was introduced with 'click'.
70
+ 'call <callbackname>(<args>)' attaches the function 'callbackname' with the specified
71
+ arguments to the node that was specified by 'click'.
72
+ Function arguments are optional: 'call <callbackname>()' simply executes 'callbackname' without any arguments.
73
+ */
74
+ "call"[\s]+ this.begin("callbackname");
75
+ <callbackname>\([\s]*\) this.popState();
76
+ <callbackname>\( this.popState(); this.begin("callbackargs");
77
+ <callbackname>[^(]* return 'CALLBACKNAME';
78
+ <callbackargs>\) this.popState();
79
+ <callbackargs>[^)]* return 'CALLBACKARGS';
80
+
81
+
82
+ <md_string>[^`"]+ { return "MD_STR";}
83
+ <md_string>[`]["] { this.popState();}
84
+ <*>["][`] { this.begin("md_string");}
85
+ <string>[^"]+ { return "STR"; }
86
+ <string>["] this.popState();
87
+ <*>["] this.pushState("string");
88
+ "style" return 'STYLE';
89
+ "default" return 'DEFAULT';
90
+ "linkStyle" return 'LINKSTYLE';
91
+ "interpolate" return 'INTERPOLATE';
92
+ "classDef" return 'CLASSDEF';
93
+ "class" return 'CLASS';
94
+
95
+
96
+
97
+ /*
98
+ ---interactivity command---
99
+ 'href' adds a link to the specified node. 'href' can only be specified when the
100
+ line was introduced with 'click'.
101
+ 'href "<link>"' attaches the specified link to the node that was specified by 'click'.
102
+ */
103
+ "href"[\s] return 'HREF';
104
+
105
+
106
+ /*
107
+ 'click' is the keyword to introduce a line that contains interactivity commands.
108
+ 'click' must be followed by an existing node-id. All commands are attached to
109
+ that id.
110
+ 'click <id>' can be followed by href or call commands in any desired order
111
+ */
112
+ "click"[\s]+ this.begin("click");
113
+ <click>[\s\n] this.popState();
114
+ <click>[^\s\n]* return 'CLICK';
115
+
116
+ "flowchart-elk" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
117
+ "swimlane-beta" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
118
+ "graph" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
119
+ "flowchart" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
120
+ "subgraph" return 'subgraph';
121
+ "end"\b\s* return 'end';
122
+
123
+ "_self" return 'LINK_TARGET';
124
+ "_blank" return 'LINK_TARGET';
125
+ "_parent" return 'LINK_TARGET';
126
+ "_top" return 'LINK_TARGET';
127
+
128
+ <dir>(\r?\n)*\s*\n { this.popState(); return 'NODIR'; }
129
+ <dir>\s*"LR" { this.popState(); return 'DIR'; }
130
+ <dir>\s*"RL" { this.popState(); return 'DIR'; }
131
+ <dir>\s*"TB" { this.popState(); return 'DIR'; }
132
+ <dir>\s*"BT" { this.popState(); return 'DIR'; }
133
+ <dir>\s*"TD" { this.popState(); return 'DIR'; }
134
+ <dir>\s*"BR" { this.popState(); return 'DIR'; }
135
+ <dir>\s*"<" { this.popState(); return 'DIR'; }
136
+ <dir>\s*">" { this.popState(); return 'DIR'; }
137
+ <dir>\s*"^" { this.popState(); return 'DIR'; }
138
+ <dir>\s*"v" { this.popState(); return 'DIR'; }
139
+
140
+ .*direction\s+TB[^\n]* return 'direction_tb';
141
+ .*direction\s+BT[^\n]* return 'direction_bt';
142
+ .*direction\s+RL[^\n]* return 'direction_rl';
143
+ .*direction\s+LR[^\n]* return 'direction_lr';
144
+ .*direction\s+TD[^\n]* return 'direction_td';
145
+
146
+ [^\s\"]+\@(?=[^\{\"]) { return 'LINK_ID'; }
147
+ [0-9]+ return 'NUM';
148
+ \# return 'BRKT';
149
+ ":::" return 'STYLE_SEPARATOR';
150
+ ":" return 'COLON';
151
+ "&" return 'AMP';
152
+ ";" return 'SEMI';
153
+ "," return 'COMMA';
154
+ "*" return 'MULT';
155
+
156
+ <INITIAL,edgeText>\s*[xo<]?\-\-+[-xo>]\s* { this.popState(); return 'LINK'; }
157
+ <INITIAL>\s*[xo<]?\-\-\s* { this.pushState("edgeText"); return 'START_LINK'; }
158
+ <edgeText>[^-]|\-(?!\-)+ return 'EDGE_TEXT';
159
+
160
+ <INITIAL,thickEdgeText>\s*[xo<]?\=\=+[=xo>]\s* { this.popState(); return 'LINK'; }
161
+ <INITIAL>\s*[xo<]?\=\=\s* { this.pushState("thickEdgeText"); return 'START_LINK'; }
162
+ <thickEdgeText>[^=]|\=(?!=) return 'EDGE_TEXT';
163
+
164
+ <INITIAL,dottedEdgeText>\s*[xo<]?\-?\.+\-[xo>]?\s* { this.popState(); return 'LINK'; }
165
+ <INITIAL>\s*[xo<]?\-\.\s* { this.pushState("dottedEdgeText"); return 'START_LINK'; }
166
+ <dottedEdgeText>[^\.]|\.(?!-) return 'EDGE_TEXT';
167
+
168
+
169
+ <*>\s*\~\~[\~]+\s* return 'LINK';
170
+
171
+ <ellipseText>[-/\)][\)] { this.popState(); return '-)'; }
172
+ <ellipseText>[^\(\)\[\]\{\}]|-\!\)+ return "TEXT"
173
+ <*>"(-" { this.pushState("ellipseText"); return '(-'; }
174
+
175
+ <text>"])" { this.popState(); return 'STADIUMEND'; }
176
+ <*>"([" { this.pushState("text"); return 'STADIUMSTART'; }
177
+
178
+ <text>"]]" { this.popState(); return 'SUBROUTINEEND'; }
179
+ <*>"[[" { this.pushState("text"); return 'SUBROUTINESTART'; }
180
+
181
+ "[|" { return 'VERTEX_WITH_PROPS_START'; }
182
+
183
+ \> { this.pushState("text"); return 'TAGEND'; }
184
+
185
+ <text>")]" { this.popState(); return 'CYLINDEREND'; }
186
+ <*>"[(" { this.pushState("text") ;return 'CYLINDERSTART'; }
187
+
188
+ <text>")))" { this.popState(); return 'DOUBLECIRCLEEND'; }
189
+ <*>"(((" { this.pushState("text"); return 'DOUBLECIRCLESTART'; }
190
+
191
+ <trapText>[\\(?=\])][\]] { this.popState(); return 'TRAPEND'; }
192
+ <trapText>\/(?=\])\] { this.popState(); return 'INVTRAPEND'; }
193
+ <trapText>\/(?!\])|\\(?!\])|[^\\\[\]\(\)\{\}\/]+ return 'TEXT';
194
+ <*>"[/" { this.pushState("trapText"); return 'TRAPSTART'; }
195
+
196
+ <*>"[\\" { this.pushState("trapText"); return 'INVTRAPSTART'; }
197
+
198
+
199
+ "<" return 'TAGSTART';
200
+ ">" return 'TAGEND';
201
+ "^" return 'UP';
202
+ "\|" return 'SEP';
203
+ "v" return 'DOWN';
204
+ "*" return 'MULT';
205
+ "#" return 'BRKT';
206
+ "&" return 'AMP';
207
+ ([A-Za-z0-9!"\#$%&'*+\.`?\\_\/]|\-(?=[^\>\-\.])|=(?!=))+ {
208
+ return 'NODE_STRING';
209
+ }
210
+ "-" return 'MINUS'
211
+ [\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|
212
+ [\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|
213
+ [\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|
214
+ [\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|
215
+ [\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|
216
+ [\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|
217
+ [\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|
218
+ [\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|
219
+ [\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|
220
+ [\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|
221
+ [\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|
222
+ [\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|
223
+ [\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|
224
+ [\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|
225
+ [\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|
226
+ [\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|
227
+ [\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|
228
+ [\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|
229
+ [\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|
230
+ [\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|
231
+ [\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|
232
+ [\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|
233
+ [\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|
234
+ [\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|
235
+ [\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|
236
+ [\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|
237
+ [\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|
238
+ [\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|
239
+ [\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|
240
+ [\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|
241
+ [\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|
242
+ [\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|
243
+ [\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|
244
+ [\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|
245
+ [\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|
246
+ [\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|
247
+ [\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|
248
+ [\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|
249
+ [\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|
250
+ [\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|
251
+ [\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|
252
+ [\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|
253
+ [\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|
254
+ [\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|
255
+ [\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|
256
+ [\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|
257
+ [\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|
258
+ [\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|
259
+ [\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|
260
+ [\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|
261
+ [\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|
262
+ [\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|
263
+ [\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|
264
+ [\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|
265
+ [\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|
266
+ [\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|
267
+ [\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|
268
+ [\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|
269
+ [\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|
270
+ [\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|
271
+ [\uFFD2-\uFFD7\uFFDA-\uFFDC]
272
+ return 'UNICODE_TEXT';
273
+
274
+ <text>"|" { this.popState(); return 'PIPE'; }
275
+ <*>"|" { this.pushState("text"); return 'PIPE'; }
276
+
277
+ <text>")" { this.popState(); return 'PE'; }
278
+ <*>"(" { this.pushState("text"); return 'PS'; }
279
+
280
+ <text>"]" { this.popState(); return 'SQE'; }
281
+ <*>"[" { this.pushState("text"); return 'SQS'; }
282
+
283
+ <text>(\}) { this.popState(); return 'DIAMOND_STOP' }
284
+ <*>"{" { this.pushState("text"); return 'DIAMOND_START' }
285
+ <text>[^\[\]\(\)\{\}\|\"]+ return "TEXT";
286
+
287
+ "\"" return 'QUOTE';
288
+ (\r?\n)+ return 'NEWLINE';
289
+ [^\S\n\r]+ return 'SPACE';
290
+ <<EOF>> return 'EOF';
291
+
292
+ /lex
293
+
294
+ /* operator associations and precedence */
295
+
296
+ %left '^'
297
+
298
+ %start start
299
+
300
+ %% /* language grammar */
301
+
302
+ start
303
+ : graphConfig document
304
+ ;
305
+
306
+
307
+ document
308
+ : /* empty */
309
+ { $$ = [];}
310
+ | document line
311
+ {
312
+ if(!Array.isArray($line) || $line.length > 0){
313
+ $document.push($line);
314
+ }
315
+ $$=$document;}
316
+ ;
317
+
318
+ line
319
+ : statement
320
+ {$$=$statement;}
321
+ | SEMI
322
+ | NEWLINE
323
+ | SPACE
324
+ | EOF
325
+ ;
326
+
327
+ graphConfig
328
+ : SPACE graphConfig
329
+ | NEWLINE graphConfig
330
+ | GRAPH NODIR
331
+ { yy.setDirection('TB');$$ = 'TB';}
332
+ | GRAPH DIR FirstStmtSeparator
333
+ { yy.setDirection($DIR);$$ = $DIR;}
334
+ // | GRAPH SPACE TAGEND FirstStmtSeparator
335
+ // { yy.setDirection("LR");$$ = $TAGEND;}
336
+ // | GRAPH SPACE TAGSTART FirstStmtSeparator
337
+ // { yy.setDirection("RL");$$ = $TAGSTART;}
338
+ // | GRAPH SPACE UP FirstStmtSeparator
339
+ // { yy.setDirection("BT");$$ = $UP;}
340
+ // | GRAPH SPACE DOWN FirstStmtSeparator
341
+ // { yy.setDirection("TB");$$ = $DOWN;}
342
+ ;
343
+
344
+ ending: endToken ending
345
+ | endToken
346
+ ;
347
+
348
+ endToken: NEWLINE | SPACE | EOF;
349
+
350
+ FirstStmtSeparator
351
+ : SEMI | NEWLINE | spaceList NEWLINE ;
352
+
353
+
354
+ spaceListNewline
355
+ : SPACE spaceListNewline
356
+ | NEWLINE spaceListNewline
357
+ | NEWLINE
358
+ | SPACE
359
+ ;
360
+
361
+
362
+ spaceList
363
+ : SPACE spaceList
364
+ | SPACE
365
+ ;
366
+
367
+ statement
368
+ : vertexStatement separator
369
+ { $$=$vertexStatement.nodes}
370
+ | styleStatement separator
371
+ {$$=[];}
372
+ | linkStyleStatement separator
373
+ {$$=[];}
374
+ | classDefStatement separator
375
+ {$$=[];}
376
+ | classStatement separator
377
+ {$$=[];}
378
+ | clickStatement separator
379
+ {$$=[];}
380
+ | subgraph SPACE textNoTags SQS text SQE separator document end
381
+ {$$=yy.addSubGraph($textNoTags,$document,$text);}
382
+ | subgraph SPACE textNoTags separator document end
383
+ {$$=yy.addSubGraph($textNoTags,$document,$textNoTags);}
384
+ // | subgraph SPACE textNoTags separator document end
385
+ // {$$=yy.addSubGraph($textNoTags,$document,$textNoTags);}
386
+ | subgraph separator document end
387
+ {$$=yy.addSubGraph(undefined,$document,undefined);}
388
+ | direction
389
+ | acc_title acc_title_value { $$=$acc_title_value.trim();yy.setAccTitle($$); }
390
+ | acc_descr acc_descr_value { $$=$acc_descr_value.trim();yy.setAccDescription($$); }
391
+ | acc_descr_multiline_value { $$=$acc_descr_multiline_value.trim();yy.setAccDescription($$); }
392
+ ;
393
+
394
+ separator: NEWLINE | SEMI | EOF ;
395
+
396
+ shapeData:
397
+ shapeData SHAPE_DATA
398
+ { $$ = $1 + $2; }
399
+ | SHAPE_DATA
400
+ { $$ = $1; }
401
+ ;
402
+
403
+ vertexStatement: vertexStatement link node shapeData
404
+ { /* console.warn('vs shapeData',$vertexStatement.stmt,$node, $shapeData);*/ yy.addVertex($node[$node.length-1],undefined,undefined,undefined, undefined,undefined, undefined,$shapeData); yy.addLink($vertexStatement.stmt,$node,$link); $$ = { stmt: $node, nodes: $node.concat($vertexStatement.nodes) } }
405
+ | vertexStatement link node
406
+ { /*console.warn('vs',$vertexStatement.stmt,$node);*/ yy.addLink($vertexStatement.stmt,$node,$link); $$ = { stmt: $node, nodes: $node.concat($vertexStatement.nodes) } }
407
+ | vertexStatement link node spaceList
408
+ { /* console.warn('vs',$vertexStatement.stmt,$node); */ yy.addLink($vertexStatement.stmt,$node,$link); $$ = { stmt: $node, nodes: $node.concat($vertexStatement.nodes) } }
409
+ |node spaceList { /*console.warn('vertexStatement: node spaceList', $node);*/ $$ = {stmt: $node, nodes:$node }}
410
+ |node shapeData {
411
+ /*console.warn('vertexStatement: node shapeData', $node[0], $shapeData);*/
412
+ yy.addVertex($node[$node.length-1],undefined,undefined,undefined, undefined,undefined, undefined,$shapeData);
413
+ $$ = {stmt: $node, nodes:$node, shapeData: $shapeData}
414
+ }
415
+ |node { /* console.warn('vertexStatement: single node', $node); */ $$ = {stmt: $node, nodes:$node }}
416
+ ;
417
+
418
+ node: styledVertex
419
+ { /*console.warn('nod', $styledVertex);*/ $$ = [$styledVertex];}
420
+ | node shapeData spaceList AMP spaceList styledVertex
421
+ { yy.addVertex($node[$node.length-1],undefined,undefined,undefined, undefined,undefined, undefined,$shapeData); $$ = $node.concat($styledVertex); /*console.warn('pip2', $node[0], $styledVertex, $$);*/ }
422
+ | node spaceList AMP spaceList styledVertex
423
+ { $$ = $node.concat($styledVertex); /*console.warn('pip', $node[0], $styledVertex, $$);*/ }
424
+ ;
425
+
426
+ styledVertex: vertex
427
+ { /* console.warn('nodc', $vertex);*/ $$ = $vertex;}
428
+ | vertex STYLE_SEPARATOR idString
429
+ {$$ = $vertex;yy.setClass($vertex,$idString)}
430
+ ;
431
+
432
+ vertex: idString SQS text SQE
433
+ {$$ = $idString;yy.addVertex($idString,$text,'square');}
434
+ | idString DOUBLECIRCLESTART text DOUBLECIRCLEEND
435
+ {$$ = $idString;yy.addVertex($idString,$text,'doublecircle');}
436
+ | idString PS PS text PE PE
437
+ {$$ = $idString;yy.addVertex($idString,$text,'circle');}
438
+ | idString '(-' text '-)'
439
+ {$$ = $idString;yy.addVertex($idString,$text,'ellipse');}
440
+ | idString STADIUMSTART text STADIUMEND
441
+ {$$ = $idString;yy.addVertex($idString,$text,'stadium');}
442
+ | idString SUBROUTINESTART text SUBROUTINEEND
443
+ {$$ = $idString;yy.addVertex($idString,$text,'subroutine');}
444
+ | idString VERTEX_WITH_PROPS_START NODE_STRING\[field] COLON NODE_STRING\[value] PIPE text SQE
445
+ {$$ = $idString;yy.addVertex($idString,$text,'rect',undefined,undefined,undefined, Object.fromEntries([[$field, $value]]));}
446
+ | idString CYLINDERSTART text CYLINDEREND
447
+ {$$ = $idString;yy.addVertex($idString,$text,'cylinder');}
448
+ | idString PS text PE
449
+ {$$ = $idString;yy.addVertex($idString,$text,'round');}
450
+ | idString DIAMOND_START text DIAMOND_STOP
451
+ {$$ = $idString;yy.addVertex($idString,$text,'diamond');}
452
+ | idString DIAMOND_START DIAMOND_START text DIAMOND_STOP DIAMOND_STOP
453
+ {$$ = $idString;yy.addVertex($idString,$text,'hexagon');}
454
+ | idString TAGEND text SQE
455
+ {$$ = $idString;yy.addVertex($idString,$text,'odd');}
456
+ | idString TRAPSTART text TRAPEND
457
+ {$$ = $idString;yy.addVertex($idString,$text,'trapezoid');}
458
+ | idString INVTRAPSTART text INVTRAPEND
459
+ {$$ = $idString;yy.addVertex($idString,$text,'inv_trapezoid');}
460
+ | idString TRAPSTART text INVTRAPEND
461
+ {$$ = $idString;yy.addVertex($idString,$text,'lean_right');}
462
+ | idString INVTRAPSTART text TRAPEND
463
+ {$$ = $idString;yy.addVertex($idString,$text,'lean_left');}
464
+ | idString
465
+ { /*console.warn('h: ', $idString);*/$$ = $idString;yy.addVertex($idString);}
466
+ ;
467
+
468
+
469
+
470
+ link: linkStatement arrowText
471
+ {$linkStatement.text = $arrowText;$$ = $linkStatement;}
472
+ | linkStatement TESTSTR SPACE
473
+ {$linkStatement.text = $TESTSTR;$$ = $linkStatement;}
474
+ | linkStatement arrowText SPACE
475
+ {$linkStatement.text = $arrowText;$$ = $linkStatement;}
476
+ | linkStatement
477
+ {$$ = $linkStatement;}
478
+ | START_LINK edgeText LINK
479
+ {var inf = yy.destructLink($LINK, $START_LINK); $$ = {"type":inf.type,"stroke":inf.stroke,"length":inf.length,"text":$edgeText};}
480
+ | LINK_ID START_LINK edgeText LINK
481
+ {var inf = yy.destructLink($LINK, $START_LINK); $$ = {"type":inf.type,"stroke":inf.stroke,"length":inf.length,"text":$edgeText, "id": $LINK_ID};}
482
+ ;
483
+
484
+ edgeText: edgeTextToken
485
+ {$$={text:$edgeTextToken, type:'text'};}
486
+ | edgeText edgeTextToken
487
+ {$$={text:$edgeText.text+''+$edgeTextToken, type:$edgeText.type};}
488
+ |STR
489
+ {$$={text: $STR, type: 'string'};}
490
+ | MD_STR
491
+ {$$={text:$MD_STR, type:'markdown'};}
492
+ ;
493
+
494
+
495
+ linkStatement: LINK
496
+ {var inf = yy.destructLink($LINK);$$ = {"type":inf.type,"stroke":inf.stroke,"length":inf.length};}
497
+ | LINK_ID LINK
498
+ {var inf = yy.destructLink($LINK);$$ = {"type":inf.type,"stroke":inf.stroke,"length":inf.length, "id": $LINK_ID};}
499
+ ;
500
+
501
+ arrowText:
502
+ PIPE text PIPE
503
+ {$$ = $text;}
504
+ ;
505
+
506
+ text: textToken
507
+ { $$={text:$textToken, type: 'text'};}
508
+ | text textToken
509
+ { $$={text:$text.text+''+$textToken, type: $text.type};}
510
+ | STR
511
+ { $$ = {text: $STR, type: 'string'};}
512
+ | MD_STR
513
+ { $$={text: $MD_STR, type: 'markdown'};}
514
+ ;
515
+
516
+
517
+
518
+ keywords
519
+ : STYLE | LINKSTYLE | CLASSDEF | CLASS | CLICK | GRAPH | DIR | subgraph | end | DOWN | UP;
520
+
521
+
522
+ textNoTags: textNoTagsToken
523
+ {$$={text:$textNoTagsToken, type: 'text'};}
524
+ | textNoTags textNoTagsToken
525
+ {$$={text:$textNoTags.text+''+$textNoTagsToken, type: $textNoTags.type};}
526
+ | STR
527
+ { $$={text: $STR, type: 'text'};}
528
+ | MD_STR
529
+ { $$={text: $MD_STR, type: 'markdown'};}
530
+ ;
531
+
532
+
533
+ classDefStatement:CLASSDEF SPACE idString SPACE stylesOpt
534
+ {$$ = $CLASSDEF;yy.addClass($idString,$stylesOpt);}
535
+ ;
536
+
537
+ classStatement:CLASS SPACE idString\[vertex] SPACE idString\[class]
538
+ {$$ = $CLASS;yy.setClass($vertex, $class);}
539
+ ;
540
+
541
+ clickStatement
542
+ : CLICK CALLBACKNAME {$$ = $CLICK;yy.setClickEvent($CLICK, $CALLBACKNAME);}
543
+ | CLICK CALLBACKNAME SPACE STR {$$ = $CLICK;yy.setClickEvent($CLICK, $CALLBACKNAME);yy.setTooltip($CLICK, $STR);}
544
+ | CLICK CALLBACKNAME CALLBACKARGS {$$ = $CLICK;yy.setClickEvent($CLICK, $CALLBACKNAME, $CALLBACKARGS);}
545
+ | CLICK CALLBACKNAME CALLBACKARGS SPACE STR {$$ = $CLICK;yy.setClickEvent($CLICK, $CALLBACKNAME, $CALLBACKARGS);yy.setTooltip($CLICK, $STR);}
546
+ | CLICK HREF STR {$$ = $CLICK;yy.setLink($CLICK, $STR);}
547
+ | CLICK HREF STR SPACE STR {$$ = $CLICK;yy.setLink($CLICK, $STR1);yy.setTooltip($CLICK, $STR2);}
548
+ | CLICK HREF STR SPACE LINK_TARGET {$$ = $CLICK;yy.setLink($CLICK, $STR, $LINK_TARGET);}
549
+ | CLICK HREF STR\[link] SPACE STR\[tooltip] SPACE LINK_TARGET {$$ = $CLICK;yy.setLink($CLICK, $link, $LINK_TARGET);yy.setTooltip($CLICK, $tooltip);}
550
+ | CLICK alphaNum {$$ = $CLICK;yy.setClickEvent($CLICK, $alphaNum);}
551
+ | CLICK alphaNum SPACE STR {$$ = $CLICK;yy.setClickEvent($CLICK, $alphaNum);yy.setTooltip($CLICK, $STR);}
552
+ | CLICK STR {$$ = $CLICK;yy.setLink($CLICK, $STR);}
553
+ | CLICK STR\[link] SPACE STR\[tooltip] {$$ = $CLICK;yy.setLink($CLICK, $link);yy.setTooltip($CLICK, $tooltip);}
554
+ | CLICK STR SPACE LINK_TARGET {$$ = $CLICK;yy.setLink($CLICK, $STR, $LINK_TARGET);}
555
+ | CLICK STR\[link] SPACE STR\[tooltip] SPACE LINK_TARGET {$$ = $CLICK;yy.setLink($CLICK, $link, $LINK_TARGET);yy.setTooltip($CLICK, $tooltip);}
556
+ ;
557
+
558
+ styleStatement:STYLE SPACE idString SPACE stylesOpt
559
+ {$$ = $STYLE;yy.addVertex($idString,undefined,undefined,$stylesOpt);}
560
+ ;
561
+
562
+ linkStyleStatement
563
+ : LINKSTYLE SPACE DEFAULT SPACE stylesOpt
564
+ {$$ = $LINKSTYLE;yy.updateLink([$DEFAULT],$stylesOpt);}
565
+ | LINKSTYLE SPACE numList SPACE stylesOpt
566
+ {$$ = $LINKSTYLE;yy.updateLink($numList,$stylesOpt);}
567
+ | LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt
568
+ {$$ = $LINKSTYLE;yy.updateLinkInterpolate([$DEFAULT],$alphaNum);yy.updateLink([$DEFAULT],$stylesOpt);}
569
+ | LINKSTYLE SPACE numList SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt
570
+ {$$ = $LINKSTYLE;yy.updateLinkInterpolate($numList,$alphaNum);yy.updateLink($numList,$stylesOpt);}
571
+ | LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum
572
+ {$$ = $LINKSTYLE;yy.updateLinkInterpolate([$DEFAULT],$alphaNum);}
573
+ | LINKSTYLE SPACE numList SPACE INTERPOLATE SPACE alphaNum
574
+ {$$ = $LINKSTYLE;yy.updateLinkInterpolate($numList,$alphaNum);}
575
+ ;
576
+
577
+ numList: NUM
578
+ {$$ = [$NUM]}
579
+ | numList COMMA NUM
580
+ {$numList.push($NUM);$$ = $numList;}
581
+ ;
582
+
583
+ stylesOpt: style
584
+ {$$ = [$style]}
585
+ | stylesOpt COMMA style
586
+ {$stylesOpt.push($style);$$ = $stylesOpt;}
587
+ ;
588
+
589
+ style: styleComponent
590
+ |style styleComponent
591
+ {$$ = $style + $styleComponent;}
592
+ ;
593
+
594
+ styleComponent: NUM | NODE_STRING| COLON | UNIT | SPACE | BRKT | STYLE | PCT ;
595
+
596
+ /* Token lists */
597
+ idStringToken : NUM | NODE_STRING | DOWN | MINUS | DEFAULT | COMMA | COLON | AMP | BRKT | MULT | UNICODE_TEXT;
598
+
599
+ textToken : TEXT | TAGSTART | TAGEND | UNICODE_TEXT;
600
+
601
+ textNoTagsToken: NUM | NODE_STRING | SPACE | MINUS | AMP | UNICODE_TEXT | COLON | MULT | BRKT | keywords | START_LINK ;
602
+
603
+ edgeTextToken : EDGE_TEXT | UNICODE_TEXT ;
604
+
605
+ alphaNumToken : NUM | UNICODE_TEXT | NODE_STRING | DIR | DOWN | MINUS | COMMA | COLON | AMP | BRKT | MULT;
606
+
607
+ idString
608
+ :idStringToken
609
+ {$$=$idStringToken}
610
+ | idString idStringToken
611
+ {$$=$idString+''+$idStringToken}
612
+ ;
613
+
614
+ alphaNum
615
+ : alphaNumToken
616
+ {$$=$alphaNumToken;}
617
+ | alphaNum alphaNumToken
618
+ {$$=$alphaNum+''+$alphaNumToken;}
619
+ ;
620
+
621
+
622
+ direction
623
+ : direction_tb
624
+ { $$={stmt:'dir', value:'TB'};}
625
+ | direction_bt
626
+ { $$={stmt:'dir', value:'BT'};}
627
+ | direction_rl
628
+ { $$={stmt:'dir', value:'RL'};}
629
+ | direction_lr
630
+ { $$={stmt:'dir', value:'LR'};}
631
+ | direction_td
632
+ { $$={stmt:'dir', value:'TD'};}
633
+ ;
634
+
635
+ %%