aoc2023/Common.scala
2023-12-05 10:08:40 +01:00

17 lines
448 B
Scala

//> using dep org.scala-lang.modules::scala-parser-combinators::2.3.0
package aoc
import scala.util.parsing.combinator._
def iterate[T](get: => T | Null) =
Iterator.continually(get).takeWhile(_ != null).map(_.nn)
def lines = iterate(scala.io.StdIn.readLine())
class CommonParser extends RegexParsers:
val num = """(0|[1-9]\d*)""".r ^^ { _.toInt }
val long = """(0|[1-9]\d*)""".r ^^ { _.toLong }
object CommonParser extends CommonParser