summaryrefslogtreecommitdiff
path: root/pycparser/c_lexer.py
Commit message (Collapse)AuthorAgeFilesLines
* Feature/add pragma support (#487)Jordy Ruiz2023-01-081-0/+1
| | | | | | | | | * 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 typos (#443)Kian Meng Ang2021-10-181-2/+2
| | | | | * Fix typos * Revert changes in vendor module
* Fix Flake8 Errors (#442)Eisuke Kawashima2021-10-151-1/+0
| | | | | | | | | * 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 u8, u, and U strings from C11 (#439)Vitaly Cheptsov2021-10-051-0/+36
| | | | | | | * 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-1/+2
| | | | | | | | | | | | | | | * 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>
* Support _Atomic as a qualifierEli Bendersky2021-09-131-2/+2
| | | | | | | 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-7/+11
| | | | | | | | | | * 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>
* Recognize integer multicharacter constants like 'ABCD' (#350)yaroslav-o2019-09-251-1/+6
| | | | | | | | | | | | | 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 slow backtracking when parsing strings (no external deps) (#347)Tyson Andre2019-08-261-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix slow backtracking when parsing strings (no external deps) Fixes #61 This uses negative lookaheads to avoid ambiguity in how string should be parsed by the regex. - https://docs.python.org/2/library/re.html#regular-expression-syntax - Previously, if it didn't immediately succeed at parsing an escape sequence such as `\123`, it would have to try `\1`+`23`, `\12` + `3`, and `\123`, which multiplied the time taken by 3 per additional escape sequence. This solves that by only allowing `\123` - The same fix was added for hex escapes. Also fix a test that relied on the incorrect handling of regexes. The implementation documentation says that it intends to allow **decimal** escapes permissively. * WIP debug * Fix ambiguity caused by allowing #path directives Solve this by allowing "\x" when not followed by hex, in the regular string literal. In the previous commits, `\x12` could be parsed both as `\x`+`12` and `\x12`, which caused exponential options for backtracking. * Document changes to lexer, remove debug code * Optimize this for strings
* Use https:// for all project links where available (#267)Jon Dufresne2018-06-261-1/+1
|
* Minor cleanupsEli Bendersky2017-11-221-1/+0
| | | | | - Removed unnecessary whitespace - Removed old & stale 'if __main__' sections in some of the library files
* Python 3.6 invalid escape sequence deprecation fixes (#177)Ville Skyttä2017-03-041-2/+2
| | | https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
* 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
* Add support for the __int128 type.Manuel Jacob2017-01-121-1/+1
| | | | | This type is not part of the core C99 or C11 standards, but is mentioned in both documents under "Common extensions".
* Improve the behavior of pathological bad string literals a bit.Eli Bendersky2016-10-101-1/+1
| | | | | By making the first * non-greedy, performance is ~10-15% better; it still demonstrates pahological backtracking slowness (issue #61).
* Adding test for exercising issue #61Eli Bendersky2016-10-101-1/+1
| | | | | The test shows that on a simple lexer level the issue doesn't manifest. It does, however, manifest if parsing a file.
* Add support for #pragmaJulian Hammer2015-10-201-9/+9
| | | | | | | | | | | | 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.
* Various cosmetic updates to documentationEli Bendersky2015-05-101-1/+1
|
* Adding support for offsetof()Eli Bendersky2015-05-091-1/+2
|
* Allow binary constants (e.g.: 0b01010)Konstanty Bialkowski2015-04-201-1/+8
| | | - Add lexer and parser tests.
* Fix #33 pragma error when '=' occurs.wvi2014-09-091-1/+1
| | | | '=' added to pppragma_ignore.
* Remember last_token in the lexer, instead of using tokenfuncEli Bendersky2013-07-131-2/+5
|
* Cosmetic changes & commentsEli Bendersky2013-07-131-3/+3
|
* Cosmetic cleanupsEli Bendersky2013-07-131-6/+5
|
* Support typedef names redeclared to identifiers in inner scopesSye van der Veen2013-07-111-6/+32
|
* Some cleanupsEli Bendersky2013-06-121-82/+50
|
* Merge pull request #4 from Syeberman/dollar-in-identifierEli Bendersky2013-06-121-2/+2
|\ | | | | Dollar signs in identifiers
| * Dollar signs in identifiers; non-standard, but supported by many compilersSye van der Veen2013-06-101-2/+2
| |
* | Fixed handling of some integer suffix corner casesSye van der Veen2013-06-101-1/+1
|/
* Issue #86: fix token column computationEli Bendersky2012-12-251-5/+2
|
* Googlecode issue #87: improve error reporting for parse errors to containEli Bendersky2012-12-251-8/+10
| | | | columns.
* Added ply 3.4 to be redistributed with pycparser. This aids withEli Bendersky2012-12-241-3/+3
| | | | distribution and with tests.
* Fixes for issue 74: pass decimal escapes \<num> in the lexereliben2012-08-101-2/+5
|
* Issue 73: initial pragma implementationEli Bendersky2012-08-101-9/+34
|
* Make sure the parser remembers the coordinates of simple string typesEli Bendersky2012-07-061-3/+0
| | | | | | | | (such as 'int' or typedef_name) by always keeping them in an IdentifierType node. This allows to correctly report some errors, which fixes issue 60. Also cleanup some whitespace & formatting issues, and replace deprecated unittest methods for python3.
* Issue 57: support for C99 hexadecimal float constantsEli Bendersky2012-06-151-5/+13
|
* Support for C99 _Complex type. Patch by Andreas KloecknerEli Bendersky2012-01-191-2/+4
|
* Fix for issue 50, added support for more windows chars in #line path.Even2011-11-061-3/+3
|
* Issue 49: Allow dots ('.') in string escapes for the sake of #line ↵eli.bendersky2011-10-311-4/+4
| | | | | | directives with Windows paths like "..\..\test" + added tests
* - cosmetic fixes for the _Bool patcheli.bendersky2011-09-241-6/+5
| | | | - adding tests for _Bool & stdbool
* Added support for C99 _Bool type.Even2011-09-181-3/+7
| | | | | Also added stdbool.h to fake_libc_includes, and its defines and typedefs to _fake_defines.h and _fake_typedefs.h.
* changed license notices to BSD in all fileseli.bendersky2011-04-291-1/+1
|
* Removed portability.py, using from __future__ import print_function instead. ↵eli.bendersky2011-02-181-3/+2
| | | | This means only Python 2.6 and later is supported in 2.x
* Implemented 'long long' type support for C99eli.bendersky2010-10-301-1/+1
|
* Implemented declarations in first expr of a For loop, for C99eli.bendersky2010-10-291-2/+2
|
* initial import from SVNEli Bendersky2010-05-211-0/+445