66
77_ Consume input, not memory._
88
9- > [ !WARNING]
10- > This library is underdeveloped. API is not stable.
11-
129This library provides an implementation of the parser combinators.
1310
14- Three different types of parser implementations exist:
15-
16- - The base parser implementations contain the logic for parsing input and serve
17- as the fundamental building blocks;
18- - The ` ParserCombinator ` provides methods to combine parsers and create new ones;
19- - The ` TaggedParser ` erases the type of the underlying parser and simplifies
20- the parser's type declaration.
21-
22- Every parser provides the type of the parsing result as a constant `ResultType:
23- type`.
24-
2511` Parcom ` offers two options for consuming data:
2612 - parse the entire input string at once,
2713 - or consume and parse byte by byte from ` AnyReader ` .
2814
2915When the input is a reader, ` Parcom ` works as a buffered reader. It reads few
3016bytes to the buffer and then parse them.
3117
32- The result of parsing by any parser can be a value of type ` ResultType ` in successful
33- case, or ` null ` if parsing was failed. In successful case not whole input can be
34- consumed. If you have to be sure, that every byte was consumed and parsed, use the
35- [ ` end() ` ] ( https://dokwork.github.io/parcom/index.html#parcom.end ) parser explicitly.
36-
3718## Installation
3819
3920Fetch ` Parcom ` from github:
@@ -60,6 +41,14 @@ Add `Parcom` module to your `build.zig`:
6041 exe.root_module.addImport("parcom", parcom.module("parcom"));
6142```
6243
44+ ## Documentation
45+ [ https://dokwork.github.io/parcom/index.html ] ( https://dokwork.github.io/parcom/index.html )
46+
47+ ## Examples
48+
49+ - [ The parser of a math expression] ( examples/expression.zig )
50+ - [ The json parser] ( examples/json.zig )
51+
6352## Quick start
6453
6554Let's create a parser, which will parse and execute a simple math expression with follow
@@ -78,6 +67,24 @@ Our parser will be capable of parsing and evaluating mathematical expressions
7867that include addition and subtraction operations, unsigned integers, and nested
7968expressions within brackets.
8069
70+ ### A short API overview
71+
72+ Three different types of parser implementations exist:
73+
74+ - The base parser implementations contain the logic for parsing input and serve
75+ as the fundamental building blocks;
76+ - The ` ParserCombinator ` provides methods to combine parsers and create new ones;
77+ - The ` TaggedParser ` erases the type of the underlying parser and simplifies
78+ the parser's type declaration.
79+
80+ Every parser provides the type of the parsing result as a constant `ResultType:
81+ type`.
82+
83+ The result of parsing by any parser can be a value of type ` ResultType ` in successful
84+ case, or ` null ` if parsing was failed. In successful case not whole input can be
85+ consumed. If you have to be sure, that every byte was consumed and parsed, use the
86+ [ ` end() ` ] ( https://dokwork.github.io/parcom/index.html#parcom.end ) parser explicitly.
87+
8188### Base parser
8289
8390The ` number ` from the grammar above is a sequence of symbols from the range [ '0', '9'] .
@@ -473,11 +480,3 @@ The parsing by the <EXPR> has been started from position 3:
473480…[!]5+2)
474481[example] (debug): End parsing by the <EXPR>. Cut 3 items during the parsing process.
475482```
476-
477- ## Documentation
478- [ https://dokwork.github.io/parcom/index.html ] ( https://dokwork.github.io/parcom/index.html )
479-
480- ## Examples
481-
482- - [ The parser of a math expression] ( examples/expression.zig )
483- - [ The json parser] ( examples/json.zig )
0 commit comments