-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.ebnf
88 lines (76 loc) · 2.83 KB
/
grammar.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
83
84
85
86
87
88
shapes : (nodeshape | edgeshape | COMMENT)*
nodeshape : "NODE" shape "[" nodetarget "]" "{" nodeconstraint "}" ";"
edgeshape : "EDGE" shape "[" edgetarget "]" "{" edgeconstraint "}" ";"
nodetarget : ":" label
| NUMBER -> nid
| "BOTTOM" -> bot
| property "=" value -> propvalue
| property -> propertytarget
?nodeconstraint : nodeconstraint_or
?nodeconstraint_or : [nodeconstraint_or "|"] nodeconstraint_and
?nodeconstraint_and : [nodeconstraint_and "&"] nodeconstraint_basic
nodeconstraint_basic : "TOP" -> top
| "BOTTOM" -> bot
| shape -> shaperef
| ":" label
| NUMBER -> rnid
| "!" nodeconstraint_basic -> negate
| comp NUMBER choicepath "." nodeconstraint_basic -> greatereq
| comp NUMBER property "." predicate -> countprop
| comp NUMBER edgeconstraint -> greatereqe
| choicepath "==" choicepath -> compare
| choicepath property "==" path property -> comparevalue
| property "==" property -> equals
| "(" nodeconstraint ")"
?choicepath : [choicepath "|"] concatpath
?concatpath : [concatpath "/"] path
path : ":" label
| "-" path -> negatepath
| "(" choicepath ")"
| path "+" -> repeatpath
predicate : "string" -> string
| "int" -> int
| "=" value -> eqvalue
edgetarget : ":" label
| NUMBER -> eid
| "BOTTOM" -> bot
| property "=" value -> propvalue
| property -> propertytarget
?edgeconstraint : edgeconstraint_or
?edgeconstraint_or : [edgeconstraint_or "|"] edgeconstraint_and
?edgeconstraint_and : [edgeconstraint_and "&"] edgeconstraint_basic
edgeconstraint_basic : "TOP" -> top
| "BOTTOM" -> bot
| shape -> shaperef
| ":" label
| NUMBER -> reid
| "!" edgeconstraint_basic -> negate
| comp NUMBER property "." predicate -> countprop
| property "==" property -> equals
| "<<" nodeconstraint_basic -> left
| ">>" nodeconstraint_basic -> right
| "(" edgeconstraint ")"
?value : "\"" STRING "\"" -> stringvalue
| NUMBER -> intvalue
comp : "<=" -> le
| ">=" -> ge
| ">" -> gr
| "<" -> ls
| "=" -> eq
shape : WORD
label : WORD
property : WORD
labelref : WORD
WORD : LCASE_LETTER CHAR+
CHAR : LETTER | DIGIT | "_"
NUMBER : DIGIT+
SCHAR : CHAR | WS
STRING : SCHAR+
COMMENT : "%" /(.)*/ NEWLINE
%import common.LCASE_LETTER
%import common.LETTER
%import common.NEWLINE
%import common.DIGIT
%import common.WS
%ignore WS
%ignore COMMENT