/*  j0c -- a compiler for j0
 * 
 *  the main compiler driver
 *  19.01.00, Matthias Zenger
 */

package j0c;

import java.io.*;


/** the main j0c compiler class
 */
public class Main {
    static public void main(String[] args) {
        try {
            Parser parser = new Parser(new FileInputStream(args[0]));
            Tree tree = parser.moduleDeclaration();
            parser.close();
            if (Report.errorLog.size() == 0) {
                Scope scope = Analyzer.analyzeTree(tree);
                if (Report.errorLog.size() == 0) {
                    Generator.generateCode(tree, scope);
                    return;
                }
            }
            System.out.println(Report.errorLog.size() + " errors detected");
        } catch (IOException e) {
            System.out.println(e.toString());
        }
    }
}
