Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C] Implement line marker rule #4154

Open
atirut-w opened this issue Jul 6, 2024 · 1 comment
Open

[C] Implement line marker rule #4154

atirut-w opened this issue Jul 6, 2024 · 1 comment
Labels

Comments

@atirut-w
Copy link

atirut-w commented Jul 6, 2024

This will be very useful for writing compilers, since line markers is the standard way to convey information where a line is from after a file has been preprocessed, and they can be used as "offsets" for proper error reporting.

@kaby76
Copy link
Contributor

kaby76 commented Jul 6, 2024

The c grammar does not implement preprocessor directives, including #line. We don't implement a preprocessor.

But, let's assume that you generated the post-processed input via cpp or gcc -E. This would contain #line directives. For a concrete example, let's take the
source file hw.c-pre.txt and the post-processed generated file hw.c-post.txt

I assume that you'd want a lexer that creates a new token type that contains the additional information that computes the line/column back to the original source. However, in the example I provide, some #line directives don't follow the ISO spec. (The current draft is https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf. We don't have a grammar for the newest spec.)

It's possible to do something, but I don't have time at the moment to understand the #line directives that aren't ISO 9899 compliant, and to implement this.

@KvanTTT KvanTTT added the c label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants