diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-23 19:13:43 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-23 19:13:43 +0000 |
commit | f52d79f1fb5cda9ea79041b6ba628a678db99162 (patch) | |
tree | fcf367d93b3bc4ddfb5d3b197c71fed5ed5310c3 /src | |
parent | 10be8dc7854ad1c7a21d86e0e3675d5231384aa5 (diff) | |
download | scala-f52d79f1fb5cda9ea79041b6ba628a678db99162.tar.gz scala-f52d79f1fb5cda9ea79041b6ba628a678db99162.tar.bz2 scala-f52d79f1fb5cda9ea79041b6ba628a678db99162.zip |
You know Cutty McPastington is having a good ti...
You know Cutty McPastington is having a good time when you can find this
logic in two different files:
('A' <= c && c <= 'Z') ||
('a' <= c && c <= 'a') ||
How could that possibly work, you might ask. After a series of ||s, the
last condition subsumes most of the previous ones:
Character.isUnicodeIdentifierStart(c)
thereby saving us from a world where the only legal lower case
identifiers are a, aa, aaa, aaaa, and a few others. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/javac/JavaScanners.scala | 20 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/StdNames.scala | 13 | ||||
-rwxr-xr-x | src/compiler/scala/tools/nsc/util/Chars.scala | 9 |
3 files changed, 5 insertions, 37 deletions
diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index dd9d2a87c6..6a698a0708 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -685,24 +685,6 @@ trait JavaScanners { // Identifiers --------------------------------------------------------------- - def isIdentStart(c: Char): Boolean = ( - ('A' <= c && c <= 'Z') || - ('a' <= c && c <= 'a') || - (c == '_') || (c == '$') || - Character.isUnicodeIdentifierStart(c) - ) - - def isIdentPart(c: Char) = ( - isIdentStart(c) || - ('0' <= c && c <= '9') || - Character.isUnicodeIdentifierPart(c) - ) - - def isSpecial(c: Char) = { - val chtp = Character.getType(c) - chtp == Character.MATH_SYMBOL.toInt || chtp == Character.OTHER_SYMBOL.toInt - } - private def getIdentRest { while (true) { (in.ch: @switch) match { @@ -894,7 +876,7 @@ trait JavaScanners { in.next return getFraction case _ => - if (!isIdentStart(lookahead.ch)) { + if (!isIdentifierStart(lookahead.ch)) { putChar(in.ch) in.next return getFraction diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 8fbdf680e6..5c7e7925ea 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -8,6 +8,7 @@ package scala.tools.nsc package symtab import scala.reflect.NameTransformer +import util.Chars.isOperatorPart trait StdNames extends reflect.generic.StdNames { self: SymbolTable => @@ -101,19 +102,9 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable => def isTraitSetterName(name: Name) = isSetterName(name) && name.pos(TRAIT_SETTER_SEPARATOR_STRING) < name.length def isOpAssignmentName(name: Name) = name(name.length - 1) == '=' && - isOperatorCharacter(name(0)) && + isOperatorPart(name(0)) && name(0) != '=' && name != NEraw && name != LEraw && name != GEraw - def isOperatorCharacter(c: Char) = c match { - case '~' | '!' | '@' | '#' | '%' | - '^' | '*' | '+' | '-' | '<' | - '>' | '?' | ':' | '=' | '&' | - '|' | '\\'| '/' => true - case _ => - val chtp = Character.getType(c) - chtp == Character.MATH_SYMBOL.toInt || chtp == Character.OTHER_SYMBOL.toInt - } - /** The expanded setter name of `name' relative to this class `base` */ def expandedSetterName(name: Name, base: Symbol): Name = diff --git a/src/compiler/scala/tools/nsc/util/Chars.scala b/src/compiler/scala/tools/nsc/util/Chars.scala index 0b33b9efd9..5a64f36eb4 100755 --- a/src/compiler/scala/tools/nsc/util/Chars.scala +++ b/src/compiler/scala/tools/nsc/util/Chars.scala @@ -50,16 +50,11 @@ object Chars { /** Can character start an alphanumeric Scala identifier? */ def isIdentifierStart(c: Char): Boolean = - ('A' <= c && c <= 'Z') || - ('a' <= c && c <= 'a') || - (c == '_') || (c == '$') || - Character.isUnicodeIdentifierStart(c) + (c == '_') || (c == '$') || Character.isUnicodeIdentifierStart(c) /** Can character form part of an alphanumeric Scala identifier? */ def isIdentifierPart(c: Char) = - isIdentifierStart(c) || - ('0' <= c && c <= '9') || - Character.isUnicodeIdentifierPart(c) + (c == '$') || Character.isUnicodeIdentifierPart(c) /** Is character a math or other symbol in Unicode? */ def isSpecial(c: Char) = { |