fork(1) download
  1. import scala.util.parsing.input._
  2. import scala.util.parsing.combinator._
  3.  
  4. object Main extends App with Parsers with RegexParsers {
  5. override def skipWhitespace = false
  6.  
  7. val pair = for (
  8. name <- """[^:]+""".r;
  9. _ <- """:\s*""".r;
  10. isMoron <- ("true" | "false").map(_.toBoolean)
  11. ) yield (name, isMoron)
  12. val morons = repsep(pair, """\r?\n""".r)
  13.  
  14. val input = """Bartek Banachewicz: false
  15. Ell: false
  16. Puppy: true
  17. rightfold: false"""
  18.  
  19. morons(new CharSequenceReader(input)) match {
  20. case Success(elements) =>
  21. elements.forEach { case (name, isMoron) =>
  22. println(s"$name is$(if (!isMoron) " not" else "") a moron!")
  23. }
  24. }
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:22: error: invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected
        println(s"$name is$(if (!isMoron) " not" else "") a moron!")
                       ^
Main.scala:22: error: unclosed string literal
        println(s"$name is$(if (!isMoron) " not" else "") a moron!")
                                                                  ^
two errors found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty