The Parsnip Parser Library

The Parsnip Parser Library allows you to build complex parsers from a rich set of parser primitives.
Download

The Parsnip Parser Library Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Alex Rubinsteyn
  • Publisher web site:

The Parsnip Parser Library Tags


The Parsnip Parser Library Description

The Parsnip Parser Library allows you to build complex parsers from a rich set of parser primitives. The Parsnip Parser Library allows you to build complex parsers from a rich set of parser primitives. This method of parser construction is inspired by parsec and other parser combinator libraries for Haskell and ML. Parsnip's default parser strategy is form of packrat parsing, augmented to allow for left-recursion within a parser.Since left recursion is allowed, the set of languages Parsnip can recognize may be (and probably is) a superset of those recognized by Parser Expression Grammars. Vanilla packrat parsing is available as a configuration option.Function Referencech (char c) ⇒ CharParser< string, string >Returns a CharParser which matches character c and returns it as a string.str (string s) ⇒ StringParser< string, string >Returns a StringParser which matches sequence of input characters to string s and return srange (char l, char u) ⇒ CharRangeParser< string, string >Returns a CharRangeParser which succeeds only if input character is within range .oneOf (string s) ⇒ OneOfParser< string, string >Returns a OneOfParser which matches an input character to any character in string s. Returns matched character in a string.seq < I, R > (Parser< I, R > p1, Parser< I, R > p2) ⇒ SeqTupleParser< I, R >Creates a sequence parser: if both parsers succeed, return their results in a tuple, fail otherwise. The shorthand for this parser is: p1 > > p2 seq_vec < I, R > (Parser< I, R > p1, Parser< I, R > p2) ⇒ SeqVecParser< I, R >Creates a vector sequence parser: if both parsers succeed, return their results in a vector, fails otherwise. Vectors, unlike tuples, can be of arbitrary length but require the parsers to be of a homogeneous input and output type. The shorthand for this parser is: p1 && p2 concat (Parser< string, string > p1, Parser< string, string > p2) ⇒ ConcatParser< string, string >Creates a concat parser: parses in sequence but concatenates results rather than tupling them. The shorthand for this parser is: p1 + p2. choice < I, R > (Parser< I, R > p1, Parser< I, R > p2) ⇒ ChoiceParser < I, R >Parser choice: Returns the first of its two parser parameters to succeed, fails otherwise. Backtracks on the input stream for second parser. The shorthand for this parser is: p1 | p2. not< I, R > (Parser< I, R > p) ⇒ NotParser< I, R >Creates a NotParser which succeeds if p fails and consumes no input.call0< I, R > (Parser< I, void > p, R (*fn) (void) ) ⇒ callParser0< I, R >Creates a CallParser which calls fn if p's parse succeeds. call1< I, T, R > (Parser< I, T > p, R (*fn) (T)) ⇒ CallParser1< I, R >Creates a CallParser which calls fn with the results of p's parse.call2< I, T1, T2, R > (Parser< I, Tuple2< T1, T2 > > p, R (*fn) (T1, T2) ) ⇒ CallParser2< I, R > Creates a CallParser which unpacks the 2-tuple that p returns and passes the components as arguments to fn.call3< I, T1, T2, T3, R > (Parser< I, Tuple3< T1, T2, T3 > > p, R (*fn) (T1, T2, T3) ) ⇒ CallParser3< I, R > Creates a CallParser which unpacks the 3-tuple that p returns and passes the components as arguments to fn.many < I, R, Acc > (Parser< I, R > p, int min = 0, int max = INT_MAX) ⇒ ManyParser< I, Acc::ResultType >The ManyParser repeatedly parses p until max is reached or p fails. If the number of parses is less than min then the ManyParser fails. Each time p is parsed successfully the result is passed to an accumulator of type Acc. If the ManyParser is successful it returns the accumulated data of its Acc object. many1 < I, R, Acc > (Parser< I, R > p, int max = INT_MAX) ⇒ ManyParser< I, Acc::ResultType >Generates a ManyParser which requires atleast one parse of p to succeed.


The Parsnip Parser Library Related Software