Encapsulate ParseStackNodes
This commit is contained in:
parent
6330ae997b
commit
aaaa1c8a5d
6 changed files with 405 additions and 350 deletions
|
|
@ -1,5 +1,10 @@
|
|||
#include "runtime/helpers/tree_helpers.h"
|
||||
|
||||
const char *symbol_names[12] = {
|
||||
"ERROR", "END", "DOCUMENT", "AMBIGUITY",
|
||||
"zero", "one", "two", "three", "four", "five", "six", "seven",
|
||||
};
|
||||
|
||||
TSTree ** tree_array(std::vector<TSTree *> trees) {
|
||||
TSTree ** result = (TSTree **)calloc(trees.size(), sizeof(TSTree *));
|
||||
for (size_t i = 0; i < trees.size(); i++)
|
||||
|
|
@ -18,3 +23,7 @@ std::ostream &operator<<(std::ostream &stream, const EqualsTree &matcher) {
|
|||
stream << std::string("equals tree: ") << std::string(ts_tree_string(matcher.expected, matcher.symbol_names));
|
||||
return stream;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, const TSTree *tree) {
|
||||
return stream << std::string(ts_tree_string(tree, symbol_names));;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
extern const char *symbol_names[12];
|
||||
|
||||
TSTree ** tree_array(std::vector<TSTree *> trees);
|
||||
|
||||
struct EqualsTree {
|
||||
|
|
@ -15,5 +17,6 @@ struct EqualsTree {
|
|||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, const EqualsTree &matcher);
|
||||
std::ostream &operator<<(std::ostream &stream, const TSTree *tree);
|
||||
|
||||
#endif // HELPERS_TREE_HELPERS_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue