Skip to content
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

Fix parsing of typed metavariable patterns for C# #513

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lang/semgrep-grammars/src/semgrep-c-sharp-pro/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ module.exports = grammar(standard_grammar, {

// use syntax similar to a cast_expression, but with metavar
//TODO: use PREC.CAST from original grammar instead of 17 below
typed_metavariable: $ => prec.right(17, seq(
typed_metavariable: $ => prec(17, prec.dynamic(1, seq(
'(',
field('type', $.type),
field('metavar', $._semgrep_metavariable),
')',
)),
))),

deep_ellipsis: $ => seq(
'<...', $.expression, '...>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ __SEMGREP_EXPRESSION
(identifier))
(argument_list))))

================================================================================
Parametrized typed metavariable
================================================================================

__SEMGREP_EXPRESSION (A<B> $X)

--------------------------------------------------------------------------------

(compilation_unit
(semgrep_expression
(typed_metavariable
(generic_name
(identifier)
(type_argument_list
(identifier))))))

================================================================================
Ellipses + metavariables as args
================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ __SEMGREP_EXPRESSION
(identifier))
(argument_list))))

================================================================================
Parametrized typed metavariable
================================================================================

__SEMGREP_EXPRESSION (A<B> $X)

--------------------------------------------------------------------------------

(compilation_unit
(semgrep_expression
(typed_metavariable
(generic_name
(identifier)
(type_argument_list
(identifier))))))

================================================================================
Ellipses + metavariables as args
================================================================================
Expand Down
Loading