Replace prec rule w/ left_assoc and right_assoc
Consider shift/reduce conflicts to be compilation errors unless they are resolved by a specified associativity.
This commit is contained in:
parent
86bd6eaa75
commit
80ec303b10
19 changed files with 27040 additions and 25946 deletions
|
|
@ -13,46 +13,57 @@ using rules::Symbol;
|
|||
ParseAction::ParseAction(ParseActionType type, ParseStateId state_index,
|
||||
Symbol symbol, size_t consumed_symbol_count,
|
||||
set<int> precedence_values,
|
||||
rules::Associativity associativity,
|
||||
int production_id)
|
||||
: type(type),
|
||||
symbol(symbol),
|
||||
state_index(state_index),
|
||||
consumed_symbol_count(consumed_symbol_count),
|
||||
precedence_values(precedence_values),
|
||||
associativity(associativity),
|
||||
production_id(production_id) {}
|
||||
|
||||
ParseAction::ParseAction()
|
||||
: type(ParseActionTypeError),
|
||||
symbol(Symbol(-1)),
|
||||
state_index(-1),
|
||||
consumed_symbol_count(0) {}
|
||||
consumed_symbol_count(0),
|
||||
associativity(rules::AssociativityUnspecified) {}
|
||||
|
||||
ParseAction ParseAction::Error() {
|
||||
return ParseAction(ParseActionTypeError, -1, Symbol(-1), 0, { 0 }, 0);
|
||||
return ParseAction();
|
||||
}
|
||||
|
||||
ParseAction ParseAction::Accept() {
|
||||
return ParseAction(ParseActionTypeAccept, -1, Symbol(-1), 0, { 0 }, 0);
|
||||
ParseAction action;
|
||||
action.type = ParseActionTypeAccept;
|
||||
return action;
|
||||
}
|
||||
|
||||
ParseAction ParseAction::Shift(ParseStateId state_index,
|
||||
set<int> precedence_values) {
|
||||
return ParseAction(ParseActionTypeShift, state_index, Symbol(-1), 0,
|
||||
precedence_values, 0);
|
||||
precedence_values, rules::AssociativityUnspecified, -1);
|
||||
}
|
||||
|
||||
ParseAction ParseAction::ShiftExtra() {
|
||||
return ParseAction(ParseActionTypeShiftExtra, 0, Symbol(-1), 0, { 0 }, 0);
|
||||
ParseAction action;
|
||||
action.type = ParseActionTypeShiftExtra;
|
||||
return action;
|
||||
}
|
||||
|
||||
ParseAction ParseAction::ReduceExtra(Symbol symbol) {
|
||||
return ParseAction(ParseActionTypeReduceExtra, 0, symbol, 0, { 0 }, 0);
|
||||
ParseAction action;
|
||||
action.type = ParseActionTypeReduceExtra;
|
||||
action.symbol = symbol;
|
||||
return action;
|
||||
}
|
||||
|
||||
ParseAction ParseAction::Reduce(Symbol symbol, size_t consumed_symbol_count,
|
||||
int precedence, int production_id) {
|
||||
int precedence, rules::Associativity associativity,
|
||||
int production_id) {
|
||||
return ParseAction(ParseActionTypeReduce, 0, symbol, consumed_symbol_count,
|
||||
{ precedence }, production_id);
|
||||
{ precedence }, associativity, production_id);
|
||||
}
|
||||
|
||||
bool ParseAction::operator==(const ParseAction &other) const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue