summaryrefslogtreecommitdiff
path: root/pycparser/c_parser.py
Commit message (Collapse)AuthorAgeFilesLines
* Feature/add pragma support (#487)Jordy Ruiz2023-01-081-1/+9
| | | | | | | | | * Support _Pragma, a C99 alternative to #pragma See https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html * Test cases for _Pragma * Add explanatory comment for _PRAGMA and PPPRAGMA
* Fix #479 (multi-pragma/single statement blocks) (#480)ldore2022-11-101-3/+9
|
* Fix typos (#443)Kian Meng Ang2021-10-181-2/+2
| | | | | * Fix typos * Revert changes in vendor module
* Fix Flake8 Errors (#442)Eisuke Kawashima2021-10-151-4/+2
| | | | | | | | | * Fix PEP8 [E101](https://github.com/PyCQA/pycodestyle/blob/2.8.0/docs/intro.rst#error-codes) * Fix PEP8 [E711](https://github.com/PyCQA/pycodestyle/blob/2.8.0/docs/intro.rst#error-codes) * Fix E999 (python2) * Fix PEP8 [F401](https://flake8.pycqa.org/en/4.0.1/user/error-codes.html)
* Implement C23 _Static_assert without message (#440)Vitaly Cheptsov2021-10-051-1/+5
| | | Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
* Implement u8, u, and U strings from C11 (#439)Vitaly Cheptsov2021-10-051-0/+9
| | | | | | | * Implement u8, u, and U strings from C11 * Also add u8, u, and U chars from C11 and C23 Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
* Implement _Alignas and _Alignof support with tests (#435)Vitaly Cheptsov2021-10-041-9/+44
| | | | | | | | | | | | | | | * Implement _Alignas and _Alignof support with tests * Improve testing and avoid unnecessary alignas for typedef * Add more tests * Drop legacy artifact * Remove extra _add_declaration_specifier call * Drop custom equality comparators for now Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
* Simplify usage of _add_declaration_specifierEli Bendersky2021-09-251-2/+1
|
* Clean up some commentsEli Bendersky2021-09-201-2/+2
|
* Improve _Atomic support and add more tests (#431)Vitaly Cheptsov2021-09-201-3/+11
| | | | | | | | | * Improve _Atomic support with more tests and fix typedef handling * Remove duplicated tests and check the generated code for typedefs * Add typedef testing to parser as well Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
* Rename debuglevel->debug flag to the parserEli Bendersky2021-09-161-4/+4
| | | | Now it matches the yacc flag name
* A different, more robust appoach to fix _Atomic specifiers.Eli Bendersky2021-09-131-33/+7
| | | | | Now the ASTs produced are more correct, and more complex cases work like nested _Atomic(...) specifiers.
* Implement atomic specifiers like _Atomic(int*).Eli Bendersky2021-09-131-6/+34
| | | | | Based on #431 by vit9696 Updates #430
* Support _Atomic as a qualifierEli Bendersky2021-09-131-0/+1
| | | | | | | This adds initial implementation for the _Atomic keyword in C11, only focusing on the use as qualifier (spec section 6.7.3) Based on #431 by vit9696. Updates #430
* Introduce partial C11 support (#429)Vitaly Cheptsov2021-08-311-0/+17
| | | | | | | | | | * Introduce partial C11 support Implemented _Noreturn, _Static_assert, _Thread_local. Also fixed tests with preprocessor on macOS. * Add more tests Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
* Add a tricky test, and reformat some commentsEli Bendersky2021-08-281-19/+12
|
* c_parser: support parenthesized compounds (#423)Jordan Yates2021-07-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * c_parser: support parenthesized compounds Support parenthesized compound statements as described here: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au> * test_c_parser: support additional initializers Add support to `expand_init` for additional `c_ast` types. If a type is not explicitly handled, return the type name instead of `None`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au> * test_c_parser: test parenthesized compounds Add parsing tests for various situations of parenthesized compound statements. The complete tree generated by the test string is: ``` FileAST: FuncDef: Decl: foo, [], [], [] FuncDecl: TypeDecl: foo, [] IdentifierType: ['void'] Compound: Decl: a, [], [], [] TypeDecl: a, [] IdentifierType: ['int'] Compound: Compound: Constant: int, 1 Compound: Constant: int, 1 Constant: int, 2 Decl: b, [], [], [] TypeDecl: b, [] IdentifierType: ['int'] Compound: Constant: int, 1 Decl: c, [], [], [] TypeDecl: c, [] IdentifierType: ['int'] Decl: d, [], [], [] TypeDecl: d, [] IdentifierType: ['int'] Compound: Decl: x, [], [], [] TypeDecl: x, [] IdentifierType: ['int'] Constant: int, 1 BinaryOp: + ID: x Constant: int, 2 Assignment: = ID: a Compound: Decl: x, [], [], [] TypeDecl: x, [] IdentifierType: ['int'] Constant: int, 1 BinaryOp: * Constant: int, 2 ID: x ``` Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
* Added flattening of abundant parenthesis in CGenerator (#394)Julian2020-10-051-0/+1
|
* Fix issues #378, #379, #385 (#387)Zecong Hu2020-07-181-5/+7
| | | | | | | | | | | | * Fix #385: generate code with nested sizeofs * Fix #378: replace assertion with check Only the assertion inside `_build_function_definition` is replaced. The assertion is not appropriate because there are possible inputs that would trigger the assertion, they're just grammatically incorrect. Thus, it is replaced with a check that raises `ParseError` on failure. * Fix #379: parse struct with nested enum
* Fix #363 incorrect AST when parsing offsetof (#364)Zecong Hu2020-03-031-2/+1
|
* Recognize integer multicharacter constants like 'ABCD' (#350)yaroslav-o2019-09-251-0/+1
| | | | | | | | | | | | | Recognize integer multicharacter constants like 'ABCD' The feature I am adding is defined here - 5th case. https://en.cppreference.com/w/c/language/character_constant Also here: 6.4.4.4.10 of C99. Put simply, pycparser thought a statement like this is an error: int a = 'ABCD'; However it is not. It is likely possible to just modify char_const regular expression in c_lexer.py:240 to allow longer characters, but the way it is done in this PR - multicharacter constants are clearly separated. I am also limiting the length of multicharacter const integers to 4 characters - this matches VS compiler behavior (gcc allows any length with a warning) and lets pycparser NOT consider lengthy single-quoted strings as integers - these would be nonsensical anyway.
* Fix issue #314: Failed parsing unnamed function parameters with array dim ↵Saullo Carvalho Castelo Branco2019-06-011-3/+4
| | | | | qualifiers (#327) Fixes #314
* Followup on #326 - simplify building up type stringEli Bendersky2019-05-091-9/+2
|
* Fix issue #324: u/l constant integer suffix (#326)Kevin2019-05-091-1/+21
|
* Fix crash when file starts with a semicolon (#310)Simon Lindholm2019-03-061-3/+2
|
* Correct Parsing of Floating Point Literals, issue #253 (#277)Robbert Harms2018-08-311-1/+11
| | | | | | * Corrects the type attribute of a constant node when parsing doubles. This sets the type attribute to either 'float', 'long double' or 'double' depending on if 'f|F', 'l|L' or '' is specified at the end of the constant definition. * Add tests for previous changes.
* Use https:// for all project links where available (#267)Jon Dufresne2018-06-261-1/+1
|
* Add support for empty struct (#66) (#254)ldore2018-04-271-8/+27
|
* Fix #235: Pragma displacing real statements (#236)dbluhm2018-03-031-10/+63
| | | | | * Fix #235: Pragma displacing real statements
* Minor cleanupsEli Bendersky2017-11-221-19/+0
| | | | | - Removed unnecessary whitespace - Removed old & stale 'if __main__' sections in some of the library files
* Add support for #pragma in struct_declaration (Issue #221). (#222)ldore2017-11-221-0/+5
|
* Add column support in c_parser (#178)serpilliere2017-03-101-56/+56
|
* Fix parsing TYPEIDs in declarators (#169)Nate Bogdanowicz2017-02-221-99/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove `init_declarator_list` workarounds * Remove `struct_declaration` workaround * Remove `declarator` pointer workaround * Add `@parameterized` decorator for parser rules * Rename `declarator` productions to `id_declarator` in preparation of adding `typeid_declarator` * Use `id_declarator` in function definitions * Add `typeid_declarator` and allow it as a `declarator` * Create separate production for `type_specifier_no_typeid` * Allow specifiers to be appended (useful for left-recursive lists) * Change `specifier_qualifier_list` to be left-recursive and require at least one `type specifier` * Change `declaration_specifiers` to require one `type_specifier` and disallow `typeid`s once we've seen a `type_specifier` * Allow `decl_body` to omit a `type_specifier` if `init_declarator` doesn't start with a TYPEID * Add `typeid_noparen_declarator` for use in `parameter_declaration`s * Add test for multi-declarator declaration using a typedef name * Move test into a more appropriate function and add another test * Expand UnaryOp in `expand_init()` * Add test for redefining name in the middle of a declaration * Added info on the `append` parameter. * Move rule template processing to a class constructor * Auto-remove template methods and remove leading underscores * Use xxx/yyy instead of XXX/YYY for better readability * Add more documentation of the templating functions * Add test for correct handling of ambiguity in parameter declarations * Don't test incremental generation of declarators yet
* Revert "Add argument to CParser.__init__ for overriding the yacc start ↵Eli Bendersky2017-02-021-7/+2
| | | | | | symbol. (#159)" This reverts commit 44137334bac69df72c6378fa84931006179d8bdf.
* Remove Copyright from every source fileEli Bendersky2017-02-021-1/+1
| | | | Replace it by website link; copyright appears in the LICENSE file already, which is sufficient
* A bit of internal cleanupEli Bendersky2017-01-311-9/+3
|
* Add argument to CParser.__init__ for overriding the yacc start symbol. (#159)Manuel Jacob2017-01-151-2/+7
| | | | | | | | * Add argument to CParser.__init__ for overriding the yacc start symbol. * Add a test for the new 'start' argument of CParser.__init__. * Add documentation for the new 'start' argument of CParser.__init__.
* Add support for the __int128 type.Manuel Jacob2017-01-121-0/+1
| | | | | This type is not part of the core C99 or C11 standards, but is mentioned in both documents under "Common extensions".
* Issue #116: Fix coord assignment to compound statementsEli Bendersky2016-10-111-0/+2
|
* Issue #116: Fix line number assignment to EmptyStatementEli Bendersky2016-10-111-1/+1
|
* Fix eliben/pycparser#87 : offsetof() support is incompleteksero2016-09-091-1/+16
|
* report filename if error is "at end of input"Julian Hammer2016-08-161-1/+1
|
* Allow user to decide which lexer the parser uses.Erik Soma2016-07-251-2/+7
|
* Fix parsing of extra semi-colons inside structure declarations.Eli Bendersky2016-03-191-1/+9
| | | | Fixes #117
* fixed #107 "No coord for Prgama Node"Julian Hammer2015-12-151-2/+2
|
* Add support for #pragmaJulian Hammer2015-10-201-2/+13
| | | | | | | | | | | | 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.
* Added taboutputdir parameter to control outputdir for tab filesShai Berger2015-06-091-3/+10
|
* Various cosmetic updates to documentationEli Bendersky2015-05-101-1/+1
|
* Adding support for empty initializer lists.Eli Bendersky2015-05-101-2/+6
| | | | The idea comes from #79 but the implementation is somewhat different.
* Adding support for offsetof()Eli Bendersky2015-05-091-0/+8
|