Encapsulate ParseStackNodes

This commit is contained in:
Max Brunsfeld 2015-06-03 09:44:13 -07:00
parent 6330ae997b
commit aaaa1c8a5d
6 changed files with 405 additions and 350 deletions

View file

@ -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));;
}

View file

@ -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_