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

io.prophecy.abinitio.mp.pset.PSETTokenProcessor.scala Maven / Gradle / Ivy

There is a newer version: 6.3.0-3.3.0
Show newest version
package io.prophecy.abinitio.mp.pset

case class PSETTokens(tokens: Seq[PsetToken])

trait PSETTokenProcessorApply {
  def apply(tokens: PSETTokens): PSETTokens
}

/**
  * Abstract class which is extended by all steps needed to process existing MP tokens and convert them into new
  * set of MP tokens.
  *
  * @param tokens
  */
abstract class PSETTokenProcessor(tokens: PSETTokens) {

  def process(tokens: PSETTokens): PSETTokens
}

object PSETTokenProcessor {

  /**
    * List of steps to be executed one after other to process python tokens.
    */
  val processors: List[PSETTokenProcessorApply] = List(
    MergeMultipleTextValueTokens,
    InsertTokensSequenceIndex
  )

  def apply(tokens: PSETTokens): Either[PSETLexerError, PSETTokens] = {
    val psetTokens = processors.foldLeft(tokens) {
      case (tokens, processor) ⇒
        processor(tokens)
    }
    Right(psetTokens)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy