LARA

package toolc
 
import parser.Parser
import analyzer.Analyzer
 
import scala.io.Source
 
class Compiler(val fileName: String)
  extends Reporter
  with Parser
  with Analyzer {
 
  val source: Source = Source.fromFile(fileName).withPositioning(true)
 
  def compile: Unit = {
    import parser.Trees._
    import analyzer.Symbols._
 
    // Parsing
    var parsedTree: Option[Tree] = None
    parsedTree = Some(parseSource)
    terminateIfErrors
 
    val mainProg: Program = parsedTree match {
      case Some(p:Program) => p
      case _ => scala.Predef.error("Main program expected from parser.")
    }
 
    // Name analysis
    val global: GlobalScope = analyzeSymbols(mainProg)
    terminateIfErrors
 
    // Pretty-printing with symbols
    println(TreePrinter.withSymbolIDs(mainProg))
  }
}