Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
relational-rags
Commits
d6c9f0ce
Commit
d6c9f0ce
authored
Oct 09, 2019
by
Johannes Mey
Browse files
reordering of components is allowed
parent
2568fb4c
Pipeline
#4535
passed with stage
in 1 minute and 55 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/jastadd/Analysis.jrag
View file @
d6c9f0ce
...
@@ -62,12 +62,6 @@ aspect ComponentAnalysis {
...
@@ -62,12 +62,6 @@ aspect ComponentAnalysis {
eq Program.getChild().lookupComponent(TypeDecl td, String name)
eq Program.getChild().lookupComponent(TypeDecl td, String name)
= lookupComponentSyn(td, name);
= lookupComponentSyn(td, name);
syn Component Program.lookupComponentSyn(TypeDecl td, String name) {
syn Component Program.lookupComponentSyn(TypeDecl td, String name) {
// Check super type first to find duplicates (shadowing is not allowed)
if (td.hasSuper() && td.getSuper().decl() != null) {
Component c = lookupComponentSyn(td.getSuper().decl(), name);
if (c != null) return c;
}
for (Component c: td.getComponents()) {
for (Component c: td.getComponents()) {
if (c.name().equals(name)) {
if (c.name().equals(name)) {
return c;
return c;
...
@@ -84,6 +78,36 @@ aspect ComponentAnalysis {
...
@@ -84,6 +78,36 @@ aspect ComponentAnalysis {
return null;
return null;
}
}
syn boolean Component.isInvalidRedefinition() {
if (toTypeDecl() == null) return false;
TypeDecl td = toTypeDecl();
while (td.hasSuper() && td.getSuper().decl() != null) {
td = td.getSuper().decl();
Component c = lookupComponent(td, getID());
if (c != null && isTargetOfDirectedRelation()) return true;
if (c != null && !this.isEqual(c)) return true;
}
return false;
}
syn boolean Component.isEqual(Component c) = this.getClass() == c.getClass() && getTypeUse().isEqual(c.getTypeUse());
syn boolean TypeUse.isEqual(TypeUse u);
eq SimpleTypeUse.isEqual(TypeUse u) = u instanceof SimpleTypeUse && getID().equals(u.getID());
eq ParameterizedTypeUse.isEqual(TypeUse u) {
if (!getID().equals(u.getID())) return false;
if (!(u instanceof ParameterizedTypeUse)) return false;
ParameterizedTypeUse pu = (ParameterizedTypeUse) u;
if (getNumTypeUse() != pu.getNumTypeUse()) return false;
for (int i = 0; i < getNumTypeUse(); i++) {
if (!getTypeUse(i).isEqual(pu.getTypeUse(i))) return false;
}
return true;
}
syn RelationComponent RelationComponent.lookup(TypeDecl td, String name)
syn RelationComponent RelationComponent.lookup(TypeDecl td, String name)
= !isTargetOfDirectedRelation() && toTypeDecl() == td && name().equals(name)
= !isTargetOfDirectedRelation() && toTypeDecl() == td && name().equals(name)
? this
? this
...
...
src/main/jastadd/Errors.jrag
View file @
d6c9f0ce
...
@@ -20,6 +20,11 @@ aspect Errors {
...
@@ -20,6 +20,11 @@ aspect Errors {
when isAlreadyDeclared()
when isAlreadyDeclared()
to Program.errors();
to Program.errors();
Component contributes error("Component '" + name()
+ "' is an invalid redefition for type '" + toTypeDecl() + "'")
when isInvalidRedefinition()
to Program.errors();
RelationComponent contributes
RelationComponent contributes
error("Role name missing for type '" + toTypeDecl() + "'")
error("Role name missing for type '" + toTypeDecl() + "'")
when !isTargetOfDirectedRelation() && name().isEmpty()
when !isTargetOfDirectedRelation() && name().isEmpty()
...
...
src/test/jastadd/errors/Inheritance.expected
View file @
d6c9f0ce
Errors:
Errors:
$FILENAME Line
2
, column 12: Component 'X' is a
lready declared
for type 'B
1
'
$FILENAME Line
4
, column 12: Component 'X' is a
n invalid redefition
for type 'B
3
'
$FILENAME Line
6
, column 5: Component 'X' is a
lready declared
for type 'B2'
$FILENAME Line
7
, column 5: Component 'X' is a
n invalid redefition
for type 'B2'
src/test/jastadd/errors/Inheritance.relast
View file @
d6c9f0ce
A ::= X;
A ::= X;
B1 : A ::= X;
B1 : A ::= X;
B2 : A;
B2 : A;
B3 : A ::= <X:String>;
X;
X;
rel B2.X -> X;
rel B2.X -> X;
src/test/jastadd/errors/InheritanceLeft.expected
View file @
d6c9f0ce
Errors:
Errors:
$FILENAME Line
2
, column 12: Component 'X' is a
lready declared
for type 'B
1
'
$FILENAME Line
4
, column 12: Component 'X' is a
n invalid redefition
for type 'B
3
'
$FILENAME Line
6
, column 10: Component 'X' is a
lready declared
for type 'B2'
$FILENAME Line
7
, column 10: Component 'X' is a
n invalid redefition
for type 'B2'
src/test/jastadd/errors/InheritanceLeft.relast
View file @
d6c9f0ce
A ::= X;
A ::= X;
B1 : A ::= X;
B1 : A ::= X;
B2 : A;
B2 : A;
B3 : A ::= <X:String>;
X;
X;
rel X <- B2.X;
rel X <- B2.X;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment