Comments (3)
As a workaround you can use this https://wandbox.org/permlink/lRGojGA7HzM9ecMX
#include <boost/spirit/home/x3.hpp>
namespace x3 = boost::spirit::x3;
auto expect = [](auto value) {
return [=](auto& ctx) {
x3::_pass(ctx) = x3::_attr(ctx) == value;
};
};
template<typename T>
auto lit_int(T value)
{
return x3::int_parser<T>{}[expect(value)];
}
int main() {
std::string input = "5";
assert(parse(input.begin(), input.end(), x3::int_[expect(5)]));
assert(parse(input.begin(), input.end(), lit_int(5)));
}
from spirit.
Thanks.
My solution is to convert it to a literal string parser using std::to_string:
int main() {
std::string input = "5";
assert(b::parse(input.begin(), input.end(), std::to_string(5)));
}
from spirit.
X3 is meant to be kept as simple as possible. I'm not sure we need literal ints.
from spirit.
Related Issues (20)
- iso8859_1::isgraph doesn't work correctly
- x3::unicode::format does not recognize certain format control characters HOT 3
- apparent uselessness of as_spirit_parser(...)? HOT 6
- no_case is a type in some make_primitives specializations, and a bool in others. HOT 1
- Boost Spirit X3 Parser recursive HOT 13
- compile error when using error_handler together with x3::variant
- boost::get overloads for boost::spirit::x3::variant should at least lack BOOST_NOEXCEPT
- x3::variant's converting constructor is explicit HOT 1
- `{qi,karma}::symbols` copy constructor does not make an independent copy HOT 2
- x3::double_ failed to parse 1.D-3 HOT 5
- X3 docs for operators is missing syntactical expressions HOT 1
- X3: Incorrect attribute propagation for alternatives with equal attributes HOT 2
- x3::phrase_parse is not expected
- X3: Vector of variant breaks string attributes if variant also contains character type
- X3: expectation operator ">" with semantic rule "[]" expectation_failure<> uses managled name
- mmap_file_iterator uses too restrictive sharing mode in a call to CreateFileA
- Build error C2061: syntax error: identifier 'BOOST_SCOPED_ENUM' on Windows MSVC HOT 1
- need for "RHS" transform_attribute
- boost::get<T>() failed with the x3::forward_ast<> wrapped types HOT 1
- MSVC (VS 2023) fails to compile example/x3/annotation.cpp with /std:c++20 or /std:c++latest option HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spirit.