Initial commit for boundary support

This commit is contained in:
Daniel Holden
2014-04-16 18:16:16 +01:00
parent 8d9bf9fdda
commit 612bc046f0
3 changed files with 130 additions and 62 deletions

View File

@@ -172,7 +172,7 @@ mpc_parser_t *mpc_string(const char *s);
Matches exactly the string `s`
### Trivial Parsers
### Other Parsers
Several other functions exist that construct parsers with some other special functionality.
@@ -225,6 +225,18 @@ mpc_parser_t *mpc_state(void);
Consumes no input, always successful, returns a copy of the parser state as `mpc_state_t *`. This pointer needs to be freed with `free` when done with.
* * *
```c
mpc_parser_t *mpc_boundary(void);
```
Consumes no input. Only successful on the boundary between words. Always returns `NULL` on success.
Words are defined as any alphanumeric character or underscore. A non word is defined as any whitespace or non-alphanumeric/underscore character. This includes the start and end of input.
A boundary is therefore when the last character parsed was not part of a word, while the next character is part of a word, _or_ when the last character was part of a word, while the next character is not.
Parsing
-------