Created
June 14, 2011 18:26
-
-
Save aereal/1025517 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
// vim:set noet sw=3 ts=3 sts=3 | |
import scala.util.parsing.combinator._ | |
import java.io.FileReader | |
class XselfParser extends RegexParsers { | |
def expression: Parser[Any] = opt("(")~rep(identifier)~opt(")") | |
def identifier: Parser[Any] = rep("""[a-zA-Z0-9]""".r | symbol) | |
def symbol: Parser[Any] = "~" | "!" | "@" | "$" | "%" | "^" | "&" | "*" | "-" | "_" | "=" | "+" | "|" | ":" | "<" | ">" | "/" | "?" | |
} | |
object Xself extends XselfParser { | |
def main(args: Array[String]) { | |
val reader = new FileReader(args(0)) | |
println(parseAll(expression, reader)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment