From 054643900e7b857cafe123b0b4c03f10a95520ed Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Sun, 8 Oct 2017 16:38:35 -0300 Subject: Update --- dice-lang/src/bjc/dicelang/scl/StreamEngine.java | 62 ++++++++++-------------- 1 file changed, 25 insertions(+), 37 deletions(-) (limited to 'dice-lang/src/bjc/dicelang/scl/StreamEngine.java') diff --git a/dice-lang/src/bjc/dicelang/scl/StreamEngine.java b/dice-lang/src/bjc/dicelang/scl/StreamEngine.java index 5094283..191ab41 100644 --- a/dice-lang/src/bjc/dicelang/scl/StreamEngine.java +++ b/dice-lang/src/bjc/dicelang/scl/StreamEngine.java @@ -27,30 +27,20 @@ import java.util.Arrays; * @author Ben Culkin */ public class StreamEngine { - /* - * Whether or not we're doing debugging. - */ + /* Whether or not we're doing debugging. */ public final boolean debug = true; - /* - * The engine we're attached to. - */ + /* The engine we're attached to. */ DiceLangEngine eng; - /* - * Our streams. - */ + /* Our streams. */ Tape> streams; IList currStream; - /* - * Saved streams - */ + /* Saved streams */ TapeLibrary> savedStreams; - /* - * Handler for SCL programs - */ + /* Handler for SCL programs */ private final StreamControlEngine scleng; /** @@ -66,15 +56,12 @@ public class StreamEngine { scleng = new StreamControlEngine(this); } + /* Do pre-run (re)initialization. */ private void init() { - /* - * Reinitialize our list of streams. - */ + /* Reinitialize our list of streams. */ streams = new SingleTape<>(); - /* - * Create an initial stream. - */ + /* Create an initial stream. */ currStream = new FunctionalList<>(); streams.insertBefore(currStream); } @@ -94,28 +81,29 @@ public class StreamEngine { return doStreams(Arrays.asList(toks), dest); } + /** + * Process a possibly interleaved set of streams. + * + * @param toks + * The raw token to read streams from. + * + * @param dest + * The list to write the final stream to. + * + * @return Whether or not the streams were successfully processed. + */ public boolean doStreams(final Iterable toks, final IList dest) { - /* - * Initialize per-run state. - */ + /* Initialize per-run state. */ init(); - /* - * Are we currently quoting things? - */ + /* Are we currently quoting things? */ boolean quoteMode = false; - - /* - * Process each token. - */ + /* Process each token. */ for (final String tk : toks) { - /* - * Process stream commands. - */ + /* Process stream commands. */ if (tk.startsWith("{@S") && !quoteMode) { - if (tk.equals("{@SQ}")) { - quoteMode = true; - } else if (!processCommand(tk)) return false; + if (tk.equals("{@SQ}")) quoteMode = true; + else if (!processCommand(tk)) return false; } else { if (tk.equals("{@SU}")) { quoteMode = false; -- cgit v1.2.3