Skip to content

Commit

Permalink
fix: support variadic functions in .pxd declarations
Browse files Browse the repository at this point in the history
Modified _typedargslist rule to properly handle C-style variadic functions
using `...` syntax. This allows declaring functions with variable arguments
in various contexts:

- Standard library functions (printf, scanf)
- Custom variadic functions with/without regular parameters
- Variadic methods in cdef classes
- Function pointer typedefs with varargs support

Examples of now-supported syntax:
- cdef int printf(const char *format, ...)
- cdef void func(...)
- cdef int log(char *prefix, int count, ...)
- ctypedef int (*printf_t)(const char*, ...)

Added comprehensive test corpus covering various variadic function
declaration patterns.
  • Loading branch information
b0o committed Nov 1, 2024
1 parent 52c1c47 commit 4cb201e
Show file tree
Hide file tree
Showing 4 changed files with 134,571 additions and 134,221 deletions.
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ module.exports = grammar(Python, {
optional(seq(":", $.c_type)),
optional(seq("=", choice($.expression, "*"))),
)),
optional(seq(",", "...")),
optional(","),
),
),
Expand Down
21 changes: 21 additions & 0 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4cb201e

Please sign in to comment.