Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Transparent handling of #line directives in input files #98
I was playing around with a project where I pass the re2c input file through a preprocessor (m4) first. For best results in this situation, it’s best if re2c can handle #file directives in its input file.
The attached patch to 0.13.3 accomplishes this. While it takes reasonable precautions against false matches for #line directives, it does not strictly check for the directives to start at the beginning of a line (as far as I know, re2c does not yet support the ^pattern syntax, does it?)
While I tried to match the general style of re2c’s source code, I’m open to reworking the patch to meet any further standards I may have missed.
Original comment by: neeri
Logged In: YES
I think it is a good idea and I am going to add it. However I need to change your patch a bit. And I will need a few tests for it. Also a patch for documentation might be good. Dunno how right now, tough.
Original comment by: helly
This doesn't appear to be working. I tried to use lemon output (with #line directives) as re2c input and large parts of the generated source got deleted. If I try feeding the output of running re2c on
(from the docs) back to re2c with
re2c example.c.re |re2c -
/* Generated by re2c 1.0.3 on Mon Jun 25 20:48:07 2018 */
(I'm on an older browser and I'm having some difficulties with the commenting tool, so apologies for the formatting.)