Skip to content

Commit

Permalink
#88: TS: Ending the FlowBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-zozol committed Nov 11, 2017
1 parent 60ff41f commit b81ae38
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions masala-parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export interface Response<T> {
map<Y>(f): Response<Y>;
flatMap<Y>(f): Response<Y>;
filter(f: (value) => boolean): Response<T>;
//value:any
//value:T
offset: number;
}


/* Array with different values*/
export interface ArrayParser<T> extends IParser<T> {
parse<X>(stream: Stream<X>, index?: number): ArrayResponse<T>;
Expand Down Expand Up @@ -169,36 +171,38 @@ export interface IParser<T> {
parse<X>(stream: Stream<X>, index?: number): Response<T> ;
}*/

export interface Response<T> {
isCompleted(): boolean
isAccepted(): boolean
fold(accept, reject?): Response<T>;
map(f): Response<T>;
flatMap(f): Response<T>;
filter(f: (value) => boolean): Response<T>;
offset: number;
}

interface CharBundle {
char(string:string): SingleParser<string>;
string(string:string): SingleParser<string>;
stringIn(strings:string[]): SingleParser<string>;
letter: SingleParser<string>;
letter(): SingleParser<string>;
}

export type parserBuilder<Y,P extends IParser<Y>> = (...rest:any[])=>P;

type extension<Y,T extends IParser<Y>> = T;

type predicate<V> = (value: V)=>boolean;

interface FlowBundle {
parse<Y,P extends IParser<Y>>(P):P;
nop(): VoidParser;
try<Y,P extends IParser<Y>>(parser:P):P;
any():SingleParser<any>;
subStream(length:number):ListParser<any>
lazy<Y,P extends IParser<Y>> (builder: parserBuilder<Y,P>, args:any[]): P;
not<Y,P extends IParser<Y>>(P):SingleParser<any>;
lazy<Y,P extends IParser<Y>> (builder: parserBuilder<Y,P>, args:any[]): P;
returns<T>(value:T):SingleParser<T>;
error():VoidParser;
eos(): SingleParser<Unit>;
satisfy<V>(predicate:predicate<V>):SingleParser<any>
startWith<V>(value:V):SingleParser<V>;
moveUntil(s:string):SingleParser<string>;
moveUntil<Y>(p:IParser<Y>):SingleParser<string>;
dropTo(s:string):VoidParser;
dropTo<Y>(p:IParser<Y>):VoidParser;

}

interface NumberBundle {
Expand Down

0 comments on commit b81ae38

Please sign in to comment.