io.prophecy.abinitio.mp.pset.PSETTokenProcessor.scala Maven / Gradle / Ivy
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)
}
}