Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Jastadd2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
Jastadd2
Commits
7010d343
Commit
7010d343
authored
12 years ago
by
Jesper
Browse files
Options
Downloads
Patches
Plain Diff
Limit attribute problem checks
- don't check class and interface decls for attribute problems
parent
9825a6b2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jastadd/ast/AttributeProblems.jrag
+55
-38
55 additions, 38 deletions
src/jastadd/ast/AttributeProblems.jrag
with
55 additions
and
38 deletions
src/jastadd/ast/AttributeProblems.jrag
+
55
−
38
View file @
7010d343
...
...
@@ -43,16 +43,33 @@ aspect AttributeProblems {
/**
* Collects semantic problems for attributes.
*/
coll Collection<Problem> Grammar.attributeProblems()
syn Collection<Problem> Grammar.attributeProblems() {
Collection<Problem> problems = new LinkedList<Problem>();
for(int i = 0; i < getNumTypeDecl(); i++) {
problems.addAll(getTypeDecl(i).attributeProblems());
}
return problems;
}
coll Collection<Problem> TypeDecl.attributeProblems()
[new LinkedList<Problem>()]
with add;
with add
root TypeDecl;
syn Collection<Problem> ClassDecl.attributeProblems() =
// don't collect problems for attributes in TypeDecls
Collections.emptyList();
syn Collection<Problem> InterfaceDecl.attributeProblems() =
// don't collect problems for attributes in TypeDecls
Collections.emptyList();
SynEq contributes new Problem.Error(
"synthesized attribute " + name() + " assigned in class " + hostClass().name() + " is not declared",
getFileName(), getStartLine())
when decl() == null
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
/**
* @return Previous equation for same synthesized attribute
...
...
@@ -64,24 +81,24 @@ aspect AttributeProblems {
", previously defined in " + prevEq().getFileName() + ":" + prevEq().getStartLine(),
getFileName(), getStartLine())
when decl() != null && prevEq() != null && prevEq() != this
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
SynEq contributes new Problem.Error(
"equation must have the same parameter names as attribute declaration in " +
decl().getFileName() + ":" + decl().getStartLine(),
getFileName(), getStartLine())
when decl() != null && !decl().parametersDecl().equals(parametersDecl())
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
InhEq contributes new Problem.Error(
"equation must have the same parameter names as attribute declaration in " +
decl().getFileName() + ":" + decl().getStartLine(),
getFileName(), getStartLine())
when decl() != null && !decl().parametersDecl().equals(parametersDecl())
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn SynDecl SynDecl.prevDecl() = hostClass().lookupSynDecl(signature());
...
...
@@ -90,19 +107,19 @@ aspect AttributeProblems {
", previously declared in " + prevDecl().getFileName() + ":" + prevDecl().getStartLine(),
getFileName(), getStartLine())
when prevDecl() != null && prevDecl() != this
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
SynDecl contributes missingEqProblem()
when !missingEqs().isEmpty()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
SynDecl contributes new Problem.Error("return type for NTA must be an AST node",
getFileName(), getStartLine())
when getNTA() && !(hostClass().env().lookup(type().split("<")[0]) instanceof ASTDecl)
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn Problem SynDecl.missingEqProblem() {
StringBuilder buf = new StringBuilder();
...
...
@@ -154,8 +171,8 @@ aspect AttributeProblems {
InhEq contributes unknownChildProblem()
when hasUnknownChildProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean InhEq.hasUnknownChildProblem() =
getComponents() == null &&
...
...
@@ -174,8 +191,8 @@ aspect AttributeProblems {
InhEq contributes unknownNTAProblem()
when hasUnknownNTAProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean InhEq.hasUnknownNTAProblem() =
!hasUnknownChildProblem() &&
...
...
@@ -196,8 +213,8 @@ aspect AttributeProblems {
InhEq contributes multiDeclProblem()
when hasMultiDeclProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
/**
* @return Previous equation for this inherited attribute
...
...
@@ -218,8 +235,8 @@ aspect AttributeProblems {
InhEq contributes badIndexProblem()
when hasBadIndexProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean InhEq.hasBadIndexProblem() =
hasIndex() &&
...
...
@@ -236,8 +253,8 @@ aspect AttributeProblems {
InhDecl contributes multiDeclProblem()
when isDuplicateInhDecl()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn Problem InhDecl.multiDeclProblem() {
StringBuilder buf = new StringBuilder();
...
...
@@ -248,8 +265,8 @@ aspect AttributeProblems {
InhDecl contributes missingEqProblem()
when hasMissingEqProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean InhDecl.hasMissingEqProblem() =
!grammar().noInhEqCheck && !missingEqs().isEmpty();
...
...
@@ -292,8 +309,8 @@ aspect AttributeProblems {
CollDecl contributes unknownAnnotationProblem()
when hasUnknownAnnotationProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean CollDecl.hasUnknownAnnotationProblem() {
for (Iterator iter = annotations.iterator(); iter.hasNext(); ) {
...
...
@@ -324,8 +341,8 @@ aspect AttributeProblems {
CollDecl contributes collectionGroupProblem()
when hasCollectionGroupProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean CollDecl.hasCollectionGroupProblem() {
if (hasAnnotation("@CollectionGroup")) {
...
...
@@ -354,8 +371,8 @@ aspect AttributeProblems {
CollDecl contributes multipleRootsProblem()
when hasMultipleRootsProblem()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
syn boolean CollDecl.hasMultipleRootsProblem() =
root == null && hostClass().env().roots().size() != 1;
...
...
@@ -374,14 +391,14 @@ aspect AttributeProblems {
"no contributions for this collection attribute",
getFileName(), getStartLine())
when uses().isEmpty()
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
CollEq contributes new Problem.Error(
"undeclared collection attribute '" + name() + "'",
getFileName(), getStartLine())
when decl() == null
to
Grammar
.attributeProblems()
for
grammar
();
to
TypeDecl
.attributeProblems()
for
hostClass
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment