MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / recurse

Method recurse

llama_cpp/llama_grammar.py:407–420  ·  view source on GitHub ↗
(i: int)

Source from the content-addressed store, hash-verified

405 assert len(literal) > 0, "Empty literal not supported"
406
407 def recurse(i: int):
408 c = literal[i]
409 if maybe_escaped_underscores and c == "_":
410 yield f"[^{c}\\\\]"
411 yield " | "
412 yield f'"\\\\"? "{c}"'
413 else:
414 yield f"[^{c}]"
415 if i < len(literal) - 1:
416 yield " | "
417 yield self._format_literal(c)
418 yield " ("
419 yield from recurse(i + 1)
420 yield ")?"
421
422 return "".join(("(", *recurse(0), ")"))
423

Callers

nothing calls this directly

Calls 1

_format_literalMethod · 0.95

Tested by

no test coverage detected