mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-11-13 22:55:29 +00:00
Updated README
This commit is contained in:
parent
7b78a1c00f
commit
fd150264a5
33
README.md
33
README.md
@ -349,39 +349,6 @@ The following are available operators:
|
||||
| tok | Token boundary |
|
||||
| ign | Ignore semantic value |
|
||||
| cap | Capture character |
|
||||
| usr | User defined parser |
|
||||
|
||||
Adjust definitions
|
||||
------------------
|
||||
|
||||
It's possible to add/override definitions.
|
||||
|
||||
```cpp
|
||||
auto syntax = R"(
|
||||
ROOT <- _ 'Hello' _ NAME '!' _
|
||||
)";
|
||||
|
||||
Rules additional_rules = {
|
||||
{
|
||||
"NAME", usr([](const char* s, size_t n, SemanticValues& sv, any& dt) -> size_t {
|
||||
static vector<string> names = { "PEG", "BNF" };
|
||||
for (const auto& name: names) {
|
||||
if (name.size() <= n && !name.compare(0, name.size(), s, name.size())) {
|
||||
return name.size(); // processed length
|
||||
}
|
||||
}
|
||||
return -1; // parse error
|
||||
})
|
||||
},
|
||||
{
|
||||
"~_", zom(cls(" \t\r\n"))
|
||||
}
|
||||
};
|
||||
|
||||
auto g = parser(syntax, additional_rules);
|
||||
|
||||
assert(g.parse(" Hello BNF! "));
|
||||
```
|
||||
|
||||
Unicode support
|
||||
---------------
|
||||
|
Loading…
Reference in New Issue
Block a user