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

jaskell.parsec.NewLine.scala Maven / Gradle / Ivy

package jaskell.parsec

import scala.util.{Success, Try}

/**
 * Newline match \n char
 *
 * @author mars
 * @version 1.0.0
 */
class Newline extends Parsec[Char, Char]{

  def apply(s: State[Char]): Try[Char] = {
    s.next() flatMap { c =>
      if(c == '\n') {
        Success(c)
      } else {
        s.trap(s"Expect a newline char but get $c")
      }
    }
  }
}

object Newline {
  def apply(): Newline = new Newline()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy