Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created March 1, 2010 07:56
Show Gist options
  • Save kmizu/318180 to your computer and use it in GitHub Desktop.
Save kmizu/318180 to your computer and use it in GitHub Desktop.
/*
* This file can be compiled only in Scala 2.8.0 or later version.
* In Scala 2.7.X, this file cannot be compiled.
*/
import scala.util.parsing.combinator._
import scala.util.matching._
trait ImplicitDisabledRegexParsers {parsers: RegexParsers =>
override def literal(s: String): Parser[String] = parsers.literal(s)
override def regex(r: Regex): Parser[String] = parsers.regex(r)
}
object RegexParserExample extends RegexParsers
with ImplicitDisabledRegexParsers {
val ident: Parser[String] = regex("""[a-zA-Z_][a-zA-Z0-9_]*""".r)
//The following line causes compilation error.
//val ident: Parser[String] = """[a-zA-Z_][a-zA-Z0-9_]*""".r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment