From f9d9bd4bbf7dd6a297e1daf5ee7b4263d706d9cd Mon Sep 17 00:00:00 2001 From: bjculkin Date: Thu, 1 Mar 2018 19:13:48 -0500 Subject: Update --- base/src/bjc/dicelang/expr/ExprREPL.java | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'base/src/bjc/dicelang/expr/ExprREPL.java') diff --git a/base/src/bjc/dicelang/expr/ExprREPL.java b/base/src/bjc/dicelang/expr/ExprREPL.java index 49b9575..d763d67 100644 --- a/base/src/bjc/dicelang/expr/ExprREPL.java +++ b/base/src/bjc/dicelang/expr/ExprREPL.java @@ -17,7 +17,7 @@ public class ExprREPL { * Main method. * * @param args - * Unused CLI args. + * Unused CLI args. */ public static void main(final String[] args) { /* Create our objects. */ @@ -32,7 +32,7 @@ public class ExprREPL { String ln = scan.nextLine().trim(); /* Enter REPL loop. */ - while (!ln.equals("")) { + while(!ln.equals("")) { /* Print raw command. */ System.out.println("Raw command: " + ln); System.out.println(); @@ -40,13 +40,13 @@ public class ExprREPL { /* Lex command to infix tokens. */ final Token[] infixTokens = lex.lexString(ln, toks); System.out.println("Lexed tokens: "); - for (final Token tok : infixTokens) { + for(final Token tok : infixTokens) { System.out.println("\t" + tok); } /* Print out infix expression. */ System.out.print("Lexed expression: "); - for (final Token tok : infixTokens) { + for(final Token tok : infixTokens) { System.out.print(tok.toExpr() + " "); } @@ -57,13 +57,13 @@ public class ExprREPL { /* Shunt infix tokens to postfix tokens. */ final IList postfixTokens = Shunter.shuntTokens(infixTokens); System.out.println("Lexed tokens: "); - for (final Token tok : postfixTokens) { + for(final Token tok : postfixTokens) { System.out.println("\t" + tok); } /* Print out postfix tokens. */ System.out.print("Shunted expression: "); - for (final Token tok : postfixTokens) { + for(final Token tok : postfixTokens) { System.out.print(tok.toExpr() + " "); } @@ -71,10 +71,15 @@ public class ExprREPL { System.out.println(); System.out.println(); - /* Construct a tree from the list of postfixed tokens. */ - final ITree ast = TreeConstructor.constructTree(postfixTokens, tok -> tok.typ.isOperator); + /* + * Construct a tree from the list of postfixed tokens. + */ + final ITree ast = TreeConstructor.constructTree(postfixTokens, + tok -> tok.typ.isOperator); - /* Print the tree, then the canonical expression for it. */ + /* + * Print the tree, then the canonical expression for it. + */ System.out.println("Parsed tree"); System.out.println(ast.toString()); System.out.println("\nCanonical expr: " + Parser.toCanonicalExpr(ast)); -- cgit v1.2.3