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
added support for Pragma #101
Conversation
Yes, I'm fine with including pragmas in the AST, as long as the change is conservative - i.e. doesn't break other code and if we encounter pragmas we can tokenize but not parse yet it shouldn't fail (similarly to the way it's done now). |
I added and modified the unit test accordingly. Any other requests? |
@@ -795,3 +795,15 @@ def children(self): | |||
|
|||
attr_names = () | |||
|
|||
class Pragma(Node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not supposed to modify this file directly. It's auto generated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I forgot to add the changed _c_ast.cfg file to the commit. Added in 95ee04f
Anything else missing? |
Looks good. Please squash into a single commit and put as much info as possible into the commit message; then it's good to go. |
Preprocessor pragmas and their arguments are tokenized (as PPPRAGMA and PPPRAGMASTR) and included in the AST as a pppragma directive with the argument as value. If no argument was given the string will be empty. Unit test of the lexer, parser and generator have been modified and added accordingly. The previous behavior, that #pragma lines would be ignored, is henceforth obsolete.
Thanks! |
Is there any chance to include (optional) support for #pragma in the AST? I know it is not strictly C99, since it is supposed to be handled before and not through the AST.
Dirty patch included, just as an example.