Homework 3
This commit is contained in:
parent
bf60a078d7
commit
0afc86ceeb
129 changed files with 3163 additions and 4316 deletions
|
@ -19,7 +19,10 @@ import cd.frontend.parser.JavaliLexer;
|
|||
import cd.frontend.parser.JavaliParser;
|
||||
import cd.frontend.parser.JavaliParser.UnitContext;
|
||||
import cd.frontend.parser.ParseFailure;
|
||||
import cd.frontend.semantic.SemanticAnalyzer;
|
||||
import cd.ir.Ast.ClassDecl;
|
||||
import cd.ir.Symbol;
|
||||
import cd.ir.Symbol.TypeSymbol;
|
||||
import cd.util.debug.AstDump;
|
||||
|
||||
/**
|
||||
|
@ -34,9 +37,15 @@ public class Main {
|
|||
// Set to non-null to write debug info out
|
||||
public Writer debug = null;
|
||||
|
||||
// Set to non-null to write dump of control flow graph
|
||||
// Set to non-null to write dump of control flow graph (Advanced Compiler Design)
|
||||
public File cfgdumpbase;
|
||||
|
||||
/** Symbol for the Main type */
|
||||
public Symbol.ClassSymbol mainType;
|
||||
|
||||
/** List of all type symbols, used by code generator. */
|
||||
public List<TypeSymbol> allTypeSymbols;
|
||||
|
||||
public void debug(String format, Object... args) {
|
||||
if (debug != null) {
|
||||
String result = String.format(format, args);
|
||||
|
@ -62,6 +71,9 @@ public class Main {
|
|||
|
||||
// Parse:
|
||||
List<ClassDecl> astRoots = m.parse(fin);
|
||||
|
||||
// Run the semantic check:
|
||||
m.semanticCheck(astRoots);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +106,11 @@ public class Main {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void semanticCheck(List<ClassDecl> astRoots) {
|
||||
{
|
||||
new SemanticAnalyzer(this).check(astRoots);
|
||||
}
|
||||
}
|
||||
|
||||
/** Dumps the AST to the debug stream */
|
||||
private void dumpAst(List<ClassDecl> astRoots) throws IOException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue