ErrorCheck.jrag 656 Bytes
Newer Older
Anders Nilsson's avatar
Anders Nilsson committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Collection;

aspect ErrorCheck {

	syn int ASTNode.lineNumber() = getLine(getStart());

	protected String ASTNode.errors = null;
	
	protected void ASTNode.error(String s) {
	    s = "Error at " + lineNumber() + ": " + s;
	    if(errors == null) {
	      errors = s;
	    } else {
	      errors = errors + "\n" + s;
	    }
	}

	protected boolean ASTNode.hasErrors() {
		return errors != null;
	}
	public void ASTNode.errorCheck(Collection collection) {
	    nameCheck();
23
            typeCheck();
Anders Nilsson's avatar
Anders Nilsson committed
24
25
26
27
28
29
30
31
	    if(hasErrors())
		collection.add(errors);
	    for(int i = 0; i < getNumChild(); i++) {
		getChild(i).errorCheck(collection);
	    }
	}

}