You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+25-24
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ cpp-peglib
5
5
6
6
C++17 header-only [PEG](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (Parsing Expression Grammars) library. You can start using it right away just by including `peglib.h` in your project.
7
7
8
-
Since this library only supports C++17 compilers, please make sure that compiler the option `-std=c++17` is enabled. (`/std:c++17 /Zc:__cplusplus` for MSVC)
8
+
Since this library only supports C++17 compilers, please make sure that the compiler option `-std=c++17` is enabled.
9
+
(`/std:c++17 /Zc:__cplusplus` for MSVC)
9
10
10
11
You can also try the online version, PEG Playground at https://yhirose.github.io/cpp-peglib.
11
12
@@ -34,11 +35,11 @@ The PEG syntax is well described on page 2 in the [document](http://www.brynosau
*`{ no_ast_opt }` (No AST node optimization instruction)
36
37
37
-
'End of Input' check will be done as default. In order to disable the check, please call `disable_eoi_check`.
38
+
'End of Input' check will be done as default. To disable the check, please call `disable_eoi_check`.
38
39
39
40
This library supports the linear-time parsing known as the [*Packrat*](http://pdos.csail.mit.edu/~baford/packrat/thesis/thesis.pdf) parsing.
40
41
41
-
IMPORTANT NOTE for some Linux distributions such as Ubuntu and CentOS: Need `-pthread` option when linking. See [#23](https://github.com/yhirose/cpp-peglib/issues/23#issuecomment-261126127), [#46](https://github.com/yhirose/cpp-peglib/issues/46#issuecomment-417870473) and [#62](https://github.com/yhirose/cpp-peglib/issues/62#issuecomment-492032680).
42
+
IMPORTANT NOTE for some Linux distributions such as Ubuntu and CentOS: Need `-pthread` option when linking. See [#23](https://github.com/yhirose/cpp-peglib/issues/23#issuecomment-261126127), [#46](https://github.com/yhirose/cpp-peglib/issues/46#issuecomment-417870473) and [#62](https://github.com/yhirose/cpp-peglib/issues/62#issuecomment-492032680).
42
43
43
44
I am sure that you will enjoy this excellent ["Practical parsing with PEG and cpp-peglib"](https://berthub.eu/articles/posts/practical-peg-parsing/) article by [bert hubert](https://berthub.eu/)!
`↑` operator could mitigate backtrack performance problem, but has a risk to change the meaning of grammar.
370
+
`↑` operator could mitigate the backtrack performance problem, but has a risk to change the meaning of grammar.
370
371
371
372
```peg
372
373
S <- '(' ↑ P ')' / '"' ↑ P '"' / P
@@ -479,7 +480,7 @@ if (parser.parse("...", ast)) {
479
480
}
480
481
```
481
482
482
-
`optimize_ast` removes redundant nodes to make a AST simpler. If you want to disable this behavior from particular rules, `no_ast_opt` instruction can be used.
483
+
`optimize_ast` removes redundant nodes to make an AST simpler. If you want to disable this behavior from particular rules, `no_ast_opt` instruction can be used.
483
484
484
485
It internally calls `peg::AstOptimizer` to do the job. You can make your own AST optimizers to fit your needs.
485
486
@@ -508,20 +509,20 @@ auto ret = ROOT.parse(" [tag1] [tag:2] [tag-3] ");
| rec | Infix expression | usr | User defined parser |
525
+
| rep | Repetition | | |
525
526
526
527
Adjust definitions
527
528
------------------
@@ -567,7 +568,7 @@ cpp-peglib supports the furthest failure error position report as described in t
567
568
568
569
For better error report and recovery, cpp-peglib supports 'recovery' operator with label which can be associated with a recovery expression and a custom error message. This idea comes from the fantastic ["Syntax Error Recovery in Parsing Expression Grammars"](https://arxiv.org/pdf/1806.11150.pdf) paper by Sergio Medeiros and Fabio Mascarenhas.
569
570
570
-
The custom message supports `%t` which is a place holder for the unexpected token, and `%c` for the unexpected Unicode char.
571
+
The custom message supports `%t` which is a placeholder for the unexpected token, and `%c` for the unexpected Unicode char.
For instance, `';'^semi` is a syntactic sugar for `(';' / %recovery(semi))`. `%recover` operator tries to recover the error at ';' by skipping input text with the recovery expression `semi`. Also `semi` is associated with a custom message "missing semicolon in assignment.".
603
+
For instance, `';'^semi` is a syntactic sugar for `(';' / %recovery(semi))`. `%recover` operator tries to recover the error at ';' by skipping input text with the recovery expression `semi`. Also `semi` is associated with a custom message "missing semicolon in assignment."
0 commit comments