grammars: fix copy rule skipping (again) & display of expectations

This commit is contained in:
Olivier Chafik 2024-04-12 18:56:14 +01:00
parent 2d98ebf0f7
commit ec913426be
2 changed files with 185 additions and 151 deletions

View file

@ -174,11 +174,11 @@ namespace grammar_parser {
// Sstar ::= Scopy Sstar |
uint32_t content_rule_id = 0;
if (last_sym_start == out_elements.size() - 1) {
if (last_sym_start >= 0 && last_sym_start == out_elements.size() - 1 && out_elements[last_sym_start].type == LLAMA_GRETYPE_RULE_REF) {
// The repeated content is already a rule ref, no need to copy it
content_rule_id = out_elements[last_sym_start].value;
} else {
content_rule_id = generate_symbol_id(state, rule_name);
content_rule_id = generate_symbol_id(state, rule_name + "_copy");
// add preceding symbol to generated copy rule
std::vector<llama_grammar_element> copy_rule(out_elements.begin() + last_sym_start, out_elements.end());
copy_rule.push_back({LLAMA_GRETYPE_END, 0});

View file

@ -24,6 +24,11 @@ static void verify_parsing(const char *grammar_bytes, const std::vector<std::pai
uint32_t index = 0;
grammar_parser::parse_state parsed_grammar = grammar_parser::parse(grammar_bytes);
std::map<uint32_t, std::string> symbol_names;
for (auto it = parsed_grammar.symbol_ids.begin(); it != parsed_grammar.symbol_ids.end(); ++it) {
symbol_names[it->second] = it->first;
}
auto print_all = [&]() {
fprintf(stderr, " verify_parsing(R\"\"\"(%s)\"\"\", {\n", grammar_bytes);
for (auto it = parsed_grammar.symbol_ids.begin(); it != parsed_grammar.symbol_ids.end(); ++it) {
@ -31,7 +36,7 @@ static void verify_parsing(const char *grammar_bytes, const std::vector<std::pai
}
fprintf(stderr, " }, {\n");
for (size_t i_rule = 0; i_rule < parsed_grammar.rules.size(); i_rule++) {
fprintf(stderr, " // %s (index %zu)\n", expected[i_rule].first.c_str(), i_rule);
fprintf(stderr, " // %s (index %zu)\n", symbol_names[i_rule].c_str(), i_rule);
auto & rule = parsed_grammar.rules[i_rule];
for (uint32_t i = 0; i < rule.size(); i++) {
std::string rule_str;
@ -51,7 +56,7 @@ static void verify_parsing(const char *grammar_bytes, const std::vector<std::pai
fprintf(stderr, "'%c'", c);
}
} else if (rule[i].type == LLAMA_GRETYPE_RULE_REF) {
fprintf(stderr, "/* %s */ %u", expected[rule[i].value].first.c_str(), rule[i].value);
fprintf(stderr, "/* %s */ %u", symbol_names[rule[i].value].c_str(), rule[i].value);
} else {
fprintf(stderr, "%u", rule[i].value);
}
@ -132,6 +137,14 @@ static void verify_failure(const char *grammar_bytes) {
int main()
{
verify_failure(R"""(
root ::= "a"{,}"
)""");
verify_failure(R"""(
root ::= "a"{,10}"
)""");
verify_parsing(R"""(
root ::= "a"
)""", {
@ -164,19 +177,23 @@ int main()
root ::= "a"+
)""", {
{"root", 0},
{"root_1", 1},
{"root_star_2", 2},
{"root_2", 2},
{"root_copy_1", 1},
{"root_star_3", 3},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_star_2 */ 2},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_star_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_star_2 */ 2},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_END, 0},
// root_star_3 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
@ -185,17 +202,21 @@ int main()
root ::= "a"?
)""", {
{"root", 0},
{"root_1", 1},
{"root_1_2", 2},
{"root_1_3", 3},
{"root_2", 2},
{"root_copy_1", 1},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* root_1_2 */ 2},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_1_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_1_3 */ 3},
{LLAMA_GRETYPE_END, 0},
// root_1_3 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
@ -204,18 +225,22 @@ int main()
root ::= "a"*
)""", {
{"root", 0},
{"root_1", 1},
{"root_star_2", 2},
{"root_2", 2},
{"root_copy_1", 1},
{"root_star_3", 3},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* root_star_2 */ 2},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_star_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_star_2 */ 2},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_END, 0},
// root_star_3 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
@ -224,14 +249,18 @@ int main()
root ::= "a"{2}
)""", {
{"root", 0},
{"root_1", 1},
{"root_2", 2},
{"root_copy_1", 1},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_END, 0},
});
@ -239,20 +268,24 @@ int main()
root ::= "a"{2,}
)""", {
{"root", 0},
{"root_1", 1},
{"root_star_2", 2},
{"root_2", 2},
{"root_copy_1", 1},
{"root_star_3", 3},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_END, 0},
// root_star_3 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_3 */ 3},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
@ -261,16 +294,20 @@ int main()
root ::= "a"{ 4}
)""", {
{"root", 0},
{"root_1", 1},
{"root_2", 2},
{"root_copy_1", 1},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_END, 0},
});
@ -278,37 +315,33 @@ int main()
root ::= "a"{2,4}
)""", {
{"root", 0},
{"root_1", 1},
{"root_1_2", 2},
{"root_2_3", 3},
{"root_1_3", 3},
{"root_2", 2},
{"root_2_4", 4},
{"root_copy_1", 1},
}, {
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 2},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_2 */ 3},
// root_copy_1 (index 1)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_END, 0},
// root_1_3 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
// root_2 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_2_4 */ 4},
{LLAMA_GRETYPE_END, 0},
// root_1_3 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// root_2 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* */ 97},
{LLAMA_GRETYPE_RULE_REF, /* root_1_3 */ 2},
// root_2_4 (index 4)
{LLAMA_GRETYPE_RULE_REF, /* root_copy_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_1_3 */ 3},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
verify_failure(R"""(
root ::= "a"{,}"
)""");
verify_failure(R"""(
root ::= "a"{,10}"
)""");
verify_parsing(R"""(
root ::= (expr "=" term "\n")+
expr ::= term ([-+*/] term)*
@ -324,59 +357,59 @@ int main()
{"root_star_5", 5},
{"term", 3},
{"term_10", 10},
{"term_9", 9},
{"term_copy_9", 9},
{"term_star_11", 11},
}, {
// expr (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root */ 4},
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_4 */ 4},
{LLAMA_GRETYPE_END, 0},
// expr_6 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* expr_7 */ 2},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* expr */ 2},
{LLAMA_GRETYPE_CHAR, '='},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_8 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* term */ 3},
{LLAMA_GRETYPE_CHAR, '\n'},
{LLAMA_GRETYPE_END, 0},
// expr_7 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* expr_star_8 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* root_star_5 */ 7},
// expr (index 2)
{LLAMA_GRETYPE_RULE_REF, /* term */ 3},
{LLAMA_GRETYPE_RULE_REF, /* expr_7 */ 7},
{LLAMA_GRETYPE_END, 0},
// expr_star_8 (index 3)
{LLAMA_GRETYPE_RULE_REF, /* term_9 */ 10},
// term (index 3)
{LLAMA_GRETYPE_RULE_REF, /* term_10 */ 10},
{LLAMA_GRETYPE_END, 0},
// root (index 4)
{LLAMA_GRETYPE_RULE_REF, /* expr_6 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 5},
// root_4 (index 4)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_5 */ 5},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 5)
{LLAMA_GRETYPE_RULE_REF, /* expr_6 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 5},
// root_star_5 (index 5)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_5 */ 5},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// root_4 (index 6)
// expr_6 (index 6)
{LLAMA_GRETYPE_CHAR, '-'},
{LLAMA_GRETYPE_CHAR_ALT, '+'},
{LLAMA_GRETYPE_CHAR_ALT, '*'},
{LLAMA_GRETYPE_CHAR_ALT, '/'},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_8 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* term */ 3},
{LLAMA_GRETYPE_END, 0},
// root_star_5 (index 7)
{LLAMA_GRETYPE_RULE_REF, /* term */ 8},
// expr_7 (index 7)
{LLAMA_GRETYPE_RULE_REF, /* expr_star_8 */ 8},
{LLAMA_GRETYPE_END, 0},
// term (index 8)
{LLAMA_GRETYPE_RULE_REF, /* root_4 */ 6},
{LLAMA_GRETYPE_RULE_REF, /* term */ 8},
// expr_star_8 (index 8)
{LLAMA_GRETYPE_RULE_REF, /* expr_6 */ 6},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_8 */ 8},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// term_10 (index 9)
// term_copy_9 (index 9)
{LLAMA_GRETYPE_CHAR, '0'},
{LLAMA_GRETYPE_CHAR_RNG_UPPER, '9'},
{LLAMA_GRETYPE_END, 0},
// term_9 (index 10)
{LLAMA_GRETYPE_RULE_REF, /* term_10 */ 9},
// term_10 (index 10)
{LLAMA_GRETYPE_RULE_REF, /* term_copy_9 */ 9},
{LLAMA_GRETYPE_RULE_REF, /* term_star_11 */ 11},
{LLAMA_GRETYPE_END, 0},
// term_star_11 (index 11)
{LLAMA_GRETYPE_RULE_REF, /* term_10 */ 9},
{LLAMA_GRETYPE_RULE_REF, /* term_copy_9 */ 9},
{LLAMA_GRETYPE_RULE_REF, /* term_star_11 */ 11},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
@ -395,12 +428,12 @@ int main()
{"expr_8", 8},
{"expr_star_9", 9},
{"ident", 10},
{"ident_12", 12},
{"ident_13", 13},
{"ident_copy_12", 12},
{"ident_star_14", 14},
{"num", 11},
{"num_15", 15},
{"num_16", 16},
{"num_copy_15", 15},
{"num_star_17", 17},
{"root", 0},
{"root_1", 1},
@ -408,101 +441,101 @@ int main()
{"root_star_6", 6},
{"term", 4},
{"ws", 3},
{"ws_18", 18},
{"ws_19", 19},
{"ws_copy_18", 18},
{"ws_star_20", 20},
}, {
// expr (index 0)
{LLAMA_GRETYPE_RULE_REF, /* ident_12 */ 5},
// root (index 0)
{LLAMA_GRETYPE_RULE_REF, /* root_5 */ 5},
{LLAMA_GRETYPE_END, 0},
// expr_7 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* expr_8 */ 2},
// root_1 (index 1)
{LLAMA_GRETYPE_RULE_REF, /* expr */ 2},
{LLAMA_GRETYPE_CHAR, '='},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* ident */ 4},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 3},
{LLAMA_GRETYPE_RULE_REF, /* term */ 4},
{LLAMA_GRETYPE_CHAR, '\n'},
{LLAMA_GRETYPE_END, 0},
// expr_8 (index 2)
{LLAMA_GRETYPE_RULE_REF, /* ident */ 4},
{LLAMA_GRETYPE_RULE_REF, /* num */ 8},
// expr (index 2)
{LLAMA_GRETYPE_RULE_REF, /* term */ 4},
{LLAMA_GRETYPE_RULE_REF, /* expr_8 */ 8},
{LLAMA_GRETYPE_END, 0},
// expr_star_9 (index 3)
// ws (index 3)
{LLAMA_GRETYPE_RULE_REF, /* ws_19 */ 19},
{LLAMA_GRETYPE_END, 0},
// ident (index 4)
{LLAMA_GRETYPE_RULE_REF, /* num_16 */ 10},
// term (index 4)
{LLAMA_GRETYPE_RULE_REF, /* ident */ 10},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_RULE_REF, /* num_star_17 */ 11},
{LLAMA_GRETYPE_RULE_REF, /* num */ 11},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_CHAR, '('},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* expr_8 */ 2},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 3},
{LLAMA_GRETYPE_RULE_REF, /* expr */ 2},
{LLAMA_GRETYPE_CHAR, ')'},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 3},
{LLAMA_GRETYPE_END, 0},
// ident_12 (index 5)
{LLAMA_GRETYPE_RULE_REF, /* expr_7 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* ident_13 */ 6},
// root_5 (index 5)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_6 */ 6},
{LLAMA_GRETYPE_END, 0},
// ident_13 (index 6)
{LLAMA_GRETYPE_RULE_REF, /* expr_7 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* ident_13 */ 6},
// root_star_6 (index 6)
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 1},
{LLAMA_GRETYPE_RULE_REF, /* root_star_6 */ 6},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// ident_star_14 (index 7)
// expr_7 (index 7)
{LLAMA_GRETYPE_CHAR, '-'},
{LLAMA_GRETYPE_CHAR_ALT, '+'},
{LLAMA_GRETYPE_CHAR_ALT, '*'},
{LLAMA_GRETYPE_CHAR_ALT, '/'},
{LLAMA_GRETYPE_RULE_REF, /* ident */ 4},
{LLAMA_GRETYPE_RULE_REF, /* term */ 4},
{LLAMA_GRETYPE_END, 0},
// num (index 8)
{LLAMA_GRETYPE_RULE_REF, /* num_15 */ 9},
// expr_8 (index 8)
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 9},
{LLAMA_GRETYPE_END, 0},
// num_15 (index 9)
{LLAMA_GRETYPE_RULE_REF, /* ident_star_14 */ 7},
{LLAMA_GRETYPE_RULE_REF, /* num_15 */ 9},
// expr_star_9 (index 9)
{LLAMA_GRETYPE_RULE_REF, /* expr_7 */ 7},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 9},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// num_16 (index 10)
// ident (index 10)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_CHAR_RNG_UPPER, 'z'},
{LLAMA_GRETYPE_RULE_REF, /* root_1 */ 13},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 3},
{LLAMA_GRETYPE_RULE_REF, /* ident_13 */ 13},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 3},
{LLAMA_GRETYPE_END, 0},
// num_star_17 (index 11)
{LLAMA_GRETYPE_RULE_REF, /* term */ 16},
{LLAMA_GRETYPE_RULE_REF, /* expr_star_9 */ 3},
// num (index 11)
{LLAMA_GRETYPE_RULE_REF, /* num_16 */ 16},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 3},
{LLAMA_GRETYPE_END, 0},
// root (index 12)
// ident_copy_12 (index 12)
{LLAMA_GRETYPE_CHAR, 'a'},
{LLAMA_GRETYPE_CHAR_RNG_UPPER, 'z'},
{LLAMA_GRETYPE_CHAR_ALT, '0'},
{LLAMA_GRETYPE_CHAR_RNG_UPPER, '9'},
{LLAMA_GRETYPE_CHAR_ALT, '_'},
{LLAMA_GRETYPE_END, 0},
// root_1 (index 13)
{LLAMA_GRETYPE_RULE_REF, /* root_5 */ 14},
// ident_13 (index 13)
{LLAMA_GRETYPE_RULE_REF, /* ident_star_14 */ 14},
{LLAMA_GRETYPE_END, 0},
// root_5 (index 14)
{LLAMA_GRETYPE_RULE_REF, /* root */ 12},
{LLAMA_GRETYPE_RULE_REF, /* root_5 */ 14},
// ident_star_14 (index 14)
{LLAMA_GRETYPE_RULE_REF, /* ident_copy_12 */ 12},
{LLAMA_GRETYPE_RULE_REF, /* ident_star_14 */ 14},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// root_star_6 (index 15)
// num_copy_15 (index 15)
{LLAMA_GRETYPE_CHAR, '0'},
{LLAMA_GRETYPE_CHAR_RNG_UPPER, '9'},
{LLAMA_GRETYPE_END, 0},
// term (index 16)
{LLAMA_GRETYPE_RULE_REF, /* root_star_6 */ 15},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 17},
// num_16 (index 16)
{LLAMA_GRETYPE_RULE_REF, /* num_copy_15 */ 15},
{LLAMA_GRETYPE_RULE_REF, /* num_star_17 */ 17},
{LLAMA_GRETYPE_END, 0},
// ws (index 17)
{LLAMA_GRETYPE_RULE_REF, /* root_star_6 */ 15},
{LLAMA_GRETYPE_RULE_REF, /* ws */ 17},
// num_star_17 (index 17)
{LLAMA_GRETYPE_RULE_REF, /* num_copy_15 */ 15},
{LLAMA_GRETYPE_RULE_REF, /* num_star_17 */ 17},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
// ws_18 (index 18)
// ws_copy_18 (index 18)
{LLAMA_GRETYPE_CHAR, ' '},
{LLAMA_GRETYPE_CHAR_ALT, '\t'},
{LLAMA_GRETYPE_CHAR_ALT, '\n'},
@ -511,11 +544,12 @@ int main()
{LLAMA_GRETYPE_RULE_REF, /* ws_star_20 */ 20},
{LLAMA_GRETYPE_END, 0},
// ws_star_20 (index 20)
{LLAMA_GRETYPE_RULE_REF, /* ws_18 */ 18},
{LLAMA_GRETYPE_RULE_REF, /* ws_copy_18 */ 18},
{LLAMA_GRETYPE_RULE_REF, /* ws_star_20 */ 20},
{LLAMA_GRETYPE_ALT, 0},
{LLAMA_GRETYPE_END, 0},
});
return 0;
}