arithy / packcc

A parser generator for C
Other
347 stars 28 forks source link

Passing auxil to PCC_DEBUG #53

Closed masatake closed 3 years ago

masatake commented 3 years ago

To control what should be printed or not in PCC_DEBUG definition, I would like to pass auxil to the definition of PCC_DEBUG.

#define PCC_DEBUG(event, rule, level, pos, buffer, length) baseDebug(event, rule, level, pos, buffer, length)
static void baseDebug(int event, const char *rule, size_t level, size_t pos, const char *buffer, size_t len)
{
    if (strcmp(rule, "Identifier") != 0)
        return;

PCC_DEBUG can print too many things. In the example, the rule is examined to limit the output only about "Identifier". In the example, I have to do hardcode ("Identifier").

What I would like to do:

PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) baseDebug(auxil, event, rule, level, pos, buffer, length)

static void baseDebug(struct parserCtx *auxil, int event, const char *rule, size_t level, size_t pos, const char *buffer, size_t len)
{
       if (!isMember(parserCtx->debug_rules_dict, rule))
        return;

PCC_DEBUG is already explained in the README file. So I wonder whether extending it is acceptable or not.

arithy commented 3 years ago

Yes, I agree with your request. I was aware of lack of auxil argument only in this macro. I'll do this modification and add a notice to README soon.

arithy commented 3 years ago

@masatake, please try it.

masatake commented 3 years ago

Thank you! It works fine.

https://github.com/universal-ctags/ctags/pull/3178/commits/697bbc6840a544c22083a0f9ae19869f1bbade8c#diff-16532ef1fadf935d74a34545777d02806881fb789cfd2d6272d0a8554f827f82R128