-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guard rename #95
base: main
Are you sure you want to change the base?
Guard rename #95
Conversation
I think the "new" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor requests. Personally, I think that the rename from Guard to Expression was necessary as it made the cod more clear as invariants should not be type Guard. However, I think we should revisit the structure of this AST. Should we instead of AndExpression
, OrExpression
, and BoolExpression
have a BinaryExpression
class. Instead of TrueExpression
and FalseExpression
we should consider Literal
with boolean value and integeger for boolValue
in BoolExpression
. Then we could have classes for Guard
and Invariant
. Making this change would follow a more conventional structure. For this reason, I think an issue on this should be opened and act as a dependency for #97.
src/models/AndExpression.java
Outdated
|
||
@Override | ||
public String prettyPrint() { | ||
return Expression.compositePrettyPrint(expressions, "&&"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this call does exactly the same as toString
.
src/models/OrExpression.java
Outdated
|
||
@Override | ||
public String prettyPrint() { | ||
return Expression.compositePrettyPrint(expressions, "||"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ìf toString
joins on ||
instead of or
then I think they are exactly the same
src/models/Expression.java
Outdated
@@ -3,11 +3,11 @@ | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
|
|||
public abstract class Guard { | |||
public abstract class Expression { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add some documentation to this class?
I am afraid I am misunderstanding, so I have a few questions in regards to the new structure you are suggesting: In regards to the grammar ( boolExpr : VARIABLE EQ BOOLEAN | VARIABLE operator INT;
operator : EQ | ORD ;
EQ : ('==' | '!=')
ORD: ('>=' | '<=' | '<' | '>') This may also let us omit the check in if (relation != Relation.EQUAL && relation != Relation.NOT_EQUAL) {
throw new IllegalArgumentException("The relation of the clock expression is invalid");
} |
Fixes #80
This PR is more or less just a big refactor. I have tried to rename
Guard
toExpression
andGuard
toInvariant
when it fits (Expression
in general, andInvariant
in context of locations). However, I have a few places I am uncertain if I should change or notsrc/logic/State.java l. 43
- We have these identical functions. Since it is aState
, I am not sure whether it is a guard, an inviriant, or just an expression we are applying.src/models/Federation.java l. 51
- Just to be sure, it should be the more general termExpression
used here instead ofGuard
? Or maybe just remove the function as it is currently unused (unless it will be used in the future)?src/models/Zone.java l. 53
- There are a lot of occurences ofGuard
in this file, but I am mainly thinking of the methodbuildConstraintsForGuard
, it this truly only happens when building guards on edges, or if this should be renamed to something more general.Expression
is to ambiguous, since it could be interpreted as both arithmetic and boolean expressions. Should It be renamed toBoolExpression
or something similar? And how should we then handle the distinction between the currentBoolExpression
and the "new"?