-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[c] Update the C grammar to the latest ISO Spec, and fixing various issues. #4682
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
base: master
Are you sure you want to change the base?
Conversation
* Split grammar. * Add CSharp base class for parser. * Add missing lexer rules for string literals. * Limit targets to just CSharp for now. * Add disambiguation predicates, symbol table.
|
BS! Some of the examples in the test suite are not strict ISO C. For example, this should not parse. But, it does! It can't parse because a So, several of the examples provided should not parse, but they do. |
The example did not parse with "gcc -c -std=c2x". It's a requirement because a symbol table in needed to disambiguate the grammar, and with the symbol table, this can't parse!
Examples must parse with new symbol table implementation.
NB: This PR is still in progress. I am currently debugging the gcc compiler (actually cc1) to understand the parser flow and the grammar it implements, specifically for the gcc extensions. The old gcc extensions currently in the c grammar are incorrect.
This PR brings the C grammar up to date with the latest ISO Specification. It also fixes several critical bugs in the correctness of the parse with respect to types.
As noted in several reported Issues for c, several examples were parsed incorrectly. This was because the EBNF in the ISO Specification, which this grammar is based on, is ambiguous. To disambiguate the grammar, I added a symbol table to the grammar's actions.
At this point, any C code input must be pre-processed so that any and all definitions are included in the input. The parser must have this information to perform type checking and select the correct parse.
Fixed
Already fixed. Please close.