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.grammar129
1 files changed, 129 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..cf940698
--- /dev/null
+++ b/language-web/src/main/js/language/problem.grammar
@@ -0,0 +1,129 @@
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<"pred">) RelationName ParameterList<Parameter>?
18 PredicateBody { ("<->" sep<OrOp, Conjunction>)? "." }
19 } |
20 Assertion {
21 ckw<"default">? (NotOp | UnknownOp)? RelationName
22 ParameterList<AssertionArgument> (":" LogicValue)? "."
23 } |
24 NodeValueAssertion {
25 UniqueNodeName ":" Constant "."
26 } |
27 UniqueDeclaration {
28 ckw<"unique"> sep<",", UniqueNodeName> "."
29 } |
30 ScopeDeclaration {
31 ckw<"scope"> sep<",", ScopeElement> "."
32 }
33}
34
35ReferenceDeclaration {
36 (kw<"refers"> | kw<"contains">)?
37 RelationName
38 RelationName
39 ( "[" Multiplicity? "]" )?
40 (kw<"opposite"> RelationName)?
41 ";"?
42}
43
44Parameter { RelationName? VariableName }
45
46Conjunction { ("," | Literal)+ }
47
48OrOp { ";" }
49
50Literal { NotOp? Atom }
51
52Atom { RelationName ParameterList<Argument>? }
53
54Argument { VariableName | Constant }
55
56AssertionArgument { NodeName | StarArgument | Constant }
57
58Constant { Real | String }
59
60LogicValue {
61 ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error">
62}
63
64ScopeElement { RelationName ("=" | "+=") Multiplicity }
65
66Multiplicity { (IntMult "..")? (IntMult | StarMult)}
67
68RelationName { QualifiedName }
69
70UniqueNodeName { QualifiedName }
71
72VariableName { QualifiedName }
73
74NodeName { QualifiedName }
75
76QualifiedName { identifier ("::" identifier)* }
77
78kw<term> { @specialize[@name={term}]<identifier, term> }
79
80ckw<term> { @extend[@name={term}]<identifier, term> }
81
82ParameterList<content> { "(" sep<",", content> ")" }
83
84sep<separator, content> { sep1<separator, content>? }
85
86sep1<separator, content> { content (separator content?)* }
87
88@skip { LineComment | BlockComment | whitespace }
89
90@tokens {
91 whitespace { std.whitespace+ }
92
93 LineComment { ("//" | "%") ![\n]* }
94
95 BlockComment { "/*" blockCommentRest }
96
97 blockCommentRest { ![*] blockCommentRest | "*" blockCommentAfterStar }
98
99 blockCommentAfterStar { "/" | "*" blockCommentAfterStar | ![/*] blockCommentRest }
100
101 @precedence { BlockComment, LineComment }
102
103 identifier { $[A-Za-z_] $[a-zA-Z0-9_]* }
104
105 int { $[0-9]+ }
106
107 IntMult { int }
108
109 StarMult { "*" }
110
111 Real { "-"? (exponential | int ("." (int | exponential))?) }
112
113 exponential { int ("e" | "E") ("+" | "-")? int }
114
115 String {
116 "'" (![\\'\n] | "\\" ![\n] | "\\\n")+ "'" |
117 "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\""
118 }
119
120 NotOp { "!" }
121
122 UnknownOp { "?" }
123
124 StarArgument { "*" }
125
126 "{" "}" "(" ")" "[" "]" "." ".." "," ":" "<->"
127}
128
129@detectDelim