diff options
author | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 09:51:52 -0800 |
---|---|---|
committer | Li Haoyi <haoyi@dropbox.com> | 2014-11-28 09:51:52 -0800 |
commit | e65a5dde462be15d4fbb5db8e3be2d7365c99f08 (patch) | |
tree | 4a05070b848fa78dd4c50ebe448963359076d1ca /scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala | |
parent | 5809f06098535636ada8759f2f9db3e2aadc95ef (diff) | |
download | hands-on-scala-js-e65a5dde462be15d4fbb5db8e3be2d7365c99f08.tar.gz hands-on-scala-js-e65a5dde462be15d4fbb5db8e3be2d7365c99f08.tar.bz2 hands-on-scala-js-e65a5dde462be15d4fbb5db8e3be2d7365c99f08.zip |
Goes all the way to
scala / test / files / pos / dotless-targs.scala
Diffstat (limited to 'scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala')
-rw-r--r-- | scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala b/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala index 5456d16..a95afac 100644 --- a/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala +++ b/scalaParser/src/main/scala/scalaParser/syntax/Identifiers.scala @@ -8,15 +8,21 @@ trait Identifiers { self: Parser with Basic => import Basic._ def Operator = rule{!Keywords ~ oneOrMore(OperatorChar)} - def VarId = rule { !Keywords ~ Lower ~ IdRest } - def PlainId = rule { !Keywords ~ Upper ~ IdRest | VarId | Operator } + def VarId = VarId0(true) + def VarId0(dollar: Boolean) = rule { !Keywords ~ Lower ~ IdRest(dollar) } + def PlainId = rule { !Keywords ~ Upper ~ IdRest(true) | VarId | Operator } + def PlainIdNoDollar = rule { !Keywords ~ Upper ~ IdRest(false) | VarId0(false) | Operator } def Id = rule { !Keywords ~ PlainId | ("`" ~ oneOrMore(noneOf("`")) ~ "`") } - def IdRest = rule { - zeroOrMore(zeroOrMore("_") ~ oneOrMore(!"_" ~ Letter | Digit)) ~ - optional(oneOrMore("_") ~ zeroOrMore(OperatorChar)) + def IdRest(dollar: Boolean) = { + if (!dollar) rule { + zeroOrMore(zeroOrMore("_") ~ oneOrMore(!anyOf("_$") ~ Letter | Digit)) ~ + optional(oneOrMore("_") ~ zeroOrMore(OperatorChar)) + } else rule{ + zeroOrMore(zeroOrMore("_") ~ oneOrMore(!"_" ~ Letter | Digit)) ~ + optional(oneOrMore("_") ~ zeroOrMore(OperatorChar)) + } } - def AlphabetKeywords = rule { ( "abstract" | "case" | "catch" | "class" | "def" | "do" | "else" | "extends" | "false" | "finally" | "final" | "finally" | "forSome" | "for" | "if" | @@ -33,5 +39,6 @@ trait Identifiers { self: Parser with Basic => AlphabetKeywords | SymbolicKeywords } + } } |