|
@@ -0,0 +1,103 @@
|
|
|
|
+#include "TokenType.h"
|
|
|
|
+
|
|
|
|
+#include <iostream>
|
|
|
|
+
|
|
|
|
+TokenTypeClass::TokenTypeClass(string name, int level) : typeName(name)
|
|
|
|
+{
|
|
|
|
+ this->level = level;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TokenTypeClass::TokenTypeClass(string name) : typeName(name)
|
|
|
|
+{
|
|
|
|
+ level = -1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TokenTypeClass::TokenTypeClass(const TokenTypeClass& orig)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TokenTypeClass::~TokenTypeClass()
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+string TokenTypeClass::getName() const
|
|
|
|
+{
|
|
|
|
+ return typeName;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int TokenTypeClass::getLevel() const
|
|
|
|
+{
|
|
|
|
+ return level;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::ostream& operator<<(std::ostream& os, TokenType& c)
|
|
|
|
+{
|
|
|
|
+ return os << c->getName();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+namespace Tokens
|
|
|
|
+{
|
|
|
|
+ TokenType FLOAT = new const TokenTypeClass("float");
|
|
|
|
+ TokenType TRUE = new const TokenTypeClass("true");
|
|
|
|
+ TokenType FALSE = new const TokenTypeClass("false");
|
|
|
|
+ TokenType TNULL = new const TokenTypeClass("null");
|
|
|
|
+ TokenType TEXT = new const TokenTypeClass("String");
|
|
|
|
+ TokenType LABEL = new const TokenTypeClass("Label");
|
|
|
|
+ TokenType VAR = new const TokenTypeClass("var");
|
|
|
|
+ TokenType GLOBAL = new const TokenTypeClass("$");
|
|
|
|
+
|
|
|
|
+ TokenType INC = new const TokenTypeClass("++", 2);
|
|
|
|
+ TokenType DEC = new const TokenTypeClass("--", 2);
|
|
|
|
+ TokenType INVERT = new const TokenTypeClass("!", 2);
|
|
|
|
+ TokenType BIT_INVERT = new const TokenTypeClass("~", 2);
|
|
|
|
+ TokenType MUL = new const TokenTypeClass("*", 3);
|
|
|
|
+ TokenType DIV = new const TokenTypeClass("/", 3);
|
|
|
|
+ TokenType MOD = new const TokenTypeClass("%", 3);
|
|
|
|
+ TokenType ADD = new const TokenTypeClass("+", 4);
|
|
|
|
+ TokenType SUB = new const TokenTypeClass("-", 4);
|
|
|
|
+ TokenType LEFT_SHIFT = new const TokenTypeClass("<<", 5);
|
|
|
|
+ TokenType RIGHT_SHIFT = new const TokenTypeClass(">>", 5);
|
|
|
|
+ TokenType LESS = new const TokenTypeClass("<", 6);
|
|
|
|
+ TokenType LESS_EQUAL = new const TokenTypeClass("<=", 6);
|
|
|
|
+ TokenType GREATER = new const TokenTypeClass(">", 6);
|
|
|
|
+ TokenType GREATER_EQUAL = new const TokenTypeClass(">=", 6);
|
|
|
|
+ TokenType EQUAL = new const TokenTypeClass("==", 7);
|
|
|
|
+ TokenType NOT_EQUAL = new const TokenTypeClass("!=", 7);
|
|
|
|
+ TokenType BIT_AND = new const TokenTypeClass("&", 8);
|
|
|
|
+ TokenType BIT_XOR = new const TokenTypeClass("^", 9);
|
|
|
|
+ TokenType BIT_OR = new const TokenTypeClass("|", 10);
|
|
|
|
+ TokenType AND = new const TokenTypeClass("&&", 11);
|
|
|
|
+ TokenType OR = new const TokenTypeClass("||", 12);
|
|
|
|
+ TokenType SET = new const TokenTypeClass("=", 14);
|
|
|
|
+ TokenType ADD_SET = new const TokenTypeClass("+=", 14);
|
|
|
|
+ TokenType SUB_SET = new const TokenTypeClass("-=", 14);
|
|
|
|
+ TokenType MUL_SET = new const TokenTypeClass("*=", 14);
|
|
|
|
+ TokenType DIV_SET = new const TokenTypeClass("/=", 14);
|
|
|
|
+ TokenType MOD_SET = new const TokenTypeClass("%=", 14);
|
|
|
|
+ TokenType LEFT_SHIFT_SET = new const TokenTypeClass("<<=", 14);
|
|
|
|
+ TokenType RIGHT_SHIFT_SET = new const TokenTypeClass(">>=", 14);
|
|
|
|
+ TokenType BIT_AND_SET = new const TokenTypeClass("&=", 14);
|
|
|
|
+ TokenType BIT_XOR_SET = new const TokenTypeClass("^=", 14);
|
|
|
|
+ TokenType BIT_OR_SET = new const TokenTypeClass("|=", 14);
|
|
|
|
+ TokenType COMMA = new const TokenTypeClass(",", 15);
|
|
|
|
+ TokenType OPEN_BRACKET = new const TokenTypeClass("(", 1);
|
|
|
|
+ TokenType CLOSE_BRACKET = new const TokenTypeClass(")", 1);
|
|
|
|
+ TokenType OPEN_SQUARE_BRACKET = new const TokenTypeClass("[", 1);
|
|
|
|
+ TokenType CLOSE_SQUARE_BRACKET = new const TokenTypeClass("]", 1);
|
|
|
|
+ TokenType OPEN_CURVED_BRACKET = new const TokenTypeClass("{");
|
|
|
|
+ TokenType CLOSE_CURVED_BRACKET = new const TokenTypeClass("}");
|
|
|
|
+ TokenType SEMICOLON = new const TokenTypeClass(";");
|
|
|
|
+
|
|
|
|
+ TokenType IF = new const TokenTypeClass("if");
|
|
|
|
+ TokenType ELSE_IF = new const TokenTypeClass("else if");
|
|
|
|
+ TokenType ELSE = new const TokenTypeClass("else");
|
|
|
|
+ TokenType FOR = new const TokenTypeClass("for");
|
|
|
|
+ TokenType WHILE = new const TokenTypeClass("while");
|
|
|
|
+ TokenType FUNCTION = new const TokenTypeClass("function");
|
|
|
|
+ TokenType BREAK = new const TokenTypeClass("break");
|
|
|
|
+ TokenType CONTINUE = new const TokenTypeClass("continue");
|
|
|
|
+ TokenType RETURN = new const TokenTypeClass("return");
|
|
|
|
+ TokenType TRY = new const TokenTypeClass("try");
|
|
|
|
+ TokenType CATCH = new const TokenTypeClass("catch");
|
|
|
|
+ TokenType END_OF_FILE = new const TokenTypeClass("end_of_file");
|
|
|
|
+};
|