skvadrik / re2c

Lexer generator for C, C++, D, Go, Haskell, Java, JS, OCaml, Python, Rust, V and Zig.
https://re2c.org
Other
1.11k stars 174 forks source link

Support new Zig's labeled switch/continue #492

Closed Ev1lT3rm1nal closed 1 week ago

Ev1lT3rm1nal commented 1 month ago

So, issue https://github.com/ziglang/zig/pull/21257 was closed, adding support for new syntax for labeled switch/continue statements, which improves performance (somewhat like computed gotos in C). It would be great if re2c added this feature too, although it is currently in Zig's master branch.

skvadrik commented 1 month ago

I added labelled loops for Zig in https://github.com/skvadrik/re2c/commit/72a7d1b3039fe35ad7797fa7dda5042d1323314f (it hasn't been merged into master yet, but it will be merged soon). This feature is important for correctness, as it would be quite easy to forget about the hidden loop generated by re2c when enclosing it in an outer user-defined loop. It is possible to suppress label generation by setting re2c:label:yyloop = ""; (e.g. if the Zig toolchain in use doesn't have this feature yet).

Ev1lT3rm1nal commented 1 month ago

This looks awesome! Thank you for updating the library for the upcoming changes.