MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / parseNumberNode

Method parseNumberNode

packages/core/src/constraints/parser.ts:310–340  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

308 }
309
310 private parseNumberNode(): Readonly<{ kind: "number"; value: number }> {
311 const start = this.pos;
312 const first = this.peek();
313 if (first === null || !isDigit(first)) {
314 this.fail("Expected number");
315 }
316
317 while (true) {
318 const ch = this.peek();
319 if (ch === null || !isDigit(ch)) break;
320 this.pos++;
321 }
322
323 if (this.peek() === ".") {
324 this.pos++;
325 const fractional = this.peek();
326 if (fractional === null || !isDigit(fractional)) {
327 this.fail("Expected digits after decimal point");
328 }
329 while (true) {
330 const ch = this.peek();
331 if (ch === null || !isDigit(ch)) break;
332 this.pos++;
333 }
334 }
335
336 const raw = this.source.slice(start, this.pos);
337 const value = Number.parseFloat(raw);
338 if (!Number.isFinite(value)) this.fail(`Invalid number "${raw}"`, start);
339 return { kind: "number", value };
340 }
341
342 private readIdentifier(): string {
343 const start = this.pos;

Callers 2

parseAtomMethod · 0.95
parseStepThresholdMethod · 0.95

Calls 3

peekMethod · 0.95
failMethod · 0.95
isDigitFunction · 0.70

Tested by

no test coverage detected