Skip to content

Commit b0cbfdc

Browse files
authored
Fix grammar, punctuation, and formatting in README.md (#313)
1 parent dedc827 commit b0cbfdc

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

README.md

+25-24
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ cpp-peglib
55

66
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.
77

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)
910

1011
You can also try the online version, PEG Playground at https://yhirose.github.io/cpp-peglib.
1112

@@ -34,11 +35,11 @@ The PEG syntax is well described on page 2 in the [document](http://www.brynosau
3435
* `label { error_message "..." }` (Error message instruction)
3536
* `{ no_ast_opt }` (No AST node optimization instruction)
3637

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`.
3839

3940
This library supports the linear-time parsing known as the [*Packrat*](http://pdos.csail.mit.edu/~baford/packrat/thesis/thesis.pdf) parsing.
4041

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).
4243

4344
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/)!
4445

@@ -208,7 +209,7 @@ parser["ROOT"] = [&](const SemanticValues& vs) {
208209
auto ret = parser.parse(" item1, item2 ");
209210
```
210211

211-
The following grammar is same as the above.
212+
The following grammar is the same as the above.
212213

213214
```cpp
214215
peg::parser parser(R"(
@@ -356,7 +357,7 @@ parser["MONTH"] = [](const SemanticValues &vs) {
356357
};
357358
```
358359

359-
It supports the case insensitive mode.
360+
It supports the case-insensitive mode.
360361

361362
```peg
362363
START <- 'This month is ' MONTH '.'
@@ -366,7 +367,7 @@ MONTH <- 'Jan'i | 'January'i | 'Feb'i | 'February'i | '...'i
366367
Cut operator
367368
------------
368369

369-
`` 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.
370371

371372
```peg
372373
S <- '(' ↑ P ')' / '"' ↑ P '"' / P
@@ -479,7 +480,7 @@ if (parser.parse("...", ast)) {
479480
}
480481
```
481482

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.
483484

484485
It internally calls `peg::AstOptimizer` to do the job. You can make your own AST optimizers to fit your needs.
485486

@@ -508,20 +509,20 @@ auto ret = ROOT.parse(" [tag1] [tag:2] [tag-3] ");
508509
509510
The following are available operators:
510511
511-
| Operator | Description | Operator | Description |
512-
| :------- | :------------------------------ | :------- | :------------------- |
513-
| seq | Sequence | cho | Prioritized Choice |
514-
| zom | Zero or More | oom | One or More |
515-
| opt | Optional | apd | And predicate |
516-
| npd | Not predicate | lit | Literal string |
517-
| liti | Case-insensitive Literal string | cls | Character class |
518-
| ncls | Negated Character class | chr | Character |
519-
| dot | Any character | tok | Token boundary |
520-
| ign | Ignore semantic value | csc | Capture scope |
521-
| cap | Capture | bkr | Back reference |
522-
| dic | Dictionary | pre | Infix expression |
523-
| rec | Infix expression | usr | User defined parser |
524-
| rep | Repetition | | |
512+
| Operator | Description | Operator | Description |
513+
|:---------|:--------------------------------|:---------|:--------------------|
514+
| seq | Sequence | cho | Prioritized Choice |
515+
| zom | Zero or More | oom | One or More |
516+
| opt | Optional | apd | And predicate |
517+
| npd | Not predicate | lit | Literal string |
518+
| liti | Case-insensitive Literal string | cls | Character class |
519+
| ncls | Negated Character class | chr | Character |
520+
| dot | Any character | tok | Token boundary |
521+
| ign | Ignore semantic value | csc | Capture scope |
522+
| cap | Capture | bkr | Back reference |
523+
| dic | Dictionary | pre | Infix expression |
524+
| rec | Infix expression | usr | User defined parser |
525+
| rep | Repetition | | |
525526
526527
Adjust definitions
527528
------------------
@@ -567,7 +568,7 @@ cpp-peglib supports the furthest failure error position report as described in t
567568

568569
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.
569570

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.
571572

572573
Here is an example of Java-like grammar:
573574

@@ -599,7 +600,7 @@ stmtb ← (!(Stmt / 'else' / '}') .)* { error_message "invalid statement"
599600
condw ← &'==' ('==' RelExp)* / &'<' ('<' AddExp)* / (!')' .)*
600601
```
601602

602-
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."
603604

604605
Here is the result:
605606

@@ -644,7 +645,7 @@ CODE <- < '0x' [a-fA-F0-9]+ > { error_message 'code format error...' }
644645
custom_message.txt:1:8: code format error...
645646
```
646647

647-
NOTE: If there are more than one elements with error message instruction in a prioritized choice, this feature may not work as you expect.
648+
NOTE: If there is more than one element with an error message instruction in a prioritized choice, this feature may not work as you expect.
648649

649650
Change the Start Definition Rule
650651
--------------------------------

0 commit comments

Comments
 (0)