diff options
author | 2024-06-30 18:10:01 +0200 | |
---|---|---|
committer | 2024-06-30 20:29:21 +0200 | |
commit | de0ea1d86b98287d688bdef42da6d8905e4e9ce6 (patch) | |
tree | d8d1cb32513861470b47ee154a529811a695a08f /subprojects/language/src/main/java/tools | |
parent | refactor(language): move computed to Atom (diff) | |
download | refinery-de0ea1d86b98287d688bdef42da6d8905e4e9ce6.tar.gz refinery-de0ea1d86b98287d688bdef42da6d8905e4e9ce6.tar.zst refinery-de0ea1d86b98287d688bdef42da6d8905e4e9ce6.zip |
refactor(language): computed constraint symbol
Diffstat (limited to 'subprojects/language/src/main/java/tools')
-rw-r--r-- | subprojects/language/src/main/java/tools/refinery/language/Problem.xtext | 2 | ||||
-rw-r--r-- | subprojects/language/src/main/java/tools/refinery/language/parser/antlr/ProblemTokenSource.java | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext index d6c605cc..5adc50eb 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext +++ b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext | |||
@@ -199,8 +199,8 @@ CastExprBody returns Expr: | |||
199 | Atom | VariableOrNodeExpr | Constant | "(" Expr ")"; | 199 | Atom | VariableOrNodeExpr | Constant | "(" Expr ")"; |
200 | 200 | ||
201 | Atom: | 201 | Atom: |
202 | computed?="computed"? | ||
203 | relation=[Relation|QualifiedName] | 202 | relation=[Relation|QualifiedName] |
203 | computed?="<-"? | ||
204 | transitiveClosure?=TRANSITIVE_CLOSURE? | 204 | transitiveClosure?=TRANSITIVE_CLOSURE? |
205 | "(" (arguments+=Expr ("," arguments+=Expr)*)? ")"; | 205 | "(" (arguments+=Expr ("," arguments+=Expr)*)? ")"; |
206 | 206 | ||
diff --git a/subprojects/language/src/main/java/tools/refinery/language/parser/antlr/ProblemTokenSource.java b/subprojects/language/src/main/java/tools/refinery/language/parser/antlr/ProblemTokenSource.java index 487e4ceb..e483517a 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/parser/antlr/ProblemTokenSource.java +++ b/subprojects/language/src/main/java/tools/refinery/language/parser/antlr/ProblemTokenSource.java | |||
@@ -28,6 +28,8 @@ public class ProblemTokenSource implements TokenSource { | |||
28 | 28 | ||
29 | private boolean seenId; | 29 | private boolean seenId; |
30 | 30 | ||
31 | private boolean seenComputed; | ||
32 | |||
31 | private boolean lastVisible; | 33 | private boolean lastVisible; |
32 | 34 | ||
33 | public ProblemTokenSource(TokenSource delegate) { | 35 | public ProblemTokenSource(TokenSource delegate) { |
@@ -57,10 +59,13 @@ public class ProblemTokenSource implements TokenSource { | |||
57 | } else if (lastVisible && isQualifiedNameSeparator(token)) { | 59 | } else if (lastVisible && isQualifiedNameSeparator(token)) { |
58 | token.setType(InternalProblemParser.RULE_QUALIFIED_NAME_SEPARATOR); | 60 | token.setType(InternalProblemParser.RULE_QUALIFIED_NAME_SEPARATOR); |
59 | } | 61 | } |
62 | } else if (seenComputed && isPlusOrTransitiveClosure(token) && peekForTransitiveClosure()) { | ||
63 | token.setType(InternalProblemParser.RULE_TRANSITIVE_CLOSURE); | ||
60 | } | 64 | } |
61 | lastVisible = isVisibleToken(token); | 65 | lastVisible = isVisibleToken(token); |
62 | if (lastVisible) { | 66 | if (lastVisible) { |
63 | seenId = isIdentifier(token); | 67 | seenId = isIdentifier(token); |
68 | seenComputed = isComputed(token); | ||
64 | } | 69 | } |
65 | return token; | 70 | return token; |
66 | } | 71 | } |
@@ -82,6 +87,10 @@ public class ProblemTokenSource implements TokenSource { | |||
82 | return token.getType() == InternalProblemParser.ColonColon; | 87 | return token.getType() == InternalProblemParser.ColonColon; |
83 | } | 88 | } |
84 | 89 | ||
90 | protected boolean isComputed(Token token) { | ||
91 | return token.getType() == InternalProblemParser.LessThanSignHyphenMinus; | ||
92 | } | ||
93 | |||
85 | protected boolean isVisibleToken(Token token) { | 94 | protected boolean isVisibleToken(Token token) { |
86 | int tokenId = token.getType(); | 95 | int tokenId = token.getType(); |
87 | return tokenId != InternalProblemParser.RULE_WS && tokenId != InternalProblemParser.RULE_SL_COMMENT && | 96 | return tokenId != InternalProblemParser.RULE_WS && tokenId != InternalProblemParser.RULE_SL_COMMENT && |