diff options
author | 2021-10-30 13:48:52 +0200 | |
---|---|---|
committer | 2021-10-31 19:26:13 +0100 | |
commit | cdb493b0a47bcf64e8e670b94fa399fcd731f531 (patch) | |
tree | b6b03aec77ef87a2dda7585be7884a30c65d93f5 /language-web/src/main/js/language/problem.grammar | |
parent | feat(web): add xtext content assist (diff) | |
download | refinery-cdb493b0a47bcf64e8e670b94fa399fcd731f531.tar.gz refinery-cdb493b0a47bcf64e8e670b94fa399fcd731f531.tar.zst refinery-cdb493b0a47bcf64e8e670b94fa399fcd731f531.zip |
chore(web): refactor xtext client
Diffstat (limited to 'language-web/src/main/js/language/problem.grammar')
-rw-r--r-- | language-web/src/main/js/language/problem.grammar | 129 |
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 | |||
3 | statement { | ||
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 | |||
35 | ReferenceDeclaration { | ||
36 | (kw<"refers"> | kw<"contains">)? | ||
37 | RelationName | ||
38 | RelationName | ||
39 | ( "[" Multiplicity? "]" )? | ||
40 | (kw<"opposite"> RelationName)? | ||
41 | ";"? | ||
42 | } | ||
43 | |||
44 | Parameter { RelationName? VariableName } | ||
45 | |||
46 | Conjunction { ("," | Literal)+ } | ||
47 | |||
48 | OrOp { ";" } | ||
49 | |||
50 | Literal { NotOp? Atom } | ||
51 | |||
52 | Atom { RelationName ParameterList<Argument>? } | ||
53 | |||
54 | Argument { VariableName | Constant } | ||
55 | |||
56 | AssertionArgument { NodeName | StarArgument | Constant } | ||
57 | |||
58 | Constant { Real | String } | ||
59 | |||
60 | LogicValue { | ||
61 | ckw<"true"> | ckw<"false"> | ckw<"unknown"> | ckw<"error"> | ||
62 | } | ||
63 | |||
64 | ScopeElement { RelationName ("=" | "+=") Multiplicity } | ||
65 | |||
66 | Multiplicity { (IntMult "..")? (IntMult | StarMult)} | ||
67 | |||
68 | RelationName { QualifiedName } | ||
69 | |||
70 | UniqueNodeName { QualifiedName } | ||
71 | |||
72 | VariableName { QualifiedName } | ||
73 | |||
74 | NodeName { QualifiedName } | ||
75 | |||
76 | QualifiedName { identifier ("::" identifier)* } | ||
77 | |||
78 | kw<term> { @specialize[@name={term}]<identifier, term> } | ||
79 | |||
80 | ckw<term> { @extend[@name={term}]<identifier, term> } | ||
81 | |||
82 | ParameterList<content> { "(" sep<",", content> ")" } | ||
83 | |||
84 | sep<separator, content> { sep1<separator, content>? } | ||
85 | |||
86 | sep1<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 | ||