diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2018-03-01 19:13:48 -0500 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2018-03-01 19:13:48 -0500 |
| commit | f9d9bd4bbf7dd6a297e1daf5ee7b4263d706d9cd (patch) | |
| tree | 75ade2ca798bcdbdd7daf867480378299598581a /base/src/bjc/dicelang/expr/Parser.java | |
| parent | b14a399d05fc90d8532cd08d1546e6bf197db10e (diff) | |
Update
Diffstat (limited to 'base/src/bjc/dicelang/expr/Parser.java')
| -rw-r--r-- | base/src/bjc/dicelang/expr/Parser.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/base/src/bjc/dicelang/expr/Parser.java b/base/src/bjc/dicelang/expr/Parser.java index 1156334..020467a 100644 --- a/base/src/bjc/dicelang/expr/Parser.java +++ b/base/src/bjc/dicelang/expr/Parser.java @@ -9,13 +9,13 @@ import bjc.utils.data.ITree; */ 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. */ public static String toCanonicalExpr(final ITree<Token> ast) { final Token data = ast.getHead(); - if (ast.getChildrenCount() == 0) { + if(ast.getChildrenCount() == 0) { /* Handle leaf nodes. */ return data.toExpr(); } @@ -29,21 +29,21 @@ public class Parser { String rightExpr = toCanonicalExpr(right); /* Add parens if the left was higher priority. */ - if (left.getChildrenCount() == 0) { + if(left.getChildrenCount() == 0) { int leftPriority = left.getHead().typ.operatorPriority; int dataPriority = data.typ.operatorPriority; - if (leftPriority >= dataPriority) { + if(leftPriority >= dataPriority) { leftExpr = String.format("(%s)", leftExpr); } } /* Add parens if the right was higher priority. */ - if (right.getChildrenCount() == 0) { + if(right.getChildrenCount() == 0) { int rightPriority = right.getHead().typ.operatorPriority; int dataPriority = data.typ.operatorPriority; - if (rightPriority >= dataPriority) { + if(rightPriority >= dataPriority) { rightExpr = String.format("(%s)", rightExpr); } } |
