More C++ LR templates
This commit is contained in:
parent
06b1ef75e1
commit
07e02b2386
|
@ -0,0 +1,13 @@
|
|||
#include "{{name}}.h"
|
||||
|
||||
#define TABLE {{name}}___Table___{{name}}
|
||||
#define REDUCE_COUNT {{name}}___Num_Reduces___{{name}}
|
||||
|
||||
const std::uint64_t TABLE[{{num_states}}][{{num_symbols}}] = {
|
||||
{{#states}}
|
||||
{ {{#actions}}({{name}}::{{action}} | {{data}} << 2),{{/actions}}
|
||||
{{#gotos}}({{data}} << 2),{{/gotos}} },
|
||||
{{/states}}
|
||||
};
|
||||
|
||||
const unsigned char REDUCE_COUNT[{{num_rules}}] = { {{#rules}}{{rhs_length}}{{/rules}} };
|
|
@ -60,8 +60,8 @@ class {{name}} {
|
|||
#define TABLE {{name}}___Table___{{name}}
|
||||
#define REDUCE_COUNT {{name}}___Num_Reduces___{{name}}
|
||||
// Not a static member because the table should not be replicated for different instantiations of the parser
|
||||
extern const std::uint64_t TABLE[%(num_states)][%(num_symbols)];
|
||||
extern const unsigned char REDUCE_COUNT[%(num_rules)];
|
||||
extern const std::uint64_t TABLE[{{num_states}}][{{num_symbols}}];
|
||||
extern const unsigned char REDUCE_COUNT[{{num_rules}}];
|
||||
|
||||
enum Action {
|
||||
ERROR = 0,
|
||||
|
|
Loading…
Reference in New Issue