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

added support for Pragma #101

Merged
merged 1 commit into from Oct 20, 2015
Merged

added support for Pragma #101

merged 1 commit into from Oct 20, 2015

Conversation

cod3monk
Copy link
Contributor

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.

@eliben
Copy link
Owner

eliben commented Oct 13, 2015

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).

@cod3monk
Copy link
Contributor Author

I added and modified the unit test accordingly. Any other requests?
Do you think the additional token will break any code?

@@ -795,3 +795,15 @@ def children(self):

attr_names = ()

class Pragma(Node):
Copy link
Owner

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

Copy link
Contributor Author

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

@cod3monk
Copy link
Contributor Author

Anything else missing?

@eliben
Copy link
Owner

eliben commented Oct 20, 2015

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.
eliben added a commit that referenced this pull request Oct 20, 2015
@eliben eliben merged commit fd2c773 into eliben:master Oct 20, 2015
@eliben
Copy link
Owner

eliben commented Oct 20, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants