Skip to content

Commit

Permalink
Merge pull request #5 from chrhansk/feature-function-arguments
Browse files Browse the repository at this point in the history
Add support for functions with C function pointer arguments
  • Loading branch information
b0o authored Nov 15, 2024
2 parents ef535ad + 883d7f3 commit 119588a
Show file tree
Hide file tree
Showing 5 changed files with 146,197 additions and 146,031 deletions.
20 changes: 14 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,23 @@ module.exports = grammar(Python, {
),

c_parameters: $ => seq("(", optional($._typedargslist), ")"),

// e.g. int (*)(const char, int)
c_function_argument_type: $ =>
seq($.c_type, "(", "*", ")", $.c_parameters),

_typedargument: $ =>
seq(
$.maybe_typed_name,
optional(seq(":", $.c_type)),
optional(seq("=", choice($.expression, "*"))),
),

_typedargslist: $ =>
choice(
"...",
seq(
commaSep1(seq(
$.maybe_typed_name,
optional(seq(":", $.c_type)),
optional(seq("=", choice($.expression, "*"))),
)),
commaSep1(choice($._typedargument, $.c_function_argument_type)),
optional(seq(",", "...")),
optional(","),
),
Expand Down Expand Up @@ -686,7 +694,7 @@ module.exports = grammar(Python, {
seq(
"sizeof",
"(",
choice($.c_type, $.expression),
choice($.c_function_argument_type, $.c_type, $.expression),
")",
),
),
Expand Down
199 changes: 97 additions & 102 deletions src/grammar.json

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

27 changes: 27 additions & 0 deletions src/node-types.json

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

Loading

0 comments on commit 119588a

Please sign in to comment.