diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-02 21:03:28 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-02 21:03:28 -0800 |
commit | 5cf89bb9d5e0d3c42610d3d2be47815ef41ecd65 (patch) | |
tree | 1bfa790b317c176ff7e087ab8ecad66d1130394b /scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala | |
parent | 5dbe9747db34b1aea95df002270e9634df533805 (diff) | |
download | hands-on-scala-js-5cf89bb9d5e0d3c42610d3d2be47815ef41ecd65.tar.gz hands-on-scala-js-5cf89bb9d5e0d3c42610d3d2be47815ef41ecd65.tar.bz2 hands-on-scala-js-5cf89bb9d5e0d3c42610d3d2be47815ef41ecd65.zip |
Moved new implementation out of test/ folder
Diffstat (limited to 'scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala')
-rw-r--r-- | scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala b/scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala new file mode 100644 index 0000000..9c39577 --- /dev/null +++ b/scalatexApi/src/main/scala/torimatomeru/syntax/Identifiers.scala @@ -0,0 +1,22 @@ +package torimatomeru +package syntax + +import org.parboiled2._ + +trait Identifiers { self: Parser with Basic => + + def Operator = rule(oneOrMore(OperatorChar)) + + def VarId = rule { !(Keywords ~ (WhitespaceChar | Newline | "//" | "/*")) ~ Lower ~ IdRest } + def PlainId = rule { Upper ~ IdRest | VarId | !(Keywords ~ (WhitespaceChar | Newline | "//" | "/*")) ~ Operator } + def Id = rule { PlainId | ("`" ~ oneOrMore(noneOf("`")) ~ "`") } + def IdRest = rule { zeroOrMore(Letter | Digit) ~ optional("_" ~ Operator) } + + + def Keywords = rule { + "abstract" | "case" | "catch" | "class" | "def" | "do" | "else" | "extends" | "false" | "finally" | "final" | "finally" | "forSome" | "for" | "if" | + "implicit" | "import" | "lazy" | "match" | "new" | "null" | "object" | "override" | "package" | "private" | "protected" | "return" | + "sealed" | "super" | "this" | "throw" | "trait" | "try" | "true" | "type" | "val" | "var" | "while" | "with" | "yield" | "_" | + ":" | ";" | "=>" | "=" | "<-" | "<:" | "<%" | ">:" | "#" | "@" | "\u21d2" | "\u2190" + } +} |