summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-13 16:41:45 -0400
committerEVE <EVE@EVE-PC>2017-03-13 16:41:45 -0400
commit01136c6796e21f023713e026674576d8e623462d (patch)
treee77886fe0e0adaf3c0430fba9ce248ef83f74fe4 /dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java
parent870d769cfc152171d27b2331a7c590d0b307ad48 (diff)
Formatting
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java b/dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java
index 92658b6..4d710fe 100644
--- a/dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java
+++ b/dice-lang/src/bjc/dicelang/v1/ast/DiceASTUtils.java
@@ -20,12 +20,11 @@ public class DiceASTUtils {
* Check if a dice AST contains a simple variable reference
*
* @param nameTree
- * The tree to check for a reference in
+ * The tree to check for a reference in
* @return Whether or not a dice AST contains a simple variable
* reference
*/
- public static boolean containsSimpleVariable(
- ITree<IDiceASTNode> nameTree) {
+ public static boolean containsSimpleVariable(ITree<IDiceASTNode> nameTree) {
return nameTree.transformHead((nameNode) -> {
if (nameNode.getType() != DiceASTType.VARIABLE) {
return false;
@@ -39,28 +38,26 @@ public class DiceASTUtils {
* Convert an literal AST node to a dice expression, if possible.
*
* @param tree
- * The node to convert in tree form
+ * The node to convert in tree form
* @return The tree as a dice expression
*
* @throws ClassCastException
- * if the head of the tree is not a literal (implements
- * {@link ILiteralDiceNode})
+ * if the head of the tree is not a literal (implements
+ * {@link ILiteralDiceNode})
* @throws UnsupportedOperationException
- * if the head of the tree is not optimizable
+ * if the head of the tree is not optimizable
*/
- public static IDiceExpression literalToExpression(
- ITree<IDiceASTNode> tree) {
+ public static IDiceExpression literalToExpression(ITree<IDiceASTNode> tree) {
ILiteralDiceNode literalNode = (ILiteralDiceNode) tree.getHead();
switch (literalNode.getLiteralType()) {
- case DICE:
- return ((DiceLiteralNode) literalNode).getValue();
- case INTEGER:
- return new ScalarDie(
- ((IntegerLiteralNode) literalNode).getValue());
- default:
- throw new UnsupportedOperationException(
- "This type of literal isn't convertable to an expression");
+ case DICE:
+ return ((DiceLiteralNode) literalNode).getValue();
+ case INTEGER:
+ return new ScalarDie(((IntegerLiteralNode) literalNode).getValue());
+ default:
+ throw new UnsupportedOperationException(
+ "This type of literal isn't convertable to an expression");
}
}
@@ -68,14 +65,14 @@ public class DiceASTUtils {
* Convert an literal AST node to an integer, if possible.
*
* @param tree
- * The literal node to convert, as a tree
+ * The literal node to convert, as a tree
* @return The node as an integer
*
* @throws ClassCastException
- * if the head of the tree is not a literal (implements
- * {@link ILiteralDiceNode})
+ * if the head of the tree is not a literal (implements
+ * {@link ILiteralDiceNode})
* @throws UnsupportedOperationException
- * if the head of the tree is not optimizable
+ * if the head of the tree is not optimizable
*/
public static int literalToInteger(ITree<IDiceASTNode> tree) {
return tree.transformHead((node) -> {