RE2C How to abandon the current agreed rule and continue trying?

Is it possible to conditionally drop a rule after negotiation and continue to try to use other rules with a lower priority?

<SOME_STATE>{rule} {
    if(condition) {
        return TOKEN;
    }
    // discard
    // continue and try the other rules below...
}

<SOME_STATE>{other_rule} {
    return OTHER_TOKEN;
}

...

PS: conditiondepends on other permissions that cannot be matched with a regular expression

PS2: I was already looking for guidance :)

PS3: I can't solve this by clicking a new state

+4
source share
1 answer

I assume that you are using the default command line options, let me know if otherwise (the example -fcan make a difference, but in the end I have to check).

As a short answer, I would say no, this is not possible.

:

, , ( re2c, re2c?).

goto - , .

#include <stdio.h>
#include <string.h>
#define RET(n) printf("%d\n", n); return n
int scan(int i, char *s, int l){
char *p = s;
char *q;
#define YYCTYPE         char
#define YYCURSOR        p
#define YYLIMIT         (s+l)
#define YYMARKER        q
/*!re2c
    re2c:yyfill:enable = 0;
    any = [\000-\377];
*/
YYCTYPE *sc = YYCURSOR; /* save cursor */
/*!re2c
    "rule"  {printf("rule match\n");if(i==1) {RET(1);}}
    any     {goto other;}
*/
other:
YYCURSOR = sc;
/*!re2c
    "rule2" {printf("rule2 match\n"); RET(2);}
    any     {if(YYCURSOR==YYLIMIT) RET(0);}
*/
}
int main(int argc, char **argv) {
    int i;
    for (i=1; i < argc; i++) {
        fprintf(stderr, "[%d]:%s\n", i, argv[i]);
        scan(i, argv[i], strlen(argv[i]));
    }
    return 0;
}

, .

+1

All Articles