-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.peg
86 lines (67 loc) · 2.39 KB
/
grammar.peg
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
package fbp
type Fbp Peg {
BaseFbp
}
start <- line* _ !.
line <-
_ "EXPORT=" [A-Za-z.0-9_]+ ":" [A-Z0-9_]+ _ LineTerminator?
/ _ "INPORT=" <[A-Za-z0-9_]+ "." [A-Z0-9_\[\]]+ ":" [A-Z0-9_]+> _ LineTerminator? { p.createInport(buffer[begin:end]) }
/ _ "OUTPORT=" <[A-Za-z0-9_]+ "." [A-Z0-9_\[\]]+ ":" [A-Z0-9_]+> _ LineTerminator? { p.createOutport(buffer[begin:end]) }
/ comment [\n\r]?
/ _ [\n\r]
/ _ connection _ LineTerminator?
LineTerminator <- _ ","? comment? [\n\r]?
comment <- _ "#" anychar*
connection <-
(
(
bridge
_ "->" _
connection
)
/ bridge
)
bridge <-
(
port _ { p.inPort = p.port; p.inPortIndex = p.index }
node _
port { p.outPort = p.port; p.outPortIndex = p.index }
) { p.createMiddlet() }
/ iip
/ leftlet { p.createLeftlet() }
/ rightlet { p.createRightlet() }
leftlet <-
(node _ portWithIndex)
/
(node _ port)
iip <- "'" <iipchar*> "'" { p.iip = buffer[begin:end] }
rightlet <-
(portWithIndex _ node)
/
(port _ node)
node <-
(
<[a-zA-Z0-9_]+> { p.nodeProcessName = buffer[begin:end] }
component?
) { p.createNode() }
component <-
"("
<[a-zA-Z/\-0-9_]*> { p.nodeComponentName = buffer[begin:end] }
compMeta?
")"
compMeta <- ":" <[a-zA-Z/=_,0-9]+> { p.nodeMeta = buffer[begin:end] }
port <- <[A-Z.0-9_]+> __ { p.port = buffer[begin:end] }
portWithIndex <-
(
<[A-Z.0-9_]+> { p.port = buffer[begin:end] }
"["
<[0-9]+> { p.index = buffer[begin:end] }
"]"
__
)
anychar <- [^\n\r]
iipchar <-
[\\][']
/ [^']
_ <- [ \t]*
__ <- [ \t]+