skvadrik / re2c

Lexer generator for C, C++, Go and Rust.
https://re2c.org
Other
1.06k stars 169 forks source link

handling digits in flex mode #483

Closed 2000jedi closed 1 month ago

2000jedi commented 1 month ago

Consider the following pattern of integer literal when the -F flag is given:

0|[1-9][0-9]* { /* ... */}

re2rust fails with error unexpected character: '0'

it requires to add double quotes or character classes around the literal 0

[0]|[1-9][0-9]* { /* ... */}

Should this be a bug in flex mode

skvadrik commented 1 month ago

I'm not sure why digits were not allowed - probably just an oversight, as flex mode is not the primary one. They don't cause any grammar ambiguities, so I just added them: https://github.com/skvadrik/re2c/commit/f2395c299886cfc5639f841f6445ab9ad0fa26f9.

helly25 commented 1 month ago

This was certainly an oversight. Apparently we did not end up needing it despite the complex original use case (convert all flex usage in PHP with RE2C).

On Sat, Jul 20, 2024 at 12:04 AM Ulya Trofimovich @.***> wrote:

I'm not sure why digits were not allowed - probably just an oversight, as flex mode is not the primary one. They don't cause any grammar ambiguities, so I just added them: f2395c2 https://github.com/skvadrik/re2c/commit/f2395c299886cfc5639f841f6445ab9ad0fa26f9 .

— Reply to this email directly, view it on GitHub https://github.com/skvadrik/re2c/issues/483#issuecomment-2240326850, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQ7NSKZSJBNPE2SZA5QAI3ZNGEOJAVCNFSM6AAAAABLEY32Q2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBQGMZDMOBVGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>