Tidy up the parser

This commit is contained in:
Lewis Dale 2023-12-06 08:28:52 +00:00
parent 02e6f1b76c
commit c896fe1d4d
1 changed files with 3 additions and 3 deletions

View File

@ -8,12 +8,12 @@ export type Race = [number, number];
const timeName = string('Time:').pipe(then(spaces1()));
const distanceName = string('Distance:').pipe(then(spaces1()));
const timeParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify(), between(timeName, whitespace()));
const distanceParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify(), between(distanceName, whitespace()));
const numbersParser = anyCharOf("0123456789").pipe(manySepBy(whitespace().pipe(exactly(2))), stringify());
const timeParser = numbersParser.pipe(between(timeName, whitespace()));
const distanceParser = numbersParser.pipe(between(distanceName, whitespace()));
const parser = timeParser.pipe(then(distanceParser));
export class BoatRace {
private readonly race: Race;