FunParserJS
A functionnal parser written in Javascript.
npm install funparserjs
Usage
Available parser :
anyChar
: parse any character in a stringfail
: parser that always failedsuccess(v)
: parser that always success and return valternate(p1,...p2)
: parser that run the first parser executable in parameterscombine(p,f)
: parser that combine a parser and a function that return a parsercombines(p, ...f)
: parser that combine recursively with the result of the previous function,charCond(cond)
: parser that success if the character condition is good else failchar
: parse a characterstring
: parse a stringoneOrMore(p)
: parser that try to run parser p one time or morezeroOrMore(p)
: parser that try to run parser p one time or moredigit
: parse a digitnumber
: parse a number and return a list of digitint
: parse an integer
How to run a parser
const parser = ; parser;// Will return ['T', 'est'] parser;// Will return ['OK', 'Test']
How to write you own parser
const parser = ; const fooParser = ;// Will return a parser of string that match fooconst anyCharBis = ;// Will return a parser that parse anyChar and success with the char (same as anyChar)const testParser = // Will return a parser that parse the string "test" and the result is true