parserlib icon indicating copy to clipboard operation
parserlib copied to clipboard

I see a crash in the parser code

Open asmwarrior opened this issue 2 months ago • 4 comments

Here is the call stack of the crash, I attach the file in the txt, because it is too big, so I can't paste it in the edit control.

It looks like that the m_expr's get() function return a 0x0 in this function:

        parse_result parse_non_left_recursion(ParseContext& pc) noexcept {
            pc.push_rule_parse_position(*this);
            parse_result result = m_expr->parse(pc);
            pc.pop_rule_parse_position(*this);
            switch (result.value()) {
                case parse_result::FALSE:
                    return false;
                case parse_result::TRUE:
                    return true;
                case parse_result::LEFT_RECURSION:
                    return result.left_recursion_rule() == this ? parse_left_recursion(pc) : result;
            }
            return result;
        }

call-stack.txt

Sorry that my parser grammar code is large, so it is a bit hard to create a minimal code.

My code are in the add many lexer and parser ids, but the code will crash

And the source files are below:

cpp_lexer_grammar.cpp
cpp_lexer_grammar.h
cpp_parser_grammar.cpp
cpp_parser_grammar.h
main.cpp
ast_visitor.h

Thanks.

BTW: when the crash happens, It is really hard to see in which rule path it get crashed.

asmwarrior avatar Nov 07 '25 08:11 asmwarrior

It's impossible to find out which rule is the problematic one.

I suggest to add a name field in a rule, then set up their name, and then when it crashes, you examine the rule's name.

axilmar avatar Nov 07 '25 21:11 axilmar

It's impossible to find out which rule is the problematic one.

I suggest to add a name field in a rule, then set up their name, and then when it crashes, you examine the rule's name.

Hi, thanks for your reply.

What dose the "name field" mean? Can you give me a simple step by step instruction? I'd like to find some method to "debug" the rules. Thanks.

asmwarrior avatar Nov 08 '25 06:11 asmwarrior

Add the following field to the rule class:

const char* name;

Then set the names of your rules:

my_rule1.name = "my rule1";

Then when the crash happens, you can see in which rule it happened into.

On Sat, Nov 8, 2025, 08:40 ollydbg @.***> wrote:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3506071327

It's impossible to find out which rule is the problematic one.

I suggest to add a name field in a rule, then set up their name, and then when it crashes, you examine the rule's name.

Hi, thanks for your reply.

What dose the "name field" mean? Can you give me a simple step by step instruction? I'd like to find some method to "debug" the rules. Thanks.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3506071327, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFAOBZ5TZMRNYMEO6QT33WF6JAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBWGA3TCMZSG4 . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 08 '25 08:11 axilmar

Add the following field to the rule class:

const char* name;

Then set the names of your rules:

my_rule1.name = "my rule1";

Then when the crash happens, you can see in which rule it happened into.

OK, let me try this method, thanks.

asmwarrior avatar Nov 08 '25 14:11 asmwarrior

The bug is caused that I define a rule variable as a class member variable, but I do not initialized it, but later I just used it.

asmwarrior avatar Nov 19 '25 14:11 asmwarrior

Nice that you found it.

While writing and documenting an example which uses the library, I added some new features that will help debugging a lot.

The new feature is a simple 'm_text' field which will contain a text description of a parse node.

It has helped me tremendously.

Unfortunately, documenting all choices for the JSON parser takes a long time, so I will not be pushing the new version soon...

Στις Τετ 19 Νοε 2025 στις 4:53 μ.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3553147374

The bug is caused that I define a rule variable as a class member variable, but I do not initialized it, but later I just used it.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3553147374, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFAFHBF4QDZC7BNVF7L35R76NAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNJTGE2DOMZXGQ . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 20 '25 09:11 axilmar

OK, I can wait for the next release, no hurry.

asmwarrior avatar Nov 21 '25 14:11 asmwarrior

It looks like you have pushed the updated library code to the git master, and sadly my testing code has many build errors. asmwarrior/parserlib: A c++ recursive-descent PEG parsing library that supports left recursion.

The source code were all put in the root folder of the git.

Hopefully I will take some time to fix those build errors.

BTW, I see a lot of document files were removed?

asmwarrior avatar Nov 24 '25 13:11 asmwarrior

I actually uploaded the new version because my computer almost crashed today, and I was afraid I will lose it.

I've changed a few things, sorry for the inconvenience, but I think it was for the better.

I will help you as much as I can adjust to the new version.

Στις Δευ 24 Νοε 2025 στις 3:50 μ.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3570882830

It looks like you have pushed the updated library code to the git master, and sadly my testing code has many build errors. asmwarrior/parserlib: A c++ recursive-descent PEG parsing library that supports left recursion. https://github.com/asmwarrior/parserlib

The source code were all put in the root folder of the git.

Hopefully I will take some time to fix those build errors.

BTW, I see a lot of document files were removed?

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3570882830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFC326TNI7W5R6TBF5T36MEJ5AVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNZQHA4DEOBTGA . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 24 '25 14:11 axilmar

    using parse_context_type = parse_context<
        parserlib::line_counting_string<>,
        match_id_type,
        error_id_type,
        case_sensitive_comparator,
        empty_parse_context_extension
    >;

