/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of SimpleC. * * See the file "SimpleC-LICENSE" for Copyright information and * * the terms and conditions for copying, distribution and * * modification of SimpleC. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package org.sablecc.simplec; import org.sablecc.simplec.node.*; import org.sablecc.simplec.tool.*; import java.io.*; public class Main { public static void main(String[] arguments) { System.out.println(Version.banner()); if(arguments.length != 1) { System.out.println("usage:"); System.out.println(" java Main filename"); System.exit(1); } compile("", arguments[0]); } private static void compile(String dir, String name) { File f; if(dir.equals("")) { f = new File(name); } else { f = new File(dir, name); } if(f.isFile()) { compile(f); } else { System.out.println("Error: " + f.getAbsolutePath() + " does not exist."); } } private static void compile(File file) { try { System.out.println(); System.out.println("***************************************"); System.out.println(file.getAbsolutePath()); Node ast = TreeBuilder.getNode( new PushbackReader( new BufferedReader( new FileReader(file)), 1024)); ast.apply(new ModifyAST()); Declarations declarations = new Declarations((Start)ast); PointsTo pto = new PointsTo((Start)ast, declarations); System.out.println(pto); } catch(Exception e) { e.printStackTrace(System.out); } } }