From f028ea6dc555fc5192a96b00b8e96e90dbf6de55 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Mon, 9 Oct 2017 16:02:10 -0300 Subject: TODO tagging --- .../src/bjc/dicelang/scl/StreamControlConsole.java | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'dice-lang/src/bjc/dicelang/scl/StreamControlConsole.java') diff --git a/dice-lang/src/bjc/dicelang/scl/StreamControlConsole.java b/dice-lang/src/bjc/dicelang/scl/StreamControlConsole.java index 8ace8ad..649c6fa 100644 --- a/dice-lang/src/bjc/dicelang/scl/StreamControlConsole.java +++ b/dice-lang/src/bjc/dicelang/scl/StreamControlConsole.java @@ -8,21 +8,43 @@ import java.util.Scanner; import java.util.function.Supplier; +/** + * Implement a SCL REPL + * + * @author Ben Culkin + */ public class StreamControlConsole { + /* + * @TODO 10/08/17 :SCLArgs + * Do something useful with the CLI args. + * + */ + /** + * Main method + * + * @param args + * Unused CLI args. + */ public static void main(String[] args) { - /* Initialize vars. */ - /* We're not using the DiceLangEngine in the streams yet. */ - StreamEngine sengine = new StreamEngine(null); + /* + * Initialize vars. + * + * We can get away with passing the null, because StreamEngine + * doesn't reference any parts of DiceLangEngine. + */ + StreamEngine sengine = new StreamEngine(null); StreamControlEngine sclengine = new StreamControlEngine(sengine); - Scanner scn = new Scanner(System.in); + Scanner scn = new Scanner(System.in); /* Get input from the user. */ System.out.print("Enter a SCL command string (blank to exit): "); + /* Process it. */ while (scn.hasNextLine()) { - String ln = scn.nextLine(); + String ln = scn.nextLine().trim(); - if (ln.trim().equals("")) { + if (ln.equals("")) { + /* Ignore empty lines. */ break; } @@ -32,16 +54,16 @@ public class StreamControlConsole { /* Run the stream engine on the tokens. */ boolean succ = sengine.doStreams(tokens, res); - if (!succ) { + System.out.printf("ERROR: Stream engine failed for line '%s'\n", ln); continue; } /* Run the command through SCL. */ tokens = res.toArray(new String[res.getSize()]); succ = sclengine.runProgram(tokens); - if (!succ) { + System.out.printf("ERROR: SCL engine failed for line '%s'\n", ln); continue; } -- cgit v1.2.3