More fixes
This commit is contained in:
parent
eaf2786738
commit
c2542719eb
|
@ -33,6 +33,7 @@ class {{name}} {
|
|||
* A token, consisting of a Symbol type (should be a terminal) and a Value
|
||||
*/
|
||||
struct Token {
|
||||
Token(const {{name}}_Symbol& sym, const Value& val) : symbol(sym), value(val) {}
|
||||
{{name}}_Symbol symbol;
|
||||
Value value;
|
||||
};
|
||||
|
@ -84,7 +85,7 @@ Value {{name}}<Value>::parse() {
|
|||
Token tok = lex();
|
||||
|
||||
while (true) {
|
||||
std::uint64_t act = TABLE[stateStack.top()][tok.symbol];
|
||||
std::uint64_t act = TABLE[stateStack.top()][static_cast<std::uint64_t>(tok.symbol)];
|
||||
|
||||
switch (act & 0x3) {
|
||||
case ERROR:
|
||||
|
@ -100,7 +101,7 @@ Value {{name}}<Value>::parse() {
|
|||
{
|
||||
std::uint64_t tmp = act >> 2;
|
||||
{{name}}_Symbol symbol = static_cast<{{name}}_Symbol>(tmp >> 31);
|
||||
std::uint32_t rule = tmp & ((1ull << 32) - 1);
|
||||
std::uint32_t rule = tmp & ((1ull << 31) - 1);
|
||||
|
||||
std::deque<Token> dq;
|
||||
for (unsigned char i = 0; i < REDUCE_COUNT[rule]; i++) {
|
||||
|
@ -112,8 +113,8 @@ Value {{name}}<Value>::parse() {
|
|||
switch (rule) {
|
||||
{{#rules}}
|
||||
case {{index}}:
|
||||
{{#rname}}valueStack.emplace({symbol, reduce_{{rname}}(std::move(dq))});{{/rname}}
|
||||
{{^rname}}valueStack.emplace({symbol, reduce_{{index}}(std::move(dq))});{{/rname}}
|
||||
{{#rname}}valueStack.emplace(symbol, reduce_{{rname}}(std::move(dq)));{{/rname}}
|
||||
{{^rname}}valueStack.emplace(symbol, reduce_{{index}}(std::move(dq)));{{/rname}}
|
||||
break;
|
||||
{{/rules}}
|
||||
default:
|
||||
|
@ -121,7 +122,7 @@ Value {{name}}<Value>::parse() {
|
|||
break;
|
||||
}
|
||||
|
||||
stateStack.push(TABLE[stateStack.top()][valueStack.top().symbol] >> 2);
|
||||
stateStack.push(TABLE[stateStack.top()][static_cast<std::uint64_t>(valueStack.top().symbol)] >> 2);
|
||||
}
|
||||
break;
|
||||
case ACCEPT:
|
||||
|
|
Loading…
Reference in New Issue