Added more information about the ignore operator.

This commit is contained in:
yhirose 2015-06-13 01:27:49 -04:00
parent 38ba5e1a5e
commit 36e58a6c7b

View File

@ -144,9 +144,9 @@ We can ignore unnecessary semantic values from the list by using `~` operator.
```c++
peglib::peg parser(
" ROOT <- _ ITEM (',' _ ITEM _)* "
" ITEM <- ([a-z])+ "
" ~_ <- [ \t]* "
" ROOT <- _ ITEM (',' _ ITEM _)* "
" ITEM <- ([a-z])+ "
" ~_ <- [ \t]* "
);
parser["ROOT"] = [&](const SemanticValues& sv) {
@ -156,6 +156,16 @@ parser["ROOT"] = [&](const SemanticValues& sv) {
auto ret = parser.parse(" item1, item2 ");
```
The following grammar is same as the above.
```c++
peglib::peg parser(
" ROOT <- ~_ ITEM (',' ~_ ITEM ~_)* "
" ITEM <- ([a-z])+ "
" _ <- [ \t]* "
);
```
Simple interface
----------------