Created
March 1, 2010 07:56
-
-
Save kmizu/318180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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