summaryrefslogtreecommitdiff
path: root/sources/scala/tools/scalai/InterpreterCommand.java
blob: 9b538d5b49b8cd621ad3a68339ff4acad127a2a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $OldId: InterpreterCommand.java,v 1.3 2002/09/02 12:58:22 paltherr Exp $
// $Id$

package scalai;

import scalac.PhaseRepository;
import scalac.CompilerCommand;
import scalac.util.Reporter;
import scalac.util.StringOptionParser;
import scalac.util.BooleanOptionParser;
import scalac.util.ScalaProgramArgumentParser;

public class InterpreterCommand extends CompilerCommand {

    //########################################################################
    // Public Fields

    public final StringOptionParser script;
    public final BooleanOptionParser interactive;
    public final BooleanOptionParser emacs;
    public final ScalaProgramArgumentParser program;

    //########################################################################
    // Public Constructors

    public InterpreterCommand(String product, String version,
        Reporter reporter, PhaseRepository phases)
    {
        this(product, version, "<source files> [-- <module> <args>]",
            reporter, phases);
    }

    public InterpreterCommand(String product, String version, String syntax,
        Reporter reporter, PhaseRepository phases)
    {
        super(product, version, syntax, reporter, phases);

        this.script = new StringOptionParser(this,
            "c", "Evaluate <string> and print result",
            "string", null);

        this.interactive = new BooleanOptionParser(this,
            "interactive", "Start interpreter in interactive mode",
            false);

        this.emacs = new BooleanOptionParser(this,
            "emacs", "Use Emacs editing mode",
            false);

        this.program = new ScalaProgramArgumentParser(this);

        remove(outpath);
        remove(target);

        add(0, script);
        add(1, interactive);
        add(2, emacs);
        add(parsers().indexOf(unknown_options), program);
    }

    //########################################################################
}