diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-08-08 18:52:33 +0200 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-08-14 11:45:47 +0200 |
commit | a06a771dea3ade03c85fb3835632a8bc54392d5e (patch) | |
tree | 6fb68ad62baac31e0103398c2fc6703d918f7abc /src/repl | |
parent | 5439c4c9aa9ef03c061fa9c2c4689a722729b8f9 (diff) | |
download | scala-a06a771dea3ade03c85fb3835632a8bc54392d5e.tar.gz scala-a06a771dea3ade03c85fb3835632a8bc54392d5e.tar.bz2 scala-a06a771dea3ade03c85fb3835632a8bc54392d5e.zip |
refactor parser entry points and extract a few methods out
This commit contains three logical changes:
1. Split `templateStatSeq` into two methods as we need more reliable
parsing of template body alone for new `parseStats` entry point.
2. Add new parser entry point called `parseStats` which is aimed towards
use in tools that require parsing of Scala code that can be written
inside of a template.
Such functionality is required for parsing lines in repl, parsing
code through toolbox, parsing and running scala scripts and lastly
for quasiquotes. All of them are refactored to use this very method
in the next commits.
A new method called `templateStatsCompat` is also added to make this
commit pass the tests but it's a temporary hack that will be removed
in next commit in favor of `parseStats`.
3. Extract out a few methods like `isCaseDefStart`, `expectedMsgTemplate`
and `parseRule`. These are needed to override parser behaviour in
updated quasiquotes parser (see next commits).
Diffstat (limited to 'src/repl')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ExprTyper.scala | 2 | ||||
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala index 9353215e1e..e79fc310bb 100644 --- a/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala @@ -28,7 +28,7 @@ trait ExprTyper { result } - def stmts(code: String) = applyRule(code, _.templateStats()) + def stmts(code: String) = applyRule(code, _.templateStatsCompat()) } /** Parse a line into a sequence of trees. Returns None if the input is incomplete. */ diff --git a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala index 8b8b668c9f..8c5162d788 100644 --- a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -190,7 +190,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput // literal Ints, Strings, etc. object literals extends CompletionAware { - def simpleParse(code: String): Tree = newUnitParser(code).templateStats().last + def simpleParse(code: String): Tree = newUnitParser(code).templateStatsCompat().last def completions(verbosity: Int) = Nil override def follow(id: String) = simpleParse(id) match { |