summaryrefslogtreecommitdiff
path: root/dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-10-27 21:56:18 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-10-27 22:12:47 -0400
commite7413128ff4e376997de6e94e4bea5eca14811ef (patch)
tree0749e270fdb754d04dc223abd95d47436508047f /dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java
parente13a6981bd278c2cfc3b5ecb2517367b117f7a52 (diff)
Moved examples
Diffstat (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java')
-rw-r--r--dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java73
1 files changed, 0 insertions, 73 deletions
diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java b/dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java
deleted file mode 100644
index b94bcc8..0000000
--- a/dice-lang/src/main/java/bjc/dicelang/ast/nodes/ILiteralDiceNode.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package bjc.dicelang.ast.nodes;
-
-/**
- * Represents a literal of some type in the AST
- *
- * @author ben
- *
- */
-public interface ILiteralDiceNode extends IDiceASTNode {
- /**
- * Check if a token represents a literal, and if so, what type
- *
- * @param tok
- * The token to check
- * @return The type the literal would be if it is one, or null
- * otherwise
- */
- static DiceLiteralType getLiteralType(String tok) {
- String diceGroupOrNumber = "[(?:\\d*d\\d+)(?:\\d+)]";
-
- if (tok.matches("\\A" + diceGroupOrNumber + "?" + "c"
- + diceGroupOrNumber + "\\Z")) {
- return DiceLiteralType.DICE;
- }
-
- String diceGroup = "\\d*d\\d+\\";
-
- if (tok.matches("\\A" + diceGroup + "Z")) {
- return DiceLiteralType.DICE;
- }
-
- try {
- Integer.parseInt(tok);
- return DiceLiteralType.INTEGER;
- } catch (@SuppressWarnings("unused") NumberFormatException nfex) {
- // We don't care about details
- return null;
- }
- }
-
- /**
- * Check if this node can be optimized to a constant
- *
- * @return Whether or not this node can be optimized to a constant
- * @see bjc.dicelang.IDiceExpression#canOptimize()
- */
- boolean canOptimize();
-
- /**
- * Get the type of literal this node represents
- *
- * @return The type of literal this node represents
- */
- DiceLiteralType getLiteralType();
-
- @Override
- default DiceASTType getType() {
- return DiceASTType.LITERAL;
- }
-
- @Override
- default boolean isOperator() {
- return false;
- }
-
- /**
- * Optimize this node to a constant if possible
- *
- * @return This node in constant form if possible
- * @see bjc.dicelang.IDiceExpression#optimize()
- */
- int optimize();
-}