aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/repl/REPL.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-17 16:57:10 +0100
committerMartin Odersky <odersky@gmail.com>2016-03-18 12:25:48 +0100
commitd8a7a59ef96127ca64f27e0cc2529d775b1fa9c9 (patch)
treed4e3a55d78195f82f750d3cac99ab59f2d6309e1 /src/dotty/tools/dotc/repl/REPL.scala
parente1fb19412c5dcc722e7df24e543aadf03a463c9a (diff)
downloaddotty-d8a7a59ef96127ca64f27e0cc2529d775b1fa9c9.tar.gz
dotty-d8a7a59ef96127ca64f27e0cc2529d775b1fa9c9.tar.bz2
dotty-d8a7a59ef96127ca64f27e0cc2529d775b1fa9c9.zip
Move all overridable bits into Config class
Central config class replaces mixture of parameters and fields. The fields were in part in the wrong class, where they could not easily be overridden.
Diffstat (limited to 'src/dotty/tools/dotc/repl/REPL.scala')
-rw-r--r--src/dotty/tools/dotc/repl/REPL.scala34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/repl/REPL.scala b/src/dotty/tools/dotc/repl/REPL.scala
index 2d6a3c742..e5ff2d3af 100644
--- a/src/dotty/tools/dotc/repl/REPL.scala
+++ b/src/dotty/tools/dotc/repl/REPL.scala
@@ -23,27 +23,37 @@ import java.io.{BufferedReader, File, FileReader, PrintWriter}
*/
class REPL extends Driver {
- /** The default input reader */
- def input(implicit ctx: Context): InteractiveReader = {
- val emacsShell = System.getProperty("env.emacs", "") != ""
- //println("emacsShell="+emacsShell) //debug
- if (ctx.settings.Xnojline.value || emacsShell) new SimpleReader()
- else InteractiveReader.createDefault()
- }
-
- /** The defult output writer */
- def output: PrintWriter = new NewLinePrintWriter(new ConsoleWriter, true)
+ lazy val config = new REPL.Config
override def newCompiler(implicit ctx: Context): Compiler =
- new repl.CompilingInterpreter(output, ctx)
+ new repl.CompilingInterpreter(config.output, ctx)
override def sourcesRequired = false
override def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter = {
if (fileNames.isEmpty)
- new InterpreterLoop(compiler, input, output).run()
+ new InterpreterLoop(compiler, config).run()
else
ctx.error(s"don't now what to do with $fileNames%, %")
ctx.reporter
}
}
+
+object REPL {
+ class Config {
+ val prompt = "scala> "
+ val continuationPrompt = " | "
+ val version = ".next (pre-alpha)"
+
+ /** The default input reader */
+ def input(implicit ctx: Context): InteractiveReader = {
+ val emacsShell = System.getProperty("env.emacs", "") != ""
+ //println("emacsShell="+emacsShell) //debug
+ if (ctx.settings.Xnojline.value || emacsShell) new SimpleReader()
+ else InteractiveReader.createDefault()
+ }
+
+ /** The default output writer */
+ def output: PrintWriter = new NewLinePrintWriter(new ConsoleWriter, true)
+ }
+}