arithy / packcc

A parser generator for C
Other
348 stars 29 forks source link

Parser seems to be successful but doesn't returns 0. #36

Closed DriNeo closed 3 years ago

DriNeo commented 3 years ago

Hello I'm testing this nice project with a minimal example.

%prefix "w"

test <-
    word   {puts("OK");}

word <-
    [_a-zA-Z]*

%%

int main()
{
        w_context_t  * ctx = w_create(NULL);
        printf("parse res: %d\n", w_parse(ctx, NULL));
        w_destroy(ctx);
       return 0;
}

When this parser reads a word and prints "OK" I guess the "test" rule is successful. But the "print" prints 1. There is no "Syntax error" default message. Is a kind person can explain what I'm doing wrong if it is not an issue ?