From 0fa4f162f4e42a455dbb7e7459854b9467337863 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 22 Apr 2016 14:48:25 -0400 Subject: Formatting changes --- .../dicelang/ast/DiceASTReferenceSanitizer.java | 78 +++++++++++----------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/DiceASTReferenceSanitizer.java') diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTReferenceSanitizer.java b/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTReferenceSanitizer.java index 3079bca..082c94a 100644 --- a/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTReferenceSanitizer.java +++ b/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTReferenceSanitizer.java @@ -20,45 +20,6 @@ import bjc.dicelang.ast.nodes.VariableDiceNode; * */ public class DiceASTReferenceSanitizer { - /** - * Sanitize the references in an AST - * - * @param ast - * @param enviroment - * @return The sanitized AST - */ - public static ITree sanitize(ITree ast, - IFunctionalMap> enviroment) { - return ast.topDownTransform( - DiceASTReferenceSanitizer::shouldSanitize, (subTree) -> { - return doSanitize(subTree, enviroment); - }); - } - - private static TopDownTransformResult shouldSanitize( - IDiceASTNode node) { - if (!node.isOperator()) { - return TopDownTransformResult.SKIP; - } - - switch (((OperatorDiceNode) node)) { - case ASSIGN: - return TopDownTransformResult.TRANSFORM; - case ARRAY: - case LET: - return TopDownTransformResult.PASSTHROUGH; - case ADD: - case CALL: - case COMPOUND: - case DIVIDE: - case GROUP: - case MULTIPLY: - case SUBTRACT: - default: - return TopDownTransformResult.SKIP; - } - } - private static ITree doSanitize(ITree ast, IFunctionalMap> enviroment) { if (ast.getChildrenCount() != 2) { @@ -199,4 +160,43 @@ public class DiceASTReferenceSanitizer { return null; } + + /** + * Sanitize the references in an AST + * + * @param ast + * @param enviroment + * @return The sanitized AST + */ + public static ITree sanitize(ITree ast, + IFunctionalMap> enviroment) { + return ast.topDownTransform( + DiceASTReferenceSanitizer::shouldSanitize, (subTree) -> { + return doSanitize(subTree, enviroment); + }); + } + + private static TopDownTransformResult shouldSanitize( + IDiceASTNode node) { + if (!node.isOperator()) { + return TopDownTransformResult.SKIP; + } + + switch (((OperatorDiceNode) node)) { + case ASSIGN: + return TopDownTransformResult.TRANSFORM; + case ARRAY: + case LET: + return TopDownTransformResult.PASSTHROUGH; + case ADD: + case CALL: + case COMPOUND: + case DIVIDE: + case GROUP: + case MULTIPLY: + case SUBTRACT: + default: + return TopDownTransformResult.SKIP; + } + } } -- cgit v1.2.3