aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/com/jantuomi/tunkki/Main.java
blob: dd4b2eab3f414714d4d6a3456b29d6e6ba8ac510 (plain)
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
package com.jantuomi.tunkki;

import com.jantuomi.tunkki.core.CommandLineArgumentContainer;
import com.jantuomi.tunkki.core.parser.ast.ASTNode;

import java.util.List;

public class Main {

    private static Tunkki tunkki;

    public static void main(String[] args) throws Exception {
        tunkki = new Tunkki();

        boolean parseSuccess = tunkki.parseArguments(args);
        if (!parseSuccess) {
            return;
        }

        if (CommandLineArgumentContainer.getInstance().isInteractive()) {
            tunkki.repl();
        } else {
            String sourceFileContents = CommandLineArgumentContainer.getInstance().getSourceFileContents();
            List<ASTNode> nodes = tunkki.parseAndInterpret(sourceFileContents);
            tunkki.executeAndOutput(nodes);
        }
    }

}