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
|
* A token, consisting of a Symbol type (should be a terminal) and a Value
|
||||||
*/
|
*/
|
||||||
struct Token {
|
struct Token {
|
||||||
|
Token(const {{name}}_Symbol& sym, const Value& val) : symbol(sym), value(val) {}
|
||||||
{{name}}_Symbol symbol;
|
{{name}}_Symbol symbol;
|
||||||
Value value;
|
Value value;
|
||||||
};
|
};
|
||||||
|
@ -84,7 +85,7 @@ Value {{name}}<Value>::parse() {
|
||||||
Token tok = lex();
|
Token tok = lex();
|
||||||
|
|
||||||
while (true) {
|
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) {
|
switch (act & 0x3) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
|
@ -100,7 +101,7 @@ Value {{name}}<Value>::parse() {
|
||||||
{
|
{
|
||||||
std::uint64_t tmp = act >> 2;
|
std::uint64_t tmp = act >> 2;
|
||||||
{{name}}_Symbol symbol = static_cast<{{name}}_Symbol>(tmp >> 31);
|
{{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;
|
std::deque<Token> dq;
|
||||||
for (unsigned char i = 0; i < REDUCE_COUNT[rule]; i++) {
|
for (unsigned char i = 0; i < REDUCE_COUNT[rule]; i++) {
|
||||||
|
@ -112,8 +113,8 @@ Value {{name}}<Value>::parse() {
|
||||||
switch (rule) {
|
switch (rule) {
|
||||||
{{#rules}}
|
{{#rules}}
|
||||||
case {{index}}:
|
case {{index}}:
|
||||||
{{#rname}}valueStack.emplace({symbol, reduce_{{rname}}(std::move(dq))});{{/rname}}
|
{{#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_{{index}}(std::move(dq)));{{/rname}}
|
||||||
break;
|
break;
|
||||||
{{/rules}}
|
{{/rules}}
|
||||||
default:
|
default:
|
||||||
|
@ -121,7 +122,7 @@ Value {{name}}<Value>::parse() {
|
||||||
break;
|
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;
|
break;
|
||||||
case ACCEPT:
|
case ACCEPT:
|
||||||
|
|
Loading…
Reference in New Issue