LARA

package minijava
 
import parser.Parser
import analyzer.Analyzer
 
class Compiler extends Reporter with Parser with Analyzer {
  import java.io.{FileInputStream,IOException,ByteArrayInputStream}
 
  def compile(fileName: String): Unit = {
    import parser.Trees._
    import analyzer.Symbols._
 
    // Parsing
    var parsedTree: Option[Tree] = None
    try {
      val in = new FileInputStream(fileName)
      parsedTree = Some(parseInputStream(in))
      in.close()
    } catch {
      case e: IOException => fatalError(e.getMessage)
    }
    terminateIfErrors
 
    val mainProg: Program = parsedTree match {
      case Some(p:Program) => p
      case _ => fatalError("Main program expected from parser.")
    }
 
    // Name analysis
    val global: GlobalScope = analyzeSymbols(mainProg)
    terminateIfErrors
 
    println(TreePrinter.withSymbolIDs(mainProg))
 
    ;
  }
}