Closed cyanogilvie closed 2 years ago
Thanks for a complete example. Indeed re2c generates identically named tag variables for different conditions, and this causes collision if one of the variables is for an s-tag and the other one for an m-tag. You are the first to hit this issue!
I pushed a fix https://github.com/skvadrik/re2c/commit/7c6b5c955eae45c4b4c4bfd9f52efa9bbd09e2e3 that makes s-tag and m-tag variables non-overlapping by adding an "m" affix to the latter. This still allows sharing tag variables of the same kind between conditions, which saves one variable in your case.
With this fix your example compiles and runs like this:
waiting
waiting
waiting
waiting
waiting
media type: application/json
(charset) = ("utf\"-8")
done
Error exit: 1
It seems to lex the input correctly. I looked a bit why it returns 1 but I think there is an rc = 0
missing in the CON_STATUS_DONE
case.
Thanks for the fast response! That's great, it works perfectly for me now.
Yeah, the CON_STATUS_DONE handling is wrong, the example code was trimmed to the point of being meaningless, just enough to exercise the issue. The project it comes from has it deeply embedded in the IO layer (I would put it in the kernel using eBPF and directly lex the socket packet buffers if the validator would allow loops that can be proven to terminate).
re2c is my new favourite thing - with better than cycle-per-byte throughput nearly everything is starting to look like a target for it.
I'm trying to parse HTTP messages with a mix of conditions, stags and mtags, and I seem to be hitting an issue where the generated yyt* variables for the stag and mtag values collide, so:
produces:
leading to compile errors like:
The issue seems to be related to conditions - if the condition
<header>
is changed to<media_type>
in the following, the collision does not occur:I'm compiling with the switches
--conditions --case-ranges -W -Wno-nondeterministic-tags --storable-state
using the latest version from the master branch: 68e1ab716I'm new to using mtags, so I'm not sure if my mental model is just wrong, or I'm hitting a case that others haven't before (mixing conditions, stags and mtags)?