aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/language/problem.grammar
diff options
context:
space:
mode:
Diffstat (limited to 'language-web/src/main/js/language/problem.grammar')
-rw-r--r--language-web/src/main/js/language/problem.grammar145
1 files changed, 145 insertions, 0 deletions
diff --git a/language-web/src/main/js/language/problem.grammar b/language-web/src/main/js/language/problem.grammar
new file mode 100644
index 00000000..c242a4ba
--- /dev/null
+++ b/language-web/src/main/js/language/problem.grammar
@@ -0,0 +1,145 @@
1@top Problem { statement* }
2
3statement {
4 ProblemDeclaration {
5 ckw<"problem"> QualifiedName "."
6 } |
7 ClassDefinition {
8 ckw<"abstract">? ckw<"class"> RelationName
9 (ckw<"extends"> sep<",", RelationName>)?
10 (ClassBody { "{" ReferenceDeclaration* "}" } | ".")
11 } |
12 EnumDefinition {
13 ckw<"enum"> RelationName
14 (EnumBody { "{" sep<",", UniqueNodeName> "}" } | ".")
15 } |
16 PredicateDefinition {
17 (ckw<"error"> ckw<"pred">? | ckw<"direct">? ckw<"pred">)
18 RelationName ParameterList<Parameter>?
19 PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." }
20 } |
21 RuleDefinition {
22 ckw<"direct">? ckw<"rule">
23 RuleName ParameterList<Parameter>?
24 RuleBody { ":" sep<OrOp, Conjunction> "~>" sep<OrOp, Action> "." }
25 } |
26 Assertion {
27 ckw<"default">? (NotOp | UnknownOp)? RelationName
28 ParameterList<AssertionArgument> (":" LogicValue)? "."
29 } |
30 NodeValueAssertion {
31 UniqueNodeName ":" Constant "."
32 } |
33 UniqueDeclaration {
34 ckw<"unique"> sep<",", UniqueNodeName> "."
35 } |
36 ScopeDeclaration {
37 ckw<"scope"> sep<",", ScopeElement> "."
38 }
39}
40
41ReferenceDeclaration {
42 (kw<"refers"> | kw<"contains">)?
43 RelationName
44 RelationName
45 ( "[" Multiplicity? "]" )?
46 (kw<"opposite"> RelationName)?
47 ";"?
48}
49
50Parameter { RelationName? VariableName }
51
52Conjunction { ("," | Literal)+ }
53
54OrOp { ";" }
55
56Literal { NotOp? Atom (("=" | ":") sep1<"|", LogicValue>)? }
57
58Atom { RelationName "+"? ParameterList<Argument> }
59
60Action { ("," | ActionLiteral)+ }
61
62ActionLiteral {
63 ckw<"new"> VariableName |
64 ckw<"delete"> VariableName |
65 Literal
66}
67
68Argument { VariableName | Constant }
69
70AssertionArgument { NodeName | StarArgument | Constant }
71
72Constant { Real | String }
73
74LogicValue {
75 ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error">
76}
77
78ScopeElement { RelationName ("=" | "+=") Multiplicity }
79
80Multiplicity { (IntMult "..")? (IntMult | StarMult)}
81
82RelationName { QualifiedName }
83
84RuleName { QualifiedName }
85
86UniqueNodeName { QualifiedName }
87
88VariableName { QualifiedName }
89
90NodeName { QualifiedName }
91
92QualifiedName { identifier ("::" identifier)* }
93
94kw<term> { @specialize[@name={term}]<identifier, term> }
95
96ckw<term> { @extend[@name={term}]<identifier, term> }
97
98ParameterList<content> { "(" sep<",", content> ")" }
99
100sep<separator, content> { sep1<separator, content>? }
101
102sep1<separator, content> { content (separator content)* }
103
104@skip { LineComment | BlockComment | whitespace }
105
106@tokens {
107 whitespace { std.whitespace+ }
108
109 LineComment { ("//" | "%") ![\n]* }
110
111 BlockComment { "/*" blockCommentRest }
112
113 blockCommentRest { ![*] blockCommentRest | "*" blockCommentAfterStar }
114
115 blockCommentAfterStar { "/" | "*" blockCommentAfterStar | ![/*] blockCommentRest }
116
117 @precedence { BlockComment, LineComment }
118
119 identifier { $[A-Za-z_] $[a-zA-Z0-9_]* }
120
121 int { $[0-9]+ }
122
123 IntMult { int }
124
125 StarMult { "*" }
126
127 Real { "-"? (exponential | int ("." (int | exponential))?) }
128
129 exponential { int ("e" | "E") ("+" | "-")? int }
130
131 String {
132 "'" (![\\'\n] | "\\" ![\n] | "\\\n")+ "'" |
133 "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\""
134 }
135
136 NotOp { "!" }
137
138 UnknownOp { "?" }
139
140 StarArgument { "*" }
141
142 "{" "}" "(" ")" "[" "]" "." ".." "," ":" "<->" "~>"
143}
144
145@detectDelim