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

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

package jaskell.parsec

import scala.util.{Try, Success}

case class Int(val sign:Parsec[Char, Char] = Ch('-').attempt, 
                val uint: Parsec[Char, String] = new UInt()) extends Parsec[Char, String] {
    
    def apply(state: State[Char]):Try[String] = {
        val buffer = new StringBuilder()
        val s = sign ? state

        s foreach {buffer.append(_)}

        (uint ? state).flatMap { n =>
            buffer.append(n)
            Success(buffer.toString)
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy