We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 195746d commit 4e305b4Copy full SHA for 4e305b4
example/choice.cc
@@ -0,0 +1,28 @@
1
+//
2
+// choice.cc
3
4
+// Copyright (c) 2023 Yuji Hirose. All rights reserved.
5
+// MIT License
6
7
+
8
+#include <cstdlib>
9
+#include <iostream>
10
+#include <peglib.h>
11
12
+using namespace peg;
13
14
+int main(void) {
15
+ parser parser(R"(
16
+type <- 'string' / 'int' / 'double'
17
+%whitespace <- [ \t\r\n]*
18
+ )");
19
20
+ parser["type"] = [](const SemanticValues &vs) {
21
+ std::cout << vs.choice() << std::endl;
22
+ };
23
24
+ if (parser.parse("int")) { return 0; }
25
26
+ std::cout << "syntax error..." << std::endl;
27
+ return -1;
28
+}
0 commit comments