add h_left, h_right, h_middle combinators
This commit is contained in:
parent
6d755efbde
commit
7724ff9e6f
4 changed files with 132 additions and 0 deletions
24
src/hammer.h
24
src/hammer.h
|
|
@ -216,6 +216,30 @@ const HParser* h_uint8();
|
|||
*/
|
||||
const HParser* h_whitespace(const HParser* p);
|
||||
|
||||
/**
|
||||
* Given two parsers, p and q, returns a parser that parses them in
|
||||
* sequence but only returns p's result.
|
||||
*
|
||||
* Result token type: p's result type
|
||||
*/
|
||||
const HParser* h_left(const HParser* p, const HParser* q);
|
||||
|
||||
/**
|
||||
* Given two parsers, p and q, returns a parser that parses them in
|
||||
* sequence but only returns q's result.
|
||||
*
|
||||
* Result token type: q's result type
|
||||
*/
|
||||
const HParser* h_right(const HParser* p, const HParser* q);
|
||||
|
||||
/**
|
||||
* Given three parsers, p, x, and q, returns a parser that parses them in
|
||||
* sequence but only returns x's result.
|
||||
*
|
||||
* Result token type: x's result type
|
||||
*/
|
||||
const HParser* h_middle(const HParser* p, const HParser* x, const HParser* q);
|
||||
|
||||
/**
|
||||
* Given another parser, p, and a function f, returns a parser that
|
||||
* applies p, then applies f to everything in the AST of p's result.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue