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
106
107
108
109
110
111
112
113
114
115
116
117
|
@top Problem { statement* }
statement {
ProblemDeclaration {
kw<"problem"> QualifiedName "."
} |
ClassDefinition {
kw<"abstract">? kw<"class"> RelationName
(ClassBody { "{" ReferenceDeclaration* "}" } | ".")
} |
EnumDefinition {
kw<"enum"> RelationName
(EnumBody { "{" sep<",", UniqueNodeName> "}" } | ".")
} |
PredicateDefinition {
(kw<"error"> kw<"pred">? | kw<"pred">) RelationName ParameterList<Parameter>?
PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." }
} |
Assertion {
kw<"default">? (NotOp | UnknownOp)? RelationName
ParameterList<AssertionArgument> (":" LogicValue)? "."
} |
UniqueDeclaration {
kw<"unique"> sep<",", UniqueNodeName> "."
} |
ScopeDeclaration {
kw<"scope"> sep<",", ScopeElement> "."
}
}
ReferenceDeclaration {
(kw<"refers"> | kw<"contains">)?
RelationName
RelationName
( "[" Multiplicity? "]" )?
(kw<"opposite"> RelationName)?
";"?
}
Parameter { RelationName? VariableName }
Conjunction { sep1<",", Literal> }
OrOp { ";" }
Literal { NotOp? Atom }
Atom { RelationName ParameterList<Argument>? }
Argument { VariableName | Real }
AssertionArgument { NodeName | StarArgument | Real }
LogicValue {
kw<"true"> | kw<"false"> | kw<"unknown"> | kw<"error">
}
ScopeElement { RelationName ("=" | "+=") Multiplicity }
Multiplicity { (IntMult "..")? (IntMult | StarMult)}
RelationName { QualifiedName }
UniqueNodeName { QualifiedName }
VariableName { QualifiedName }
NodeName { QualifiedName }
QualifiedName { identifier ("::" identifier)* }
kw<term> { @specialize[@name={term}]<identifier, term> }
ParameterList<content> { "(" sep<",", content> ")" }
sep<separator, content> { sep1<separator, content>? }
sep1<separator, content> { content (separator content?)* }
@skip { LineComment | BlockComment | whitespace }
@tokens {
whitespace { std.whitespace+ }
LineComment { ("//" | "%") ![\n]* }
BlockComment { "/*" blockCommentRest }
blockCommentRest { ![*] blockCommentRest | "*" blockCommentAfterStar }
blockCommentAfterStar { "/" | "*" blockCommentAfterStar | ![/*] blockCommentRest }
@precedence { BlockComment, LineComment }
identifier { $[A-Za-z_] $[a-zA-Z0-9_]* }
int { $[0-9]+ }
IntMult { int }
StarMult { "*" }
Real { "-"? (exponential | int ("." (int | exponential))?) }
exponential { int ("e" | "E") ("+" | "-")? int }
NotOp { "!" }
UnknownOp { "?" }
StarArgument { "*" }
"{" "}" "(" ")" "[" "]" "." ".." "," ":" "<->"
}
@detectDelim
|