MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / json_number

Method json_number

common/peg-parser.cpp:1293–1306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1291// JSON parsers
1292
1293common_peg_parser common_peg_parser_builder::json_number() {
1294 return rule("json-number", [this]() {
1295 auto digit1_9 = chars("[1-9]", 1, 1);
1296 auto digits = chars("[0-9]");
1297 auto int_part = choice({literal("0"), sequence({digit1_9, chars("[0-9]", 0, -1)})});
1298 auto frac = sequence({literal("."), digits});
1299 auto exp = sequence({choice({literal("e"), literal("E")}), optional(chars("[+-]", 1, 1)), digits});
1300 // Negative lookahead: only commit the number when the next character can't extend it.
1301 // At EOF in partial mode, chars returns NEED_MORE → negate propagates NEED_MORE → number not committed.
1302 // This prevents premature commits of partial numbers (e.g. "3" when "3.14" is incoming).
1303 auto not_number_continuation = negate(chars("[0-9.eE+-]", 1, 1));
1304 return sequence({ optional(literal("-")), int_part, optional(frac), optional(exp), not_number_continuation, space() });
1305 });
1306}
1307
1308common_peg_parser common_peg_parser_builder::json_string() {
1309 return rule("json-string", [this]() {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected