diff options
author | Paul Phillips <paulp@improving.org> | 2010-10-15 05:38:20 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-10-15 05:38:20 +0000 |
commit | c5c38fc6420ce5a22448a2eeb3b45e1644358575 (patch) | |
tree | d6a7ed0994c407520e932e1fe3fe0aefdccc72ce /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 185700607dc2fd12cf47a61f583bdbafd726558b (diff) | |
download | scala-c5c38fc6420ce5a22448a2eeb3b45e1644358575.tar.gz scala-c5c38fc6420ce5a22448a2eeb3b45e1644358575.tar.bz2 scala-c5c38fc6420ce5a22448a2eeb3b45e1644358575.zip |
There was a fascinating tangle of name creation...
There was a fascinating tangle of name creation functions passing around
positions only to reach the end of the line and discard the position
since names don't have positions. I deleted all of it. The winner for
most creative use of parameters was the freshName function in etaExpand,
with this signature:
def freshName(pos: util.Position, n: Int)
And an implementation referencing neither pos nor n. "In a world beset
by attrition on all sides... a people defeated by entropy... one man
will show them the power of deletion." No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 6f41b3ac47..997573f7f5 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -73,12 +73,10 @@ self => val in = new UnitScanner(unit, patches) in.init() - def freshName(pos: Position, prefix: String): Name = - unit.fresh.newName(pos, prefix) + def freshName(prefix: String): Name = unit.fresh.newName(prefix) def o2p(offset: Int): Position = new OffsetPosition(unit.source,offset) def r2p(start: Int, mid: Int, end: Int): Position = rangePos(unit.source, start, mid, end) - def warning(offset: Int, msg: String) { unit.warning(o2p(offset), msg) } def deprecationWarning(offset: Int, @@ -150,18 +148,12 @@ self => abstract class Parser { val in: Scanner - //val unit : CompilationUnit - //import in.ScanPosition - def freshName(pos: Position, prefix: String): Name - def freshName(prefix: String): Name = freshName(NoPosition, prefix) // todo get rid of position + def freshName(prefix: String): Name def o2p(offset: Int): Position def r2p(start: Int, mid: Int, end: Int): Position - //private implicit def p2i(pos: Position) = pos.offset.get /** whether a non-continuable syntax error has been seen */ - //private var syntaxErrorSeen = false - private var lastErrorOffset : Int = -1 object treeBuilder extends TreeBuilder { @@ -1002,7 +994,7 @@ self => /** WildcardType ::= `_' TypeBounds */ def wildcardType(start: Int) = { - val pname = freshName(o2p(start), "_$").toTypeName + val pname = freshName("_$").toTypeName val t = atPos(start) { Ident(pname) } val bounds = typeBounds() val param = atPos(t.pos union bounds.pos) { makeSyntheticTypeParam(pname, bounds) } @@ -1141,7 +1133,7 @@ self => case WHILE => val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshName(o2p(start), nme.WHILE_PREFIX) + val lname: Name = freshName(nme.WHILE_PREFIX) val cond = condExpr() newLinesOpt() val body = expr() @@ -1150,7 +1142,7 @@ self => case DO => val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshName(o2p(start), nme.DO_WHILE_PREFIX) + val lname: Name = freshName(nme.DO_WHILE_PREFIX) val body = expr() if (isStatSep) in.nextToken() accept(WHILE) @@ -1325,7 +1317,7 @@ self => path(true, false) case USCORE => val start = in.offset - val pname = freshName(o2p(start), "x$") + val pname = freshName("x$") in.nextToken() val id = atPos(start) (Ident(pname)) val param = atPos(id.pos.focus){ makeSyntheticParam(pname) } |