Skip to content

Commit 17e069f

Browse files
committed
Fixed build wornings
1 parent 3947450 commit 17e069f

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

example/docx.cc

Lines changed: 64 additions & 0 deletions
Large diffs are not rendered by default.

example/enter_leave.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// enter_leave.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+
S <- A+
17+
A <- 'A'
18+
)");
19+
20+
parser["A"].enter = [](const Context & /*c*/, const char * /*s*/,
21+
size_t /*n*/, std::any & /*dt*/) {
22+
std::cout << "enter" << std::endl;
23+
};
24+
25+
parser["A"] = [](const SemanticValues & /*vs*/, std::any & /*dt*/) {
26+
std::cout << "action!" << std::endl;
27+
};
28+
29+
parser["A"].leave = [](const Context & /*c*/, const char * /*s*/,
30+
size_t /*n*/, size_t /*matchlen*/,
31+
std::any & /*value*/, std::any & /*dt*/) {
32+
std::cout << "leave" << std::endl;
33+
};
34+
35+
if (parser.parse("A")) { return 0; }
36+
37+
std::cout << "syntax error..." << std::endl;
38+
return -1;
39+
}

example/sequence.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// sequence.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+
START <- SEQUENCE_A
17+
SEQUENCE_A <- SEQUENCE('A')
18+
SEQUENCE(X) <- X (',' X)*
19+
)");
20+
21+
parser["SEQUENCE_A"] = [](const SemanticValues & /*vs*/) {
22+
std::cout << "SEQUENCE_A" << std::endl;
23+
};
24+
25+
if (parser.parse("A,A")) { return 0; }
26+
27+
std::cout << "syntax error..." << std::endl;
28+
return -1;
29+
}

0 commit comments

Comments
 (0)