All Downloads are FREE. Search and download functionalities are using the official Maven repository.

encrywm.frontend.semantics.scope.SymbolTable.scala Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package encrywm.frontend.semantics.scope

import encrywm.frontend.semantics.error.AlreadyDefinedError

import scala.collection.mutable

trait SymbolTable {

  protected val symbols: mutable.TreeMap[String, Symbol] = mutable.TreeMap.empty[String, Symbol]

  def insert(sym: Symbol): Unit = {
    symbols.get(sym.name).map(_ => throw AlreadyDefinedError(sym.name))
    symbols.update(sym.name, sym)
  }

  def lookup(name: String, currentScopeOnly: Boolean = false): Option[Symbol] = symbols.get(name)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy