jwtowner / lug Goto Github PK
View Code? Open in Web Editor NEWParsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
License: Other
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
License: Other
I've found that lug no longer compiles using recent libc++ (8220dac5 from 29 Aug 2018) and Clang (v8.0.0 from tip-of-tree):
clang version 8.0.0 (https://git.llvm.org/git/clang a12d0b0e0159b8f533297b291c79489a6322de3e) (https://git.llvm.org/git/llvm da01ae3cf249da908e28e3681845b859b2193ce8)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/jon/Dev/LLVM/build/bin
One issue is that the ~
operator is found to be ambigious when compiling some of the samples:
In file included from samples/basic.cpp:8:
./lug/lug.hpp:1389:28: error: use of overloaded operator '~' is ambiguous
(operand type '(lambda at ./lug/lug.hpp:740:10)')
...> ~(chr('^') <[](generator& g) { g.circumflex = true; })
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./lug/detail.hpp:41:13: note: candidate function [with T = (lambda at
./lug/lug.hpp:740:10), $1 = void]
constexpr T operator~(T x) noexcept
^
./lug/lug.hpp:766:16: note: candidate function [with E = (lambda at
./lug/lug.hpp:740:10), $1 = void]
constexpr auto operator~(E const& e)
^
When compiling lug's samples using recent libc++ (8220dac5 from 29 Aug 2018) and Clang (v8.0.0 from tip-of-tree):
clang version 8.0.0 (https://git.llvm.org/git/clang a12d0b0e0159b8f533297b291c79489a6322de3e) (https://git.llvm.org/git/llvm da01ae3cf249da908e28e3681845b859b2193ce8)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/jon/Dev/LLVM/build/bin
I encounter the following compilation error at lug.hpp:1383
:
In file included from samples/basic.cpp:8:
In file included from ./lug/lug.hpp:9:
In file included from ./lug/utf8.hpp:13:
In file included from ./lug/unicode.hpp:12:
In file included from ./lug/detail.hpp:8:
In file included from /Users/jon/Dev/LLVM/build/include/c++/v1/algorithm:645:
/Users/jon/Dev/LLVM/build/include/c++/v1/functional:1572:16: error: no viable
conversion from returned value of type '(lambda at ./lug/lug.hpp:696:9)'
to function return type 'const void *'
return &__f_.first();
^~~~~~~~~~~~~
/Users/jon/Dev/LLVM/build/include/c++/v1/functional:1491:14: note: in
instantiation of member function
'std::__1::__function::__func<lug::language::(anonymous struct at
./lug/lug.hpp:604:11), std::__1::allocator<lug::language::(anonymous
struct at ./lug/lug.hpp:604:11)>, void (lug::encoder &)>::target'
requested here
explicit __func(_Fp&& __f)
^
/Users/jon/Dev/LLVM/build/include/c++/v1/functional:1767:42: note: in
instantiation of member function
'std::__1::__function::__func<lug::language::(anonymous struct at
./lug/lug.hpp:604:11), std::__1::allocator<lug::language::(anonymous
struct at ./lug/lug.hpp:604:11)>, void (lug::encoder &)>::__func'
requested here
__f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
^
/Users/jon/Dev/LLVM/build/include/c++/v1/functional:1855:5: note: in
instantiation of function template specialization 'std::__1::function<void
(lug::encoder &)>::function<lug::language::(anonymous struct at
./lug/lug.hpp:604:11), void>' requested here
function(_VSTD::forward<_Fp>(__f)).swap(*this);
^
./lug/lug.hpp:1383:26: note: in instantiation of function template
specialization 'std::__1::function<void (lug::encoder &)>::operator=<const
lug::language::(anonymous struct at ./lug/lug.hpp:604:11) &, void>'
requested here
grammar::implicit_space = nop;
When compiling with recent libc++ (8220dac5 from 29 Aug 2018) and Clang (v8.0.0 from tip-of-tree):
clang version 8.0.0 (https://git.llvm.org/git/clang a12d0b0e0159b8f533297b291c79489a6322de3e) (https://git.llvm.org/git/llvm da01ae3cf249da908e28e3681845b859b2193ce8)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/jon/Dev/LLVM/build/bin
one of the compilation errors I see comes from lug's use of std::underlying_type_t
:
In file included from samples/basic.cpp:8:
In file included from ./lug/lug.hpp:8:
In file included from ./lug/error.hpp:8:
In file included from /Users/jon/Dev/LLVM/build/include/c++/v1/stdexcept:46:
In file included from /Users/jon/Dev/LLVM/build/include/c++/v1/exception:81:
In file included from /Users/jon/Dev/LLVM/build/include/c++/v1/cstddef:110:
/Users/jon/Dev/LLVM/build/include/c++/v1/type_traits:4659:13: error: only
enumeration types have underlying types
typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
^
/Users/jon/Dev/LLVM/build/include/c++/v1/__config:463:36: note: expanded from
macro '_LIBCPP_UNDERLYING_TYPE'
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
^
/Users/jon/Dev/LLVM/build/include/c++/v1/type_traits:4663:22: note: in
instantiation of template class 'std::__1::underlying_type<lug::rule>'
requested here
template <class _Tp> using underlying_type_t = typename underlying_type<...
^
./lug/detail.hpp:55:41: note: in instantiation of template type alias
'underlying_type_t' requested here
return static_cast<T>(static_cast<std::underlying_type_t<T>>(x) ...
^
./lug/lug.hpp:1392:30: note: in instantiation of function template
specialization 'lug::bitfield_ops::operator|<lug::rule, void>' requested
here
grammar grmr = start((+(Dot | Bracket | Sequence) | Empty) > eoi);
I would like to point out that identifiers like “LUG_HPP__
” and “LUG_DETAIL_HPP__
” do eventually not fit to the expected naming convention of the C++ language standard.
Would you like to adjust your selection for unique names?
Hi.
Around line 833 (and once more around 1159 onwards) the structured bindings compile fine on MSVC, whereas fail to compile on clang 10 and above.
I've done a very ugly local hack to get this to work on clang, however I wanted to ask your input on whether this is the best workaround:
#if defined(__clang__) for (auto X : top_rule->callees_) { // Workaround for clang auto callee_rule = std::get<0>(X); auto callee_program = std::get<1>(X); auto instr_offset = std::get<2>(X); auto mode = std::get<3>(X); #else for (auto [callee_rule, callee_program, instr_offset, mode] : top_rule->callees_) { #endif calls.emplace_back(callee_program, address + instr_offset); if (callee_rule && (mode & directives::eps) != directives::none && detail::escaping_find_if( callstack.crbegin(), callstack.crend(), [callee_rule](auto& caller) { return caller.first == callee_rule ? 1 : (caller.second ? 0 : -1); }) != callstack.crend()) {
AFAIK capturing structured bindings (in the above case, [callee_rule]) from lambdas is not supposed to be part of supported features in c++17 (as they're not meant to be 'variables' you can capture), the above hack came up.
Any better way to do this you can think of?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.