{"record":{"id":"9596e786c8f7106d","repo":"oobabooga/textgen","slug":"expecting-newline-or-end-at-remaining-src","errorCode":null,"errorMessage":"expecting newline or end at {remaining_src}","messagePattern":"expecting newline or end at (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"modules/grammar/grammar_utils.py","lineNumber":278,"sourceCode":"\n\ndef parse_rule(state, src):\n    name, remaining_src = parse_name(src)\n    remaining_src = remove_leading_white_space(remaining_src, False)\n    rule_id = get_symbol_id(state, name)\n\n    if remaining_src[:3] != \"::=\":\n        raise RuntimeError(\"expecting ::= at \" + remaining_src)\n    remaining_src = remove_leading_white_space(remaining_src[3:], True)\n\n    remaining_src = parse_alternates(state, remaining_src, name, rule_id, False)\n\n    if remaining_src and remaining_src[0] == \"\\r\":\n        remaining_src = remaining_src[2:] if remaining_src[1] == \"\\n\" else remaining_src[1:]\n    elif remaining_src and remaining_src[0] == \"\\n\":\n        remaining_src = remaining_src[1:]\n    elif remaining_src:\n        raise RuntimeError(\"expecting newline or end at \" + remaining_src)\n    return remove_leading_white_space(remaining_src, True)\n\n\ndef parse_ebnf(src):\n    try:\n        state = ParseState()\n        grammar_repr = remove_leading_white_space(src, True)\n        last_grammar_repr = \"\"\n        while grammar_repr:\n            if last_grammar_repr:\n                last_parsed_rule_len = len(last_grammar_repr) - len(grammar_repr)\n                logger.debug(f\"last_parsed_rule: {last_grammar_repr[:last_parsed_rule_len]}\")\n            last_grammar_repr = grammar_repr\n            grammar_repr = parse_rule(state, grammar_repr)\n        state.grammar_encoding.append(0xFFFF)\n        return state\n    except RuntimeError as err:\n        logger.warning(\"error parsing grammar:\", err)","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/oobabooga/textgen/blob/ed888c71f221df552750e1834b3654abab8ae345/modules/grammar/grammar_utils.py#L260-L296","documentation":"Error \"expecting newline or end at {remaining_src}\" thrown in oobabooga/textgen.","triggerScenarios":"Raised while parsing a GBNF grammar string: after a rule expression the parser found extra tokens where it expected a newline or the end of input. Triggers when a grammar rule line contains trailing characters (e.g. an unclosed alternation, stray literal, or missing newline between rules) in the grammar passed to the grammar-constrained generation feature.","commonSituations":"See trigger scenarios.","solutions":["End each grammar rule with a newline or the end of the input; remove any trailing characters after the rule body.","Check the grammar text near the reported position for a missing line break between rules."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed888c71f221df552750e1834b3654abab8ae345","analyzedAt":"2026-08-15T05:24:21.000Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}