2014-04-17 13:20:43 -07:00
|
|
|
#include "compiler/build_tables/parse_item.h"
|
|
|
|
|
#include "tree_sitter/compiler.h"
|
|
|
|
|
|
|
|
|
|
namespace tree_sitter {
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::to_string;
|
|
|
|
|
using std::ostream;
|
|
|
|
|
|
|
|
|
|
namespace build_tables {
|
2014-04-28 20:43:27 -07:00
|
|
|
ParseItem::ParseItem(const rules::Symbol &lhs,
|
2014-04-17 13:20:43 -07:00
|
|
|
const rules::rule_ptr rule,
|
|
|
|
|
size_t consumed_symbol_count,
|
2014-04-28 20:43:27 -07:00
|
|
|
const rules::Symbol &lookahead_sym) :
|
2014-04-17 13:20:43 -07:00
|
|
|
Item(lhs, rule),
|
|
|
|
|
consumed_symbol_count(consumed_symbol_count),
|
|
|
|
|
lookahead_sym(lookahead_sym) {}
|
|
|
|
|
|
|
|
|
|
bool ParseItem::operator==(const ParseItem &other) const {
|
2014-04-23 08:32:11 -07:00
|
|
|
return
|
|
|
|
|
(other.lhs == lhs) &&
|
|
|
|
|
(other.consumed_symbol_count == consumed_symbol_count) &&
|
|
|
|
|
(other.lookahead_sym == lookahead_sym) &&
|
2014-04-28 18:31:03 -07:00
|
|
|
(other.rule == rule || other.rule->operator==(*rule));
|
2014-04-17 13:20:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& operator<<(ostream &stream, const ParseItem &item) {
|
|
|
|
|
return stream <<
|
|
|
|
|
string("#<item ") <<
|
|
|
|
|
item.lhs <<
|
|
|
|
|
string(" ") <<
|
|
|
|
|
*item.rule <<
|
|
|
|
|
string(" ") <<
|
|
|
|
|
to_string(item.consumed_symbol_count) <<
|
|
|
|
|
string(" ") <<
|
|
|
|
|
item.lookahead_sym <<
|
|
|
|
|
string(">");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|