I used to write such code, see here:

https://github.com/asmwarrior/parserlib/blob/master/cpp_lexer_grammar.h#L74

But it looks like the line_counting_string does not exist any longer.

asmwarrior avatar Nov 25 '25 02:11 asmwarrior

Indeed.

It was not the best approach.

Now you have to write

parse_context<std::string, match_id_type, error_id_type, text_position, default_symbol_comparator_type>

I have written a very detailed explanation of the parse context in the readme (which I should split into different documents).

Στις Τρί 25 Νοε 2025 στις 4:43 π.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3573560642

using parse_context_type = parse_context<
    parserlib::line_counting_string<>,
    match_id_type,
    error_id_type,
    case_sensitive_comparator,
    empty_parse_context_extension
>;

I used to write such code, see here:

https://github.com/asmwarrior/parserlib/blob/master/cpp_lexer_grammar.h#L74

But it looks like the line_counting_string does not exist any longer.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3573560642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFAE5DDMMNKMMX2HM3336O66DAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNZTGU3DANRUGI . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 25 '25 09:11 axilmar

Thanks. I see some wired build error:


-------------- Build file: Debug in test_parser_lib (compiler: GNU GCC Compiler)---------------

[100.0%] g++.exe -Wall -fexceptions -g -Iinclude -c E:\F\code\parserlib\cpp_lexer_grammar.cpp -o obj\Debug\cpp_lexer_grammar.o
In file included from include/parserlib.hpp:19,
                 from E:\F\code\parserlib\cpp_lexer_grammar.h:6,
                 from E:\F\code\parserlib\cpp_lexer_grammar.cpp:1:
include/parserlib/named_parse_node.hpp: In member function 'void parserlib::named_parse_node<ParseNode>::set_name(const std::string&)':
include/parserlib/named_parse_node.hpp:67:22: error: no match for 'operator=' (operand types are 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} and 'const std::string' {aka 'const std::__cxx11::basic_string<char>'})
   67 |             m_name = name;
      |                      ^~~~
In file included from D:/code/msys2/mingw64/include/c++/14.2.0/string:54,
                 from E:\F\code\parserlib\cpp_lexer_grammar.h:4:
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
  817 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:817:7: note:   passing 'const std::string*' {aka 'const std::__cxx11::basic_string<char>*'} as 'this' argument discards qualifiers
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
  858 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:858:7: note:   conversion of argument 1 would be ill-formed:
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:941:8: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  941 |        operator=(const _Tp& __svt)
      |        ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:941:8: note:   template argument deduction/substitution failed:
In file included from D:/code/msys2/mingw64/include/c++/14.2.0/bits/char_traits.h:50,
                 from D:/code/msys2/mingw64/include/c++/14.2.0/string:42:
D:/code/msys2/mingw64/include/c++/14.2.0/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = std::__cxx11::basic_string<char>; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:941:8:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator=(const _Tp&) [with _Tp = std::__cxx11::basic_string<char>]'
  941 |        operator=(const _Tp& __svt)
      |        ^~~~~~~~
include/parserlib/named_parse_node.hpp:67:22:   required from here
   67 |             m_name = name;
      |                      ^~~~
D:/code/msys2/mingw64/include/c++/14.2.0/type_traits:2696:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2696 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  828 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:828:31: note:   no known conversion for argument 1 from 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} to 'const char*'
  828 |       operator=(const _CharT* __s)
      |                 ~~~~~~~~~~~~~~^~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  840 |       operator=(_CharT __c)
      |       ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:840:24: note:   no known conversion for argument 1 from 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} to 'char'
  840 |       operator=(_CharT __c)
      |                 ~~~~~~~^~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:926:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  926 |       operator=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
