package cs241e.scanparse

object DFAs {

  /** For convenience, we generally use `String`s to denote DFA states, but here we create a type alias
    * so that we can use the type `State` when we mean a DFA state. The Scala compiler will treat the
    * type `State` the same as if we had used the type `String` instead.
    */
  type State = String

  /** A representation of a deterministic finite automaton (DFA). */
  case class DFA( alphabet: Set[Char],
                  states: Set[State],
                  start: State,
                  accepting: Set[State],
                  transition: PartialFunction[(State, Char), State]
                  )

  /** A token that has been produced as the output of a scanner.
    * @param kind   is set to the accepting state of the scanning DFA that accepted the token.
    * @param lexeme is the string of actual characters that make up the token in the input to the scanner.
    */
  case class Token(kind: String, lexeme: String = "") {
    def size = lexeme.size
    override def toString = kind + " " + lexeme
  }
}