Parsnip Parser Library enables users to construct intricate parsers using an abundant array of parser primitives.
Thanks to this feature, Parsnip can recognize a more extensive range of languages, compared to Parser Expression Grammars. However, if needed, vanilla packrat parsing is available as a configuration option.
The software provides several parser methods that can be called within the programming language. Among the available functions are:
- ch (char c): Returns a CharParser that matches character c and returns it as a string.
- str (string s): Returns a StringParser that matches a sequence of input characters to string s and returns s.
- range (char l, char u): Returns a CharRangeParser that succeeds only if the input character is within the defined range [l, u].
- oneOf (string s): Returns a OneOfParser that matches an input character to any character in string s and returns the matched character in a string.
- seq < I, R > (Parser< I, R > p1, Parser< I, R > p2): Creates a sequence parser that returns a tuple of results if both parsers succeed; fails otherwise.
- seq_vec < I, R > (Parser< I, R > p1, Parser< I, R > p2): Creates a vector sequence parser that returns a vector of results if both parsers succeed; fails otherwise.
- concat (Parser< string, string > p1, Parser< string, string > p2): Creates a concat parser that parses in sequence but concatenates results rather than tupling them.
- choice < I, R > (Parser< I, R > p1, Parser< I, R > p2): Returns the first of its two parser parameters to succeed, failing otherwise. Backtracks on the input stream for the second parser.
- not< I, R > (Parser< I, R > p): Creates a NotParser that succeeds if p fails and consumes no input.
- call0< I, R > (Parser< I, void > p, R (*fn) (void)): Creates a CallParser that calls fn if p's parse succeeds.
- call1< I, T, R > (Parser< I, T > p, R (*fn) (T)): Creates a CallParser that calls fn with the results of p's parse.
- call2< I, T1, T2, R > (Parser< I, Tuple2< T1, T2 > > p, R (*fn) (T1, T2)): Creates a CallParser that 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)): Creates a CallParser that 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): Creates a
Version 0.21: N/A