D:/code/msys2/mingw64/include/c++/14.2.0/bits/basic_string.h:926:42: note:   no known conversion for argument 1 from 'const std::string' {aka 'const std::__cxx11::basic_string<char>'} to 'std::initializer_list<char>'
  926 |       operator=(initializer_list<_CharT> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:\F\code\parserlib\cpp_lexer_grammar.h: At global scope:
E:\F\code\parserlib\cpp_lexer_grammar.h:85:5: error: 'parse_result' does not name a type
   85 |     parse_result parse(parse_context_type& pc) const noexcept;
      |     ^~~~~~~~~~~~
E:\F\code\parserlib\cpp_lexer_grammar.cpp:184:1: error: 'parse_result' does not name a type
  184 | parse_result cpp_lexer_grammar::parse(parse_context_type& pc) const noexcept
      | ^~~~~~~~~~~~
Process terminated with status 1 (0 minute(s), 5 second(s))
6 error(s), 1 warning(s) (0 minute(s), 5 second(s))
 

It looks like it points to the

        /**
         * Sets the name of the parse node.
         * @param name the name of the parse node.
         */
        void set_name(const std::string& name) {
            m_name = name;
        }

In the source file: include\parserlib\named_parse_node.hpp.

asmwarrior avatar Nov 26 '25 14:11 asmwarrior

It looks like the m_name is defined as "const", so can this variable be set in the function?

namespace parserlib {


    #ifndef NDEBUG
    /**
     * Parse node only used in debugging to attach a name to an expression.
     * Available only in debug mode.
     * @param ParseNode the child parse node type.
     */
    template <class ParseNode>
    class named_parse_node : public parse_node<named_parse_node<ParseNode>> {
    public:
        /**
         * Constructor.
         * @param name name of the expression.
         * @param parse_node the parse node to use for parsing.
         */
        named_parse_node(const std::string& name, const ParseNode& parse_node)
            : m_name(name)
            , m_parse_node(parse_node)
        {
        }

        /**
         * Invokes the child parse node.
         * @param pc the current parse context.
         * @return true on success, false on failure.
         */
        template <class ParseContext>
        bool parse(ParseContext& pc) const {
            return pc.parse(m_parse_node);
        }

        /**
         * Returns the name.
         * @return the name.
         */
        std::string text() const override {
            return m_name;
        }

        /**
         * Returns the parse node that is named.
         * @return the parse node that is named.
         */
        const ParseNode& parse_node() const {
            return m_parse_node;
        }

        /**
         * Returns the name.
         * @return the name.
         */
        const std::string& name() const {
            return m_name;
        }

        /**
         * Sets the name of the parse node.
         * @param name the name of the parse node.
         */
        void set_name(const std::string& name) {
            m_name = name;
        }

        #ifndef NDEBUG
        void init_tree() const override {
            m_parse_node.init();
        }
        #endif

    private:
        const std::string m_name;
        const ParseNode m_parse_node;
    };
    

asmwarrior avatar Nov 26 '25 14:11 asmwarrior

Why do I have a setter for the name there? I will remove the setter. The parse nodes are supposed to be immutable, except for the rule class.

Στις Τετ 26 Νοε 2025 στις 4:17 μ.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3581527303

It looks like the m_name is defined as "const", so can this variable be set in the function?

namespace parserlib {

#ifndef NDEBUG
/**
 * Parse node only used in debugging to attach a name to an expression.
 * Available only in debug mode.
 * @param ParseNode the child parse node type.
 */
template <class ParseNode>
class named_parse_node : public parse_node<named_parse_node<ParseNode>> {
public:
    /**
     * Constructor.
     * @param name name of the expression.
     * @param parse_node the parse node to use for parsing.
     */
    named_parse_node(const std::string& name, const ParseNode& parse_node)
        : m_name(name)
        , m_parse_node(parse_node)
    {
    }

    /**
     * Invokes the child parse node.
     * @param pc the current parse context.
     * @return true on success, false on failure.
     */
    template <class ParseContext>
    bool parse(ParseContext& pc) const {
        return pc.parse(m_parse_node);
    }

    /**
     * Returns the name.
     * @return the name.
     */
    std::string text() const override {
        return m_name;
    }

    /**
     * Returns the parse node that is named.
     * @return the parse node that is named.
     */
    const ParseNode& parse_node() const {
        return m_parse_node;
    }

    /**
     * Returns the name.
     * @return the name.
     */
    const std::string& name() const {
        return m_name;
    }

    /**
     * Sets the name of the parse node.
     * @param name the name of the parse node.
     */
    void set_name(const std::string& name) {
        m_name = name;
    }

    #ifndef NDEBUG
    void init_tree() const override {
        m_parse_node.init();
    }
    #endif

private:
    const std::string m_name;
    const ParseNode m_parse_node;
};

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3581527303, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFBBDTZOG64G55FMXWL36WZBHAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKOBRGUZDOMZQGM . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 26 '25 15:11 axilmar

Indeed.

It was not the best approach.

Now you have to write

parse_context<std::string, match_id_type, error_id_type, text_position, default_symbol_comparator_type>

I have written a very detailed explanation of the parse context in the readme (which I should split into different documents).

Στις Τρί 25 Νοε 2025 στις 4:43 π.μ., ο/η ollydbg @.***> έγραψε:

The lexer's parse_context works, but I'd try to modify the parser's context

The old definition is:

    using parse_context_type = parse_context<
        typename lexer<line_counting_string<>, lexer_grammar>::parsed_token_container_type,
        match_id_type,
        error_id_type,
        case_sensitive_comparator,
        empty_parse_context_extension
    >;

Can you tell me what is the new way to define the parse_context_type, it actually accept a steam of the lexer's token.

In the document, I see this:

parser_parse_context parser_pc = tokenizer_pc.derive_parse_context<AST_ID>();
expression.parse(parser_pc);

It looks like the parser's context is derived from the lexer? But sorry, I still can't find a way to define this type.

I also see in the source code:

result->parser.parse_context = result->tokenizer.parse_context.template derive_parse_context<typename ParserParseContext::match_id_type, typename ParserParseContext::error_id_type>();

Not sure how to use such kinds of code.

Can you help me? Thanks.

asmwarrior avatar Nov 27 '25 02:11 asmwarrior

class cpp_parser_grammar {
public:
    using lexer_grammar = cpp_lexer_grammar;

    enum class match_id_type {
        VAR_DECL,
        FUNC_DECL,
        FUNC_DEF,
        BLOCK,
        BLOCK_SKIP, // skipped function bodies
        CLASS_DEF,
        CLASS_ID,
        TOP_LEVEL,
        EXPRESSION_STATEMENT,
        FOR_LOOP,
        CONTROL_FLOW,
        PARAM_LIST,
        ENUM_DEF,
        TEMPLATE_PARAMS,
        TEMPLATE_FUNC_DECL,
        TEMPLATE_FUNC_DEF,
        TEMPLATE_CLASS_DEF,
        USING_DECL,

        STRUCT_DEF,
        NAMESPACE_DEF,
        TYPEDEF_DECL,
        ALIAS_DECL,
        RETURN_STMT,
        BREAK_STMT,
        CONTINUE_STMT,
        INCLUDE_DIRECTIVE,
        MACRO_DEFINE,
        MACRO_IF_BLOCK,
        SWITCH_STMT,
        CASE_LABEL,
        DEFAULT_LABEL,
        TRY_CATCH,
        THROW_STMT,
        OPERATOR_FUNC_DEF,
        OPERATOR_FUNC_DECL,
        CONSTRUCTOR_DEF,
        CONSTRUCTOR_DECL,
        DESTRUCTOR_DEF,
        DESTRUCTOR_DECL,
        TEMPLATE_SPEC_DEF,
        COMMENT,
        UNKNOWN_STATEMENT,
        ENUMBERATOR,
        ENUM_LIST,
        ENUM_ID,
        ENUMERATOR
    };

    enum class error_id_type {
        INVALID_TOKEN,
        INCOMPLETE_PARSE,
        INVALID_STATEMENT,
        INVALID_TEMPLATE
    };

    // Define the specific ParseContext type
    // using parse_context_type = cpp_lexer_grammar::parse_context_type::derive_parse_context<match_id_type>;


using parse_context_type = parse_context<
    lexer_grammar::parse_context_type::match_container_type,
    match_id_type,
    error_id_type,
    default_text_position,
    default_symbol_comparator
>;

It looks like the above parse_context_type of the parser is correct?

asmwarrior avatar Nov 27 '25 02:11 asmwarrior

You can always use your custom source type. For example:

using my_parse_context = parserlib::parse_context<MyContainer,

MyMatchId, MyErrorId>;

The method 'derive_parse_context' is used as a helper method that allows using the matches produced by one parse context to be used as input to another parse context. You don't have to use it, if you don't want this approach.

Στις Πέμ 27 Νοε 2025 στις 4:18 π.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3583954038

Indeed.

It was not the best approach.

Now you have to write

parse_context<std::string, match_id_type, error_id_type, text_position, default_symbol_comparator_type>

I have written a very detailed explanation of the parse context in the readme (which I should split into different documents).

Στις Τρί 25 Νοε 2025 στις 4:43 π.μ., ο/η ollydbg @.***> έγραψε: … <#m_-6268403081507020970_>

The lexer's parse_context works, but I'd try to modify the parser's context

The old definition is:

using parse_context_type = parse_context<
    typename lexer<line_counting_string<>, lexer_grammar>::parsed_token_container_type,
    match_id_type,
    error_id_type,
    case_sensitive_comparator,
    empty_parse_context_extension
>;

Can you tell me what is the new way to define the parse_context_type, it actually accept a steam of the lexer's token.

In the document, I see this:

parser_parse_context parser_pc = tokenizer_pc.derive_parse_context<AST_ID>(); expression.parse(parser_pc);

It looks like the parser's context is derived from the lexer? But sorry, I still can't find a way to define this type.

I also see in the source code:

result->parser.parse_context = result->tokenizer.parse_context.template derive_parse_context<typename ParserParseContext::match_id_type, typename ParserParseContext::error_id_type>();

Not sure how to use such kinds of code.

Can you help me? Thanks.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3583954038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFB745LDXU57XQXPAF336ZNPDAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKOBTHE2TIMBTHA . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 27 '25 08:11 axilmar

Indeed, it's correct, if you want to use the matches created by the lexer as input to the parser.

Στις Πέμ 27 Νοε 2025 στις 4:46 π.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3583998516

class cpp_parser_grammar { public: using lexer_grammar = cpp_lexer_grammar;

enum class match_id_type {
    VAR_DECL,
    FUNC_DECL,
    FUNC_DEF,
    BLOCK,
    BLOCK_SKIP, // skipped function bodies
    CLASS_DEF,
    CLASS_ID,
    TOP_LEVEL,
    EXPRESSION_STATEMENT,
    FOR_LOOP,
    CONTROL_FLOW,
    PARAM_LIST,
    ENUM_DEF,
    TEMPLATE_PARAMS,
    TEMPLATE_FUNC_DECL,
    TEMPLATE_FUNC_DEF,
    TEMPLATE_CLASS_DEF,
    USING_DECL,

    STRUCT_DEF,
    NAMESPACE_DEF,
    TYPEDEF_DECL,
    ALIAS_DECL,
    RETURN_STMT,
    BREAK_STMT,
    CONTINUE_STMT,
    INCLUDE_DIRECTIVE,
    MACRO_DEFINE,
    MACRO_IF_BLOCK,
    SWITCH_STMT,
    CASE_LABEL,
    DEFAULT_LABEL,
    TRY_CATCH,
    THROW_STMT,
    OPERATOR_FUNC_DEF,
    OPERATOR_FUNC_DECL,
    CONSTRUCTOR_DEF,
    CONSTRUCTOR_DECL,
    DESTRUCTOR_DEF,
    DESTRUCTOR_DECL,
    TEMPLATE_SPEC_DEF,
    COMMENT,
    UNKNOWN_STATEMENT,
    ENUMBERATOR,
    ENUM_LIST,
    ENUM_ID,
    ENUMERATOR
};

enum class error_id_type {
    INVALID_TOKEN,
    INCOMPLETE_PARSE,
    INVALID_STATEMENT,
    INVALID_TEMPLATE
};

// Define the specific ParseContext type
// using parse_context_type = cpp_lexer_grammar::parse_context_type::derive_parse_context<match_id_type>;

using parse_context_type = parse_context< lexer_grammar::parse_context_type::match_container_type, match_id_type, error_id_type, default_text_position, default_symbol_comparator

;

It looks like the above parse_context_type of the parser is correct?

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3583998516, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFALOBYE3PXACCLYOC336ZQY5AVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKOBTHE4TQNJRGY . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 27 '25 08:11 axilmar

You can always use your custom source type. For example:

using my_parse_context = parserlib::parse_context<MyContainer,

MyMatchId, MyErrorId>;

The method 'derive_parse_context' is used as a helper method that allows using the matches produced by one parse context to be used as input to another parse context. You don't have to use it, if you don't want this approach.

OK, thanks. I'm currently still fixing building my project here and there.

Indeed, it's correct, if you want to use the matches created by the lexer as input to the parser.

Yes, it works. I think AI is better than me to understand the library code.

asmwarrior avatar Nov 30 '25 03:11 asmwarrior

I wouldn't consider the code complicated.

It's one of those things that if one understands the reasoning, then it becomes very easy.

Στις Κυρ 30 Νοε 2025 στις 5:13 π.μ., ο/η ollydbg @.***> έγραψε:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3592148920

You can always use your custom source type. For example:

using my_parse_context = parserlib::parse_context<MyContainer,

MyMatchId, MyErrorId>;

The method 'derive_parse_context' is used as a helper method that allows using the matches produced by one parse context to be used as input to another parse context. You don't have to use it, if you don't want this approach.

OK, thanks. I'm currently still fixing building my project here and there.

Indeed, it's correct, if you want to use the matches created by the lexer as input to the parser.

Yes, it works. I think AI is better than me to understand the library code.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3592148920, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFAGAXQPLH2S3MMIT2L37JOGVAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKOJSGE2DQOJSGA . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Nov 30 '25 10:11 axilmar

I have hard time to solve the build issue.

I can just upload the 3 files: 1 header file, and 2 cpp files in a code.zip file.

The error message happens in the link time, and the message is extremely large, such as:


-------------- Clean: Debug in test_parser_lib (compiler: GNU GCC Compiler)---------------

Cleaned "test_parser_lib - Debug"

-------------- Build: Debug in test_parser_lib (compiler: GNU GCC Compiler)---------------

[ 33.3%] g++.exe -Wall -fexceptions -g -Iinclude -c E:\F\code\parserlib\cpp_lexer_grammar.cpp -o obj\Debug\cpp_lexer_grammar.o
[ 66.7%] g++.exe -Wall -fexceptions -g -Iinclude -c E:\F\code\parserlib\main.cpp -o obj\Debug\main.o
[100.0%] g++.exe  -o bin\Debug\test_parser_lib.exe obj\Debug\cpp_lexer_grammar.o obj\Debug\main.o   
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.data+0x0): undefined reference to `typeinfo for parserlib::loop_break_exception'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.text$_ZNK9parserlib4ruleINS_13parse_contextINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN17cpp_lexer_grammar13match_id_typeENS8_13error_id_typeENS_13text_positionENS_25default_symbol_comparatorEJEEEE5parseERSD_[_ZNK9parserlib4ruleINS_13parse_contextINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN17cpp_lexer_grammar13match_id_typeENS8_13error_id_typeENS_13text_positionENS_25default_symbol_comparatorEJEEEE5parseERSD_]+0x266): undefined reference to `.refptr._ZNSt11logic_errorD1Ev'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEESK_EEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEESK_EEE]+0x28): undefined reference to `typeinfo for parserlib::sequence_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEEEEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEEEEE]+0x28): undefined reference to `typeinfo for parserlib::sequence_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_NS1_IS3_NS4_IJNSI_INS0_IJSK_SK_S6_EEEEENS7_INS0_IJSK_SK_S6_SK_EEEEEEEEEEEEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_NS1_IS3_NS4_IJNSI_INS0_IJSK_SK_S6_EEEEENS7_INS0_IJSK_SK_S6_SK_EEEEEEEEEEEEE]+0x28): undefined reference to `typeinfo for parserlib::choice_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to `typeinfo for parserlib::choice_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to `typeinfo for parserlib::choice_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to `typeinfo for parserlib::choice_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to `typeinfo for parserlib::choice_parse_node_base'
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): more undefined references to `typeinfo for parserlib::choice_parse_node_base' follow
D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_1_parse_nodeINS_17choice_parse_nodeIJNS_16range_parse_nodeIcEES4_NS_17symbol_parse_nodeIcEEEEEEENS_17loop_0_parse_nodeINS2_IJS4_S4_S6_S4_EEEEEEEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_1_parse_nodeINS_17choice_parse_nodeIJNS_16range_parse_nodeIcEES4_NS_17symbol_parse_nodeIcEEEEEEENS_17loop_0_parse_nodeINS2_IJS4_S4_S6_S4_EEEEEEEE]+0x28): undefined reference to `typeinfo for parserlib::sequence_parse_node_base'



a lot of messages, it looks very long

Can you have a look? Thanks.

code.zip

asmwarrior avatar Dec 04 '25 12:12 asmwarrior

Perhaps you should enable rtti? There are messages that type info is missing.

Unfortunately, gcc obfuscates the class names...

On Thu, Dec 4, 2025, 14:32 ollydbg @.***> wrote:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3612024984

I have hard time to solve the build issue.

I can just upload the 3 files: 1 header file, and 2 cpp files in a code.zip file.

The error message happens in the link time, and the message is extremely large, such as:

-------------- Clean: Debug in test_parser_lib (compiler: GNU GCC Compiler)---------------

Cleaned "test_parser_lib - Debug"

-------------- Build: Debug in test_parser_lib (compiler: GNU GCC Compiler)---------------

[ 33.3%] g++.exe -Wall -fexceptions -g -Iinclude -c E:\F\code\parserlib\cpp_lexer_grammar.cpp -o obj\Debug\cpp_lexer_grammar.o [ 66.7%] g++.exe -Wall -fexceptions -g -Iinclude -c E:\F\code\parserlib\main.cpp -o obj\Debug\main.o [100.0%] g++.exe -o bin\Debug\test_parser_lib.exe obj\Debug\cpp_lexer_grammar.o obj\Debug\main.o D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.data+0x0): undefined reference to typeinfo for parserlib::loop_break_exception' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.text$_ZNK9parserlib4ruleINS_13parse_contextINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN17cpp_lexer_grammar13match_id_typeENS8_13error_id_typeENS_13text_positionENS_25default_symbol_comparatorEJEEEE5parseERSD_[_ZNK9parserlib4ruleINS_13parse_contextINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN17cpp_lexer_grammar13match_id_typeENS8_13error_id_typeENS_13text_positionENS_25default_symbol_comparatorEJEEEE5parseERSD_]+0x266): undefined reference to .refptr._ZNSt11logic_errorD1Ev' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEESK_EEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEESK_EEE]+0x28): undefined reference to typeinfo for parserlib::sequence_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEEEEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_0_parse_nodeINS_17choice_parse_nodeIJNS_17symbol_parse_nodeIcEES4_NS_17string_parse_nodeIcEES4_S4_NS0_IJS6_NS1_INS0_IJNS_22logical_not_parse_nodeINS2_IJS6_S4_S4_EEEEENS_14any_parse_nodeEEEEEEEEENS0_IJS6_NS1_INS0_IJNS7_IS6_EESA_EEEEES6_EEENS0_IJS4_SC_EEEEEEEENS2_IJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS0_IJS4_NS1_INS2_IJS6_S6_S6_S6_NS0_IJNS7_IS4_EESA_EEEEEEEES4_EEEEENSL_ISN_NS0_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS0_IJS4_SX_EEEEEEEEEENSL_ISN_S6_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_NSL_ISN_S4_EES14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_S14_NSL_ISN_NS0_IJNSU_INS2_IJSW_SW_S4_EEEEENS1_INS2_IJSW_SW_S4_SW_EEEEEEEEEEEEEEEE]+0x28): undefined reference to typeinfo for parserlib::sequence_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_NS1_IS3_NS4_IJNSI_INS0_IJSK_SK_S6_EEEEENS7_INS0_IJSK_SK_S6_SK_EEEEEEEEEEEEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_NS1_IS3_NS4_IJNSI_INS0_IJSK_SK_S6_EEEEENS7_INS0_IJSK_SK_S6_SK_EEEEEEEEEEEEE]+0x28): undefined reference to typeinfo for parserlib::choice_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to typeinfo for parserlib::choice_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to typeinfo for parserlib::choice_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to typeinfo for parserlib::choice_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): undefined reference to typeinfo for parserlib::choice_parse_node_base' D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE[_ZTIN9parserlib17choice_parse_nodeIJNS_16match_parse_nodeIN17cpp_lexer_grammar13match_id_typeENS_19sequence_parse_nodeIJNS_17symbol_parse_nodeIcEENS_17loop_0_parse_nodeINS0_IJNS_17string_parse_nodeIcEES9_S9_S9_NS4_IJNS_22logical_not_parse_nodeIS6_EENS_14any_parse_nodeEEEEEEEEES6_EEEEENS1_IS3_NS4_IJNS_17loop_1_parse_nodeINS_16range_parse_nodeIcEEEENS_19optional_parse_nodeINS4_IJS6_SL_EEEEEEEEEENS1_IS3_S9_EESR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_SR_NS1_IS3_S6_EESS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_EEE]+0x28): more undefined references to typeinfo for parserlib::choice_parse_node_base' follow D:/code/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Debug\cpp_lexer_grammar.o:cpp_lexer_grammar.cpp:(.rdata$_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_1_parse_nodeINS_17choice_parse_nodeIJNS_16range_parse_nodeIcEES4_NS_17symbol_parse_nodeIcEEEEEEENS_17loop_0_parse_nodeINS2_IJS4_S4_S6_S4_EEEEEEEE[_ZTIN9parserlib19sequence_parse_nodeIJNS_17loop_1_parse_nodeINS_17choice_parse_nodeIJNS_16range_parse_nodeIcEES4_NS_17symbol_parse_nodeIcEEEEEEENS_17loop_0_parse_nodeINS2_IJS4_S4_S6_S4_EEEEEEEE]+0x28): undefined reference to `typeinfo for parserlib::sequence_parse_node_base'

a lot of messages, it looks very long

Can you have a look? Thanks.

code.zip https://github.com/user-attachments/files/23932780/code.zip

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3612024984, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFHI3ARENOOQ5CCUPWL4AASWZAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMJSGAZDIOJYGQ . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Dec 04 '25 21:12 axilmar

Perhaps you should enable rtti? There are messages that type info is missing.

As far as I know, the g++ has enabled rtti option by default.

asmwarrior avatar Dec 06 '25 10:12 asmwarrior

    template <class F>
    bool do_catch_loop_break(const F& f, const bool result_on_break = true) {
        try {
            return f();
        }
        catch (loop_break_exception ex) {
            if (ex.levels > 1) {
                throw loop_break_exception{ ex.levels - 1 };
            }
        }
        return result_on_break;
    }

I see the throw type is:

    /**
     * Exception thown to break the current loop.
     */
    struct loop_break_exception {
        /**
         * Number of nested loops to break.
         */
        const size_t levels;
    };

After AI reading the linker errors, it told me that the struct should be derived from the std::exception.

asmwarrior avatar Dec 07 '25 01:12 asmwarrior

diff --git a/include/parserlib/choice_parse_node.hpp b/include/parserlib/choice_parse_node.hpp
index ed4be59..a1c9ef8 100644
--- a/include/parserlib/choice_parse_node.hpp
+++ b/include/parserlib/choice_parse_node.hpp
@@ -17,9 +17,12 @@ namespace parserlib {
      * Base class for choice parse nodes.
      */
     class choice_parse_node_base {
+    public:
+        virtual ~choice_parse_node_base() = default;
     };

And

diff --git a/include/parserlib/loop_break_parse_node.hpp b/include/parserlib/loop_break_parse_node.hpp
index 644323b..0a63d52 100644
--- a/include/parserlib/loop_break_parse_node.hpp
+++ b/include/parserlib/loop_break_parse_node.hpp
@@ -12,14 +12,18 @@ namespace parserlib {
     /**
      * Exception thown to break the current loop.
      */
-    struct loop_break_exception {
-        /**
+    struct loop_break_exception : public std::exception {
+    	/**
          * Number of nested loops to break.
          */
         const size_t levels;
+        inline loop_break_exception(size_t n) noexcept : levels(n) {}
+        inline ~loop_break_exception() noexcept override = default;
+        inline const char* what() const noexcept override { return "loop break"; }
     };
 
 
+
     /**
      * A parse node that can break a loop by throwing an exception.
      * The loop will take the exception and break out of the loop algorithm.

and

diff --git a/include/parserlib/sequence_parse_node.hpp b/include/parserlib/sequence_parse_node.hpp
index 62a70e8..8204680 100644
--- a/include/parserlib/sequence_parse_node.hpp
+++ b/include/parserlib/sequence_parse_node.hpp
@@ -17,22 +17,25 @@ namespace parserlib {
      * Base class for sequence parse nodes.
      */
     class sequence_parse_node_base {
+    public:
+        virtual ~sequence_parse_node_base() = default;
     };
 
 
+
     /**
      * A parse node that invokes a series of children parse nodes to parse.
      * All the children must parse successfully in order for this parse node to parse successfully.
      * @param ParseNodes list of children parse node types.
      */

With this changes, I see some of the build errors are gone, but I still see many other complex build/linker errors, can you try to use a GCC compiler to test the code?

My guess is that you are using MSVC compiler, and GCC compiler is strict about the C++ rules?

asmwarrior avatar Dec 07 '25 01:12 asmwarrior

AI told me that my rule in the lexer_grammar cpp file:

return *( skip_element >> token >> skip_element );

is bad. But those rules were correct and works OK in some old revision of the parserlib.

Currently, it looks like the skip_element will trigger some loop break error, because it is a * like rule.

asmwarrior avatar Dec 07 '25 03:12 asmwarrior

There is no need to have all exceptions be derived from std exceptions.

Especially since loop break is not an actual exception, it is a go-to.

What are the linker errors you are

On Sun, Dec 7, 2025, 03:26 ollydbg @.***> wrote:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3621460738

template <class F>
bool do_catch_loop_break(const F& f, const bool result_on_break = true) {
    try {
        return f();
    }
    catch (loop_break_exception ex) {
        if (ex.levels > 1) {
            throw loop_break_exception{ ex.levels - 1 };
        }
    }
    return result_on_break;
}

I see the throw type is:

/**
 * Exception thown to break the current loop.
 */
struct loop_break_exception {
    /**
     * Number of nested loops to break.
     */
    const size_t levels;
};

After AI reading the linker errors, it told me that the struct should be derived from the std::exception.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3621460738, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFH6WLNLN2GB4DXVAN34AN62ZAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMRRGQ3DANZTHA . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Dec 07 '25 08:12 axilmar

I have compiled it not only with msvc, but with gcc as well (mingw64 on windows, through code blocks).

I didn't get any compiler and linker errors.

Are you compiling with c++17?

On Sun, Dec 7, 2025, 03:50 ollydbg @.***> wrote:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3621477130

diff --git a/include/parserlib/choice_parse_node.hpp b/include/parserlib/choice_parse_node.hpp index ed4be59..a1c9ef8 100644 --- a/include/parserlib/choice_parse_node.hpp +++ b/include/parserlib/choice_parse_node.hpp @@ -17,9 +17,12 @@ namespace parserlib { * Base class for choice parse nodes. */ class choice_parse_node_base {

  • public:
  •    virtual ~choice_parse_node_base() = default;
    
    };

And

diff --git a/include/parserlib/loop_break_parse_node.hpp b/include/parserlib/loop_break_parse_node.hpp index 644323b..0a63d52 100644 --- a/include/parserlib/loop_break_parse_node.hpp +++ b/include/parserlib/loop_break_parse_node.hpp @@ -12,14 +12,18 @@ namespace parserlib { /** * Exception thown to break the current loop. */

  • struct loop_break_exception {
  •    /**
    
  • struct loop_break_exception : public std::exception {

  • /**
        * Number of nested loops to break.
        */
       const size_t levels;
    
  •    inline loop_break_exception(size_t n) noexcept : levels(n) {}
    
  •    inline ~loop_break_exception() noexcept override = default;
    
  •    inline const char* what() const noexcept override { return "loop break"; }
    

    };

  • /** * A parse node that can break a loop by throwing an exception. * The loop will take the exception and break out of the loop algorithm.

and

diff --git a/include/parserlib/sequence_parse_node.hpp b/include/parserlib/sequence_parse_node.hpp index 62a70e8..8204680 100644 --- a/include/parserlib/sequence_parse_node.hpp +++ b/include/parserlib/sequence_parse_node.hpp @@ -17,22 +17,25 @@ namespace parserlib { * Base class for sequence parse nodes. */ class sequence_parse_node_base {

  • public:

  •    virtual ~sequence_parse_node_base() = default;
    

    };

  • /** * A parse node that invokes a series of children parse nodes to parse. * All the children must parse successfully in order for this parse node to parse successfully. * @param ParseNodes list of children parse node types. */

With this changes, I see some of the build errors are gone, but I still see many other complex build/linker errors, can you try to use a GCC compiler to test the code?

My guess is that you are using MSVC compiler, and GCC compiler is strict about the C++ rules?

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3621477130, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFARIX4DU2RSKVWCONT4AOBU3AVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMRRGQ3TOMJTGA . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Dec 07 '25 08:12 axilmar

Can I see your full code somewhere? I cannot understand why you are doing a return, have you written your own parsing functions?

On Sun, Dec 7, 2025, 05:02 ollydbg @.***> wrote:

asmwarrior left a comment (axilmar/parserlib#31) https://github.com/axilmar/parserlib/issues/31#issuecomment-3621533962

AI told me that my rule in the lexer_grammar cpp file:

return *( skip_element >> token >> skip_element );

is bad. But those rules were correct and works OK in some old revision of the parserlib.

Currently, it looks like the skip_element will trigger some loop break error, because it is a * like rule.

— Reply to this email directly, view it on GitHub https://github.com/axilmar/parserlib/issues/31#issuecomment-3621533962, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESDFGFD2KALBPO7RQIG634AOKDLAVCNFSM6AAAAACLNLJUKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMRRGUZTGOJWGI . You are receiving this because you commented.Message ID: @.***>

axilmar avatar Dec 07 '25 08:12 axilmar

Can I see your full code somewhere? I cannot understand why you are doing a return, have you written your own parsing functions?

Hi, the complete code is in this comment:

https://github.com/axilmar/parserlib/issues/31#issuecomment-3612024984

You can see a code.zip file attached. In the zip file, I have the lexer grammar code, there are 2 cpp files and 1 header files. Just drag them to any project, and build it.

I'm using GCC 14.2, I believe it is using C++ 17 by default. Because my code builds OK one month ago before the code-refactoring about the parserlib.

Thanks.

asmwarrior avatar Dec 07 '25 10:12 asmwarrior