From 8094fc813a29d447555863b6c32816229ff01958 Mon Sep 17 00:00:00 2001 From: student Date: Mon, 12 Feb 2018 12:59:01 -0500 Subject: Formatting pass --- base/src/bjc/dicelang/expr/Parser.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'base/src/bjc/dicelang/expr/Parser.java') diff --git a/base/src/bjc/dicelang/expr/Parser.java b/base/src/bjc/dicelang/expr/Parser.java index 5fa2d3d..3dc10ea 100644 --- a/base/src/bjc/dicelang/expr/Parser.java +++ b/base/src/bjc/dicelang/expr/Parser.java @@ -14,14 +14,14 @@ import bjc.utils.parserutils.TreeConstructor; */ public class Parser { /* - * @TODO 10/08/17 Ben Culkin :MainSeperation - * This main method should be moved to its own class. + * @TODO 10/08/17 Ben Culkin :MainSeperation This main method should be moved to + * its own class. */ /** * Main method. * * @param args - * Unused CLI args. + * Unused CLI args. */ public static void main(final String[] args) { /* Create our objects. */ @@ -76,12 +76,10 @@ public class Parser { System.out.println(); /* Construct a list from the array of tokens. */ - final FunctionalList tokList = new FunctionalList<>( - Arrays.asList(postfixTokens)); + final FunctionalList tokList = new FunctionalList<>(Arrays.asList(postfixTokens)); /* Construct a tree from the list of postfixed tokens. */ - final ITree ast = TreeConstructor.constructTree(tokList, - tok -> tok.typ.isOperator); + final ITree ast = TreeConstructor.constructTree(tokList, tok -> tok.typ.isOperator); /* Print the tree, then the canonical expression for it. */ System.out.println("Parsed tree"); @@ -103,8 +101,8 @@ public class Parser { } /* - * Convert an expression to one that uses the smallest necessary amount - * of parens. + * Convert an expression to one that uses the smallest necessary amount of + * parens. */ private static String toCanonicalExpr(final ITree ast) { final Token data = ast.getHead(); @@ -115,11 +113,11 @@ public class Parser { } /* The left/right children. */ - final ITree left = ast.getChild(0); + final ITree left = ast.getChild(0); final ITree right = ast.getChild(1); /* Recursively canonicalize them. */ - String leftExpr = toCanonicalExpr(left); + String leftExpr = toCanonicalExpr(left); String rightExpr = toCanonicalExpr(right); /* Add parens if the left was higher priority. */ @@ -135,7 +133,7 @@ public class Parser { /* Add parens if the right was higher priority. */ if (right.getChildrenCount() == 0) { int rightPriority = right.getHead().typ.operatorPriority; - int dataPriority = data.typ.operatorPriority; + int dataPriority = data.typ.operatorPriority; if (rightPriority >= dataPriority) { rightExpr = String.format("(%s)", rightExpr); -- cgit v1.2.3