mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-10 09:35:30 +00:00
Fixed build wornings
This commit is contained in:
parent
3947450925
commit
17e069fbc5
64
example/docx.cc
Normal file
64
example/docx.cc
Normal file
File diff suppressed because one or more lines are too long
39
example/enter_leave.cc
Normal file
39
example/enter_leave.cc
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// enter_leave.cc
|
||||
//
|
||||
// Copyright (c) 2023 Yuji Hirose. All rights reserved.
|
||||
// MIT License
|
||||
//
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <peglib.h>
|
||||
|
||||
using namespace peg;
|
||||
|
||||
int main(void) {
|
||||
parser parser(R"(
|
||||
S <- A+
|
||||
A <- 'A'
|
||||
)");
|
||||
|
||||
parser["A"].enter = [](const Context & /*c*/, const char * /*s*/,
|
||||
size_t /*n*/, std::any & /*dt*/) {
|
||||
std::cout << "enter" << std::endl;
|
||||
};
|
||||
|
||||
parser["A"] = [](const SemanticValues & /*vs*/, std::any & /*dt*/) {
|
||||
std::cout << "action!" << std::endl;
|
||||
};
|
||||
|
||||
parser["A"].leave = [](const Context & /*c*/, const char * /*s*/,
|
||||
size_t /*n*/, size_t /*matchlen*/,
|
||||
std::any & /*value*/, std::any & /*dt*/) {
|
||||
std::cout << "leave" << std::endl;
|
||||
};
|
||||
|
||||
if (parser.parse("A")) { return 0; }
|
||||
|
||||
std::cout << "syntax error..." << std::endl;
|
||||
return -1;
|
||||
}
|
29
example/sequence.cc
Normal file
29
example/sequence.cc
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// sequence.cc
|
||||
//
|
||||
// Copyright (c) 2023 Yuji Hirose. All rights reserved.
|
||||
// MIT License
|
||||
//
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <peglib.h>
|
||||
|
||||
using namespace peg;
|
||||
|
||||
int main(void) {
|
||||
parser parser(R"(
|
||||
START <- SEQUENCE_A
|
||||
SEQUENCE_A <- SEQUENCE('A')
|
||||
SEQUENCE(X) <- X (',' X)*
|
||||
)");
|
||||
|
||||
parser["SEQUENCE_A"] = [](const SemanticValues & /*vs*/) {
|
||||
std::cout << "SEQUENCE_A" << std::endl;
|
||||
};
|
||||
|
||||
if (parser.parse("A,A")) { return 0; }
|
||||
|
||||
std::cout << "syntax error..." << std::endl;
|
||||
return -1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user