commit 2727bca0e623dfff1945e10a7662616169289dd5 Author: Jonathan Turner Date: Sat Oct 7 11:46:00 2023 -0400 Created Token Enums with Functions. diff --git a/src/edu/jt_kb/cs4308/compiler/models/Token.java b/src/edu/jt_kb/cs4308/compiler/models/Token.java new file mode 100644 index 0000000..db19eb9 --- /dev/null +++ b/src/edu/jt_kb/cs4308/compiler/models/Token.java @@ -0,0 +1,30 @@ +package edu.jt_kb.cs4308.compiler.models; + +public enum Token { + IDENT(0),ASS_OP(1),SUB_OP(2),DIV_OP(3),INT_LITERAL(4),SEMICOLON(5); + + public final int value; /* represents which Token you are referencing. */ + + /** + * Constructor for the ENUM to represent the value of each Token. + * + * @precondition: none + * @postcondition: A token is created. + * + * @param value - the integer value for the token. + */ + Token(int value) { + this.value = value; + } + + /** + * Compares two tokens and returns whether they are the same value or not. + * + * @param other - the other token being compared. + * @return if the values are the same, true + * else, false + */ + public boolean equals(Token other) { + return this.value == other.value; + } +}