module /** */ import { ParsingState } from "../state" ; import { ResultKind } from "../result" ; import { defineCombinator } from "./combinator" ; import { ParjserBase } from "../parser" ; import { ParjsCombinator } from "../../index" ; param val export function maybe < T , S = undefined > ( val ? ) ; export function maybe ( val = undefined ) { return defineCombinator ( inner => { return new class MaybeCombinator extends ParjserBase { _inner = inner ; expecting = "expecting anything" ; type = "maybe" ; _apply ( ps ) { inner . apply ( ps ) ; if ( ps . isSoft ) { ps . value = val ; ps . kind = ResultKind . Ok ; } } } ( ) ; } ) ; }