aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorAdrian Kummerländer2013-10-19 20:11:56 +0200
committerAdrian Kummerländer2013-10-19 20:11:56 +0200
commit9a95b5d24b2b2f5111e1862875d4136964a59548 (patch)
tree9ac96fdf846ae19e2278f9540593823fa8ba3b21 /src/utils.h
parentaca18e1803b3d54e6c9d7444e8b9c1bf09d12f52 (diff)
downloadSimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar.gz
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar.bz2
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar.lz
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar.xz
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.tar.zst
SimpleParser-9a95b5d24b2b2f5111e1862875d4136964a59548.zip
Improvement: Replaced "priority" with TokenType
* Made implementation more expressive by replacing the integer priority with an strictly typed enum called TokenType ** Made removal of character comparisons from tree construction and lexer possible * As a side effect distinct numbers had to be assigned to each token ** Operators of same priority do not have identical numbers anymore
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/utils.h b/src/utils.h
index f71c835..6e43605 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -8,7 +8,18 @@
namespace SimpleParser {
-int8_t getPriority(char);
+enum class TokenType : int8_t {
+ OPERATOR_PLUS = 10,
+ OPERATOR_MINUS = 11,
+ OPERATOR_DIVIDE = 20,
+ OPERATOR_MULTIPLY = 21,
+ OPERATOR_POWER = 30,
+ PARENTHESES_OPEN = 90,
+ PARENTHESES_CLOSE = 91,
+ VALUE_NUMBER = -1,
+};
+
+TokenType getTokenType(char);
std::vector<std::string> lexer(std::string);
}