yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
900 stars 112 forks source link

AST annotations stop working #102

Closed yesint closed 4 years ago

yesint commented 4 years ago

Hello! I've recently update peglib to latest version and my AST with custom annotation suddenly stopped working, while it was perfectly fine with older version:

struct MyAst_annotation {
    bool is_coord_dependent;
    std::vector<int> precomputed;
};

typedef peg::AstBase<MyAst_annotation> MyAst;
...

/// AST tree
std::shared_ptr<MyAst> tree;

This is no more compiling (see below). What should I change to make it work again?

[1/21 0.2/sec] Building CXX object src/core/CMakeFiles/pteros.dir/selection_parser/selection_parser.cpp.o
FAILED: src/core/CMakeFiles/pteros.dir/selection_parser/selection_parser.cpp.o 
/usr/bin/g++  -DUSE_POWERSASA -Dpteros_EXPORTS -I/home/semen/work/current/Projects/pteros/github/pteros/include -I/home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser -I/home/semen/work/current/Projects/pteros/github/pteros/external/peglib -I/home/semen/work/current/Projects/pteros/github/pteros/thirdparty/powersasa -I/home/semen/work/current/Projects/pteros/github/pteros/thirdparty/dssp -isystem /usr/include/eigen3 -I/home/semen/work/current/Projects/pteros/github/pteros/thirdparty/sasa -I/home/semen/work/current/Projects/pteros/github/pteros/thirdparty/molfile_plugins -Wl,--no-as-needed -g -fPIC   -fopenmp -std=gnu++14 -MD -MT src/core/CMakeFiles/pteros.dir/selection_parser/selection_parser.cpp.o -MF src/core/CMakeFiles/pteros.dir/selection_parser/selection_parser.cpp.o.d -o src/core/CMakeFiles/pteros.dir/selection_parser/selection_parser.cpp.o -c /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:32,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’:
/usr/include/c++/7/bits/alloc_traits.h:475:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; _Tp = peg::AstBase<pteros::MyAst_annotation>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<peg::AstBase<pteros::MyAst_annotation> >]’
/usr/include/c++/7/bits/shared_ptr_base.h:526:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:637:4:   required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:1295:35:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; _Tp = peg::AstBase<pteros::MyAst_annotation>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr.h:344:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’
/usr/include/c++/7/bits/shared_ptr.h:690:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
/usr/include/c++/7/bits/shared_ptr.h:706:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[6], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
/home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:178:99:   required from here
/usr/include/c++/7/ext/new_allocator.h:136:4: error: no matching function for call to ‘peg::AstBase<pteros::MyAst_annotation>::AstBase(const char [1], int, int, const char [6], std::__cxx11::basic_string<char>)’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:37:0,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note: candidate: peg::AstBase<Annotation>::AstBase(const peg::AstBase<Annotation>&, const char*, size_t, size_t, size_t, size_t) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const AstBase &ast, const char *a_original_name, size_t a_position,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note:   candidate expects 6 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const string&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const std::vector<std::shared_ptr<peg::AstBase<Annotation> > >&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(const peg::AstBase<pteros::MyAst_annotation>&)
 template <typename Annotation> struct AstBase : public Annotation {
                                       ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(peg::AstBase<pteros::MyAst_annotation>&&)
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:32,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’:
/usr/include/c++/7/bits/alloc_traits.h:475:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; _Tp = peg::AstBase<pteros::MyAst_annotation>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<peg::AstBase<pteros::MyAst_annotation> >]’
/usr/include/c++/7/bits/shared_ptr_base.h:526:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:637:4:   required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:1295:35:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; _Tp = peg::AstBase<pteros::MyAst_annotation>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr.h:344:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’
/usr/include/c++/7/bits/shared_ptr.h:690:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}]’
/usr/include/c++/7/bits/shared_ptr.h:706:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&}]’
/home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:188:73:   required from here
/usr/include/c++/7/ext/new_allocator.h:136:4: error: no matching function for call to ‘peg::AstBase<pteros::MyAst_annotation>::AstBase(const char [1], int, int, const char [13], std::vector<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> >, std::allocator<std::shared_ptr<peg::AstBase<pteros::MyAst_annotation> > > >&)’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:37:0,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note: candidate: peg::AstBase<Annotation>::AstBase(const peg::AstBase<Annotation>&, const char*, size_t, size_t, size_t, size_t) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const AstBase &ast, const char *a_original_name, size_t a_position,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note:   candidate expects 6 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const string&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const std::vector<std::shared_ptr<peg::AstBase<Annotation> > >&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(const peg::AstBase<pteros::MyAst_annotation>&)
 template <typename Annotation> struct AstBase : public Annotation {
                                       ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(peg::AstBase<pteros::MyAst_annotation>&&)
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:32,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’:
/usr/include/c++/7/bits/alloc_traits.h:475:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; _Tp = peg::AstBase<pteros::MyAst_annotation>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<peg::AstBase<pteros::MyAst_annotation> >]’
/usr/include/c++/7/bits/shared_ptr_base.h:526:39:   required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:637:4:   required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr_base.h:1295:35:   required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; _Tp = peg::AstBase<pteros::MyAst_annotation>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’
/usr/include/c++/7/bits/shared_ptr.h:344:64:   required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}; _Tp = peg::AstBase<pteros::MyAst_annotation>]’
/usr/include/c++/7/bits/shared_ptr.h:690:14:   required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Alloc = std::allocator<peg::AstBase<pteros::MyAst_annotation> >; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}]’
/usr/include/c++/7/bits/shared_ptr.h:706:39:   required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = peg::AstBase<pteros::MyAst_annotation>; _Args = {const char (&)[1], int, int, const char (&)[4], const char (&)[1]}]’
/home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:214:59:   required from here
/usr/include/c++/7/ext/new_allocator.h:136:4: error: no matching function for call to ‘peg::AstBase<pteros::MyAst_annotation>::AstBase(const char [1], int, int, const char [4], const char [1])’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.h:37:0,
                 from /home/semen/work/current/Projects/pteros/github/pteros/src/core/selection_parser/selection_parser.cpp:30:
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note: candidate: peg::AstBase<Annotation>::AstBase(const peg::AstBase<Annotation>&, const char*, size_t, size_t, size_t, size_t) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const AstBase &ast, const char *a_original_name, size_t a_position,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3550:3: note:   candidate expects 6 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const string&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3540:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note: candidate: peg::AstBase<Annotation>::AstBase(const char*, size_t, size_t, const char*, size_t, size_t, size_t, size_t, const std::vector<std::shared_ptr<peg::AstBase<Annotation> > >&) [with Annotation = pteros::MyAst_annotation; size_t = long unsigned int]
   AstBase(const char *a_path, size_t a_line, size_t a_column,
   ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3529:3: note:   candidate expects 9 arguments, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(const peg::AstBase<pteros::MyAst_annotation>&)
 template <typename Annotation> struct AstBase : public Annotation {
                                       ^~~~~~~
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note: candidate: peg::AstBase<pteros::MyAst_annotation>::AstBase(peg::AstBase<pteros::MyAst_annotation>&&)
/home/semen/work/current/Projects/pteros/github/pteros/external/peglib/peglib.h:3528:39: note:   candidate expects 1 argument, 5 provided
[2/21 0.2/sec] Building CXX object src/core/CMakeFiles/pteros.dir/system.cpp.o
[3/21 0.2/sec] Building CXX object src/core/CMakeFiles/pteros.dir/selection.cpp.o
ninja: build stopped: subcommand failed.
12:34:14: The process "/usr/bin/cmake" exited with code 1.
Error while building/deploying project pteros (kit: gcc7)
When executing step "CMake Build"
12:34:14: Elapsed time: 00:17.
yhirose commented 4 years ago

@yesint, thank you for the report. I tried to reproduce it, but I couldn't. I built the following code with g++ --std=c++11 a.cpp, and the build succeeded with no error.

a.cpp

#include "peglib.h"
using namespace peg;

struct MyAst_annotation {
  bool is_coord_dependent;
  std::vector<int> precomputed;
};

typedef peg::AstBase<MyAst_annotation> MyAst;

int main(void) {
  parser parser("START <- 'hello' ' '+ 'world'");
  parser.enable_ast();

  /// AST tree
  std::shared_ptr<MyAst> tree;
  if (parser.parse("hello  world", tree)) {
    tree = AstOptimizer(true).optimize(tree);
    return 0;
  }
  return -1;
}

Could you give me more information, and the smallest possible example which reproduces the problem? Thanks for your help!

yesint commented 4 years ago

@yhirose, thank you for prompt reaction! Unfortunately I was unable to reproduced outside of our project, which is very weird and most likely points to our mistake, but in any case it was compiling nicely before and doesn't compile with the latest peglib. I would be grateful if you'll help us to understand why.

This is how to reproduce:

git clone -b new-peglib https://github.com/yesint/pteros.git pteros
mkdir build 
cd build
cmake ../pteros -DWITH_GROMACS=OFF -DWITH_OPENBABEL=OFF -DWITH_PYTHON=OFF -DCMAKE_BUILD_TYPE=Release
make

This builds our pteros library in the bare minimal configuration and fails with this compilation error. If I substitute peglib.h with older version in compiles nicely without any other changes.

The project is large but peglib is only used in one place: src/core/selection_parser.

yhirose commented 4 years ago

@yesint, I tried to build it, but cmake stops working with the following message:

-- Generating examples
-- Generating tests
-- Checking for module 'libsystemd'
--   No package 'libsystemd' found
-- Generating install
-- =======================
CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindOpenMP.cmake:473 (find_package_handle_standard_args)
  CMakeLists.txt:134 (find_package)

Do I miss something? (I am running on Mac OS 10.15 Catalina.)

yesint commented 4 years ago

Apparently it can't find OpenMP, could you try with -DWITH_OPENMP=OFF ?

yhirose commented 4 years ago

@yesint, thanks for the info. I am now able to generate Makefile. But when I run make, I encountered another compile error in dssp.cpp before reaching selection_parser.cpp... Is there any easy way to compile just the selection_parser.cpp? Thanks for your help!

[ 33%] Building CXX object thirdparty/dssp/CMakeFiles/dssp.dir/dssp.cpp.o
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/dssp.cpp:6:
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/mas.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:504:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:643:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2147:9: error: 
      cannot initialize a member subobject of type 'int *' with an rvalue of type 'long'
      : __value_(_VSTD::forward<_Up>(__u))
        ^        ~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2240:9: note: 
      in instantiation of function template specialization 'std::__1::__compressed_pair_elem<int *, 0,
      false>::__compressed_pair_elem<long, void>' requested here
      : _Base1(std::forward<_Tp>(__t)), _Base2() {}
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:436:7: note: 
      in instantiation of function template specialization 'std::__1::__compressed_pair<int *,
      std::__1::allocator<int> >::__compressed_pair<long, true>' requested here
      __end_cap_(nullptr)
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:517:5: note: 
      in instantiation of member function 'std::__1::__vector_base<int, std::__1::allocator<int>
      >::__vector_base' requested here
    vector(size_type __n, const value_type& __x);
    ^
/usr/local/include/boost/token_functions.hpp:360:9: note: in instantiation of member function
      'std::__1::vector<int, std::__1::allocator<int> >::vector' requested here
      : offsets_(1,1), current_offset_(),
        ^
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/dssp.cpp:6:
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/mas.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:504:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:643:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2250:9: error: 
      no matching constructor for initialization of '__compressed_pair_elem<int *, 0>'
      : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
        ^      ~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:455:7: note: 
      in instantiation of function template specialization 'std::__1::__compressed_pair<int *,
      std::__1::allocator<int> >::__compressed_pair<long, std::__1::allocator<int> >' requested here
      __end_cap_(nullptr, std::move(__a)) {}
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:1281:7: note: 
      in instantiation of member function 'std::__1::__vector_base<int, std::__1::allocator<int>
      >::__vector_base' requested here
    : __base(_VSTD::move(__x.__alloc()))
      ^
/usr/local/include/boost/token_functions.hpp:343:9: note: in instantiation of member function
      'std::__1::vector<int, std::__1::allocator<int> >::vector' requested here
  class offset_separator {
        ^
/usr/local/include/boost/date_time/gregorian/parsers.hpp:50:23: note: in instantiation of function template
      specialization 'boost::date_time::parse_undelimited_date<boost::gregorian::date>' requested here
    return date_time::parse_undelimited_date<date>(s);
                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2133:8: note: 
      candidate constructor (the implicit copy constructor) not viable: no known conversion from 'long' to
      'const std::__1::__compressed_pair_elem<int *, 0, false>' for 1st argument
struct __compressed_pair_elem {
       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2133:8: note: 
      candidate constructor (the implicit move constructor) not viable: no known conversion from 'long' to
      'std::__1::__compressed_pair_elem<int *, 0, false>' for 1st argument
struct __compressed_pair_elem {
       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2146:3: note: 
      candidate template ignored: substitution failure [with _Up = long, $1 = void]
  __compressed_pair_elem(_Up&& __u)
  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2153:3: note: 
      candidate constructor template not viable: requires 3 arguments, but 1 was provided
  __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2139:39: note: 
      candidate constructor not viable: requires 0 arguments, but 1 was provided
  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2147:9: error: 
      cannot initialize a member subobject of type 'short *' with an rvalue of type 'long'
      : __value_(_VSTD::forward<_Up>(__u))
        ^        ~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2250:9: note: 
      in instantiation of function template specialization 'std::__1::__compressed_pair_elem<short *, 0,
      false>::__compressed_pair_elem<long, void>' requested here
      : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:455:7: note: 
      in instantiation of function template specialization 'std::__1::__compressed_pair<short *,
      std::__1::allocator<short> >::__compressed_pair<long, std::__1::allocator<short> >' requested here
      __end_cap_(nullptr, std::move(__a)) {}
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:1243:7: note: 
      in instantiation of member function 'std::__1::__vector_base<short, std::__1::allocator<short>
      >::__vector_base' requested here
    : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
      ^
/Users/yhirose/Projects/pteros/thirdparty/dssp/align-2d.h:24:9: note: in instantiation of member function
      'std::__1::vector<short, std::__1::allocator<short> >::vector' requested here
                                                , m_positions(e.m_positions)
                                                  ^
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/dssp.cpp:6:
In file included from /Users/yhirose/Projects/pteros/thirdparty/dssp/mas.h:
yesint commented 4 years ago

Ups, I'm sorry for these troubles. Unfortunately pteros was never tested on Mac and apparently it doesn't compile there without some changes. I'll try to disable all third-party components and will commit the bare-bone version tomorrow.

yesint commented 4 years ago

@yhirose, please try the latest git. I've removed all offending code and I hope it should now compile on Mac up to the point where peglib is used.

yhirose commented 4 years ago

@yesint, I am now able to see the compile errors!

They are caused by the enhancement of AstBase constructors. (https://github.com/yhirose/cpp-peglib/commit/b76e4fe305d07b50dad80e25bc711ed843ff0cbe, https://github.com/yhirose/cpp-peglib/commit/b330799cd683f2884fe92cacd46cccc60c1f681c).

std::make_shared<MyAst>(...) calls with the latest peglib now require more parameters. The new parameters are useful information for debugging.

I am thinking to move these additional parameters to the end of the parameter list and make them with default values, so that your code doesn't need to make any change.

I'll let you know when it becomes ready.

yhirose commented 4 years ago

@yesint, I think I fixed it. Could you try with the latest peglib.h?

yesint commented 4 years ago

@yhirose, it works perfectly now! Thanks a lot!

yhirose commented 4 years ago

@yesint, glad to hear the problem is gone!

By the way, when I was looking in the section_parser.cpp, I found that name property in AstBase is used a number of times to check Ast node type. That's totally fine. But there is another way to check the type with tag property.

Here is the original code of is_node_coordinate_dependent:

bool is_node_coordinate_dependent(const std::shared_ptr<MyAst>& node){
    if(node->name == "X" || node->name == "Y" || node->name == "Z" || node->name == "WITHIN"
            || node->name == "POINT" || node->name == "PLANE" || node->name == "VECTOR" || node->name == "COM"
      ){
        return true;
    } else {
        return false;
    }
}

Here is a revised code with tag property.

bool is_node_coordinate_dependent(const std::shared_ptr<MyAst>& node){
    using namespace peg::udl;
    switch (node->tag){
    case "X"_:
    case "Y"_:
    case "WITHIN"_:
    case "POINT"_:
    case "PLANE"_:
    case "VECTOR"_:
    case "COM"_:
        return true;
    default:
        return false;
    }
}

tag is a 32-bits hash value for name property. "???"_ generates a 32-bits hash value for "???" string on compile time. So we can check Ast node type with integer comparison instead of slower string comparison. It also allows us to use switch statement which could make code a bit more readable.

Anyway, thank you for your interest in this library!

yesint commented 4 years ago

@yhirose, thanks a lot for suggestion! This was one of my questions of how to avoid rather costly string comparisons. This is a very clever way indeed! Thank you for your fantastic library!