mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: Fix parsing of await inside expressions
Found when parsing `Lib/test/test_coroutines.py` using the new parser. For whatever reason, having `await` be an `expression` (with an argument of the same kind) resulted in a bad parse. Consulting the official grammar, we see that `await` should actually be a `primary_expression` instead. This is also more in line with the other unary operators, whose precedence is shared by the `await` syntax.
This commit is contained in:
@@ -751,7 +751,6 @@ module.exports = grammar({
|
|||||||
$.comparison_operator,
|
$.comparison_operator,
|
||||||
$.not_operator,
|
$.not_operator,
|
||||||
$.boolean_operator,
|
$.boolean_operator,
|
||||||
$.await,
|
|
||||||
$.lambda,
|
$.lambda,
|
||||||
$.primary_expression,
|
$.primary_expression,
|
||||||
$.conditional_expression,
|
$.conditional_expression,
|
||||||
@@ -759,6 +758,7 @@ module.exports = grammar({
|
|||||||
),
|
),
|
||||||
|
|
||||||
primary_expression: $ => choice(
|
primary_expression: $ => choice(
|
||||||
|
$.await,
|
||||||
$.binary_operator,
|
$.binary_operator,
|
||||||
$.identifier,
|
$.identifier,
|
||||||
$.keyword_identifier,
|
$.keyword_identifier,
|
||||||
@@ -1202,7 +1202,7 @@ module.exports = grammar({
|
|||||||
|
|
||||||
await: $ => prec(PREC.unary, seq(
|
await: $ => prec(PREC.unary, seq(
|
||||||
'await',
|
'await',
|
||||||
$.expression
|
$.primary_expression
|
||||||
)),
|
)),
|
||||||
|
|
||||||
comment: $ => token(seq('#', /.*/)),
|
comment: $ => token(seq('#', /.*/)),
|
||||||
|
|||||||
Reference in New Issue
Block a user