We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2101a2 commit 92ee631Copy full SHA for 92ee631
common/grammar-parser.cpp
@@ -416,8 +416,20 @@ namespace grammar_parser {
416
std::vector<const llama_grammar_element *> parse_state::c_rules() {
417
std::vector<const llama_grammar_element *> ret;
418
ret.reserve(rules.size());
419
+ unsigned int cnt = 0;
420
for (const auto & rule : rules) {
- ret.push_back(rule.data());
421
+ // Ensure it's not empty
422
+ if (rule.data() != nullptr) {
423
+ ret.push_back(rule.data());
424
+ } else {
425
+ // Find the symbol ID for this rule ID
426
+ for (const auto & kv : symbol_ids) {
427
+ if (kv.second == cnt) {
428
+ throw std::runtime_error("Undefined rule identifier '" + kv.first + "'");
429
+ }
430
431
432
+ cnt++;
433
}
434
return ret;
435
0 commit comments