diff options
author | Adrian Kummerländer | 2013-10-20 00:10:54 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2013-10-20 00:10:54 +0200 |
commit | cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7 (patch) | |
tree | 02eda2354acb6462977cf9c6babcbd62b446d0e2 /src/tree.h | |
parent | 2b5ed18ae11439897a64708a434e5d7a6edac91e (diff) | |
download | SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar.gz SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar.bz2 SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar.lz SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar.xz SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.tar.zst SimpleParser-cf2aa4c9d70fc8ed658c213b2c46bb48ee10e6f7.zip |
Implemented constant identifier functionality
* SimpleParser optionally acceps a pointer to an ConstantMap containing string keys mapping to values
* Constants are handled in their own ConstantNode class derived from the standard Node class
* Operator precedence is now determined separated from the TokenType using a new PrecedenceLevel enum
** Conversion between tokens and their PrecedenceLevel is possible using the new utility function getPrecedence
* Added additional test cases for constant identifier resolutions
Diffstat (limited to 'src/tree.h')
-rw-r--r-- | src/tree.h | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,17 +1,20 @@ #ifndef PARSER_SRC_NODE_H_ #define PARSER_SRC_NODE_H_ -#include <vector> -#include <string> #include <memory> +#include <string> +#include <vector> #include "nodes.h" namespace SimpleParser { +typedef std::vector<std::unique_ptr<Node>> NodeCollection; + class Tree { public: Tree(std::string); + Tree(std::string, const ConstantMap*); double solve(); std::string print(); @@ -21,9 +24,10 @@ class Tree { Node* addNode(Node**, Args&&... args); Node* buildTree(std::string); - std::vector<std::unique_ptr<Node>> node_collection_; - Node* root_node_; std::string term_; + Node* root_node_; + NodeCollection node_collection_; + const ConstantMap* constants_; }; } |