Skip to content

Wrong result only if another rule is present #57

@skvadrik

Description

@skvadrik

The following program produces the wrong result

3: \baaa

If the first rule [<]... is removed, the correct result is produced:

8:

This could be reproduced with re2c 0.13.7.5 and 0.14.1. Versions 0.13.5 and 0.13.6 work fine.

(This is a reduced testcase. The problem was discovered in a more complicated scanner in libcmark.)

#include <stdio.h>

int scan(const char *p)
{
#define YYCTYPE char
    const char *YYCURSOR = p;
    const char *YYMARKER;

/*!re2c
    re2c:yyfill:enable = 0;

    reg_char     = [a];
    escaped_char = [\\][b];

    [<] ([x] | escaped_char | [y])* [>] { return YYCURSOR - p; }
    (reg_char | escaped_char)* { return YYCURSOR - p; }
    . { return 0; }
*/
}

int main()
{
    const char *str = "aaa\\baaa";
    int res = scan(str);
    printf("%d: %s\n", res, str + res);
    return 0;
}

Original comment by: nwellnhof

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions