@masala/parser
Version:
Masala Parser
41 lines (27 loc) • 1.28 kB
TypeScript
import type {IParser, Option} from "../masala-parser.js";
import type {EmptyTupleParser, MixedParser, SingleParser, TupleParser} from "./tuple-parser.js";
declare type MASALA_VOID_TYPE = symbol;
/**
* Special case of a [[SingleParser]], but easier to write.
* Note that `VoidParser.then(VoidParser)` will produce a [[TupleParser]] where
* inner value is `[]`. Same result with `optrep()` and `rep()`
*/
export interface VoidParser extends IParser<MASALA_VOID_TYPE> {
then(dropped: VoidParser): EmptyTupleParser;
then(empty: EmptyTupleParser): EmptyTupleParser;
then<Y>(otherTuple: TupleParser<Y>): TupleParser<Y>;
then<FIRST,LAST>(mixed: MixedParser<FIRST, LAST>): MixedParser<FIRST, LAST>;
then<Y>(other: SingleParser<Y>): TupleParser<Y>;
then<T>(p: IParser<T>): TupleParser<T>;
rep(): EmptyTupleParser;
opt(): SingleParser<Option<MASALA_VOID_TYPE>>;
/*
or(other: VoidParser): VoidParser;
or<T, P extends IParser<T>>(other: P): VoidParser | P;
opt(): IParser<Option<MASALA_VOID_TYPE>>;
// Accepted with one or more occurrences.Will produce an Tuple of at least one T
rep(): VoidParser;
// Accepted with zero or more occurrences. Will produce a Tuple of zero or more T
//optrep(): VoidParser;
*/
}