Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Gestegård Robertz
LabComm
Commits
121b7a79
Commit
121b7a79
authored
11 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
some simple tests of void type check performed
parent
b25d312c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/TypeCheck.jrag
+13
-6
13 additions, 6 deletions
compiler/TypeCheck.jrag
examples/simple/simple.lc
+11
-0
11 additions, 0 deletions
examples/simple/simple.lc
with
24 additions
and
6 deletions
compiler/TypeCheck.jrag
+
13
−
6
View file @
121b7a79
aspect TypeCheck {
public void ASTNode.typeCheck() {
for (int i = 0; i < getNumChild(); i++) {
getChild(i).typeCheck();
}
// calls to the different type checks to be performed
nullTypeCheck();
}
// void is not allowed as a field in a struct or an array element
syn boolean Type.isNull();
eq Type.isNull() = false;
eq VoidType.isNull() = true;
eq UserType.isNull() = decl().isNull();
syn boolean TypeDecl.isNull();
eq TypeDecl.isNull() = getType().isNull();
public void ASTNode.nullTypeCheck() {}
public void Field.nullTypeCheck() {
if(getType().isNull()) {
error(getName() + "
: fields can
not be of type void");
error(
"field " +
getName() + "
may
not be of type void");
}
}
public void ParseArrayType.nullTypeCheck() {
if(getType().isNull()) {
error("array elements
can
not be of type void");
error("array elements
may
not be of type void");
}
}
public void ArrayType.nullTypeCheck() {
if(getType().isNull()) {
error("array elements
can
not be of type void");
error("array elements
may
not be of type void");
}
}
}
This diff is collapsed.
Click to expand it.
examples/simple/simple.lc
+
11
−
0
View file @
121b7a79
...
...
@@ -29,3 +29,14 @@ sample struct {
typedef void avoid;
sample avoid doavoid;
// examples of errors: void may not be used
// in structs or arrays
//
// sample struct {
// int a;
// avoid error;
//} foo;
//
//sample void error2[2] ;
//sample avoid error3[_];
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