robotpy / robotpy-cppheaderparser

DEPRECATED: use cxxheaderparser instead
Other
123 stars 39 forks source link

I can't parse this code ";" #73

Closed Bestriverjg closed 2 years ago

Bestriverjg commented 2 years ago

I can't parse this code when I parse mysql source code:

static Sys_var_bool Sys_partial_revokes ( "partial_revokes" , "Access of database objects can be restricted, " "even if user has global privileges granted." , GLOBAL_VAR ( opt_partial_revokes ) , CMD_LINE ( OPT_ARG ) , DEFAULT ( DEFAULT_PARTIAL_REVOKES ) , NO_MUTEX_GUARD , IN_BINLOG , ON_CHECK ( check_partial_revokes ) , ON_UPDATE ( partial_revokes_update ) , 0 , sys_var :: PARSE_EARLY );

I'm not familiar with c++ but the python error is indicated here:

        if len(nameStack) < 2:  # +++
            if len(nameStack) == 1:
                self["type"] = nameStack[0]
                self["name"] = ""
            else:
                error_print("%s", _stack_)
                assert 0
Bestriverjg commented 2 years ago

I don't know much about the structure of c++, so I want to ask you about it

virtuald commented 2 years ago

That isn't valid C++ as-is, you need a preprocessor to handle the macros. As noted in our README:

If you need anything complex, you should preprocess the code yourself. You can use the excellent pure python preprocessor pcpp, or the preprocessing facilities provided by your favorite compiler.