From 4c30f9037e242b47a363b3f4e6a4bbc34ed2d239 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sun, 1 Sep 2024 18:17:32 -0400 Subject: [PATCH] Fix #304 --- README.md | 23 ++++++++++ docs/index.html | 1 + docs/index.js | 6 ++- docs/native.cpp | 12 +++-- docs/native.wasm | Bin 429113 -> 430239 bytes peglib.h | 117 +++++++++++++++++++++++++++-------------------- test/test1.cc | 50 +++++++++++++++++--- 7 files changed, 146 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 5d28cc0..80bdb4d 100644 --- a/README.md +++ b/README.md @@ -647,6 +647,29 @@ custom_message.txt:1:8: code format error... NOTE: If there are more than one elements with error message instruction in a prioritized choice, this feature may not work as you expect. +Change the Start Definition Rule +-------------------------------- + +We can change the start definition rule as below. + +```cpp +auto grammar = R"( + Start <- A + A <- B (',' B)* + B <- '[one]' / '[two]' + %whitespace <- [ \t\n]* +)"; + +peg::parser parser(grammar, "A"); // Start Rule is "A" + + or + +peg::parser parser; +parser.load_grammar(grammar, "A"); // Start Rule is "A" + +parser.parse(" [one] , [two] "); // OK +``` + peglint - PEG syntax lint utility --------------------------------- diff --git a/docs/index.html b/docs/index.html index 3ce55ee..edd068c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -20,6 +20,7 @@
  • Source Code