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