mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +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,
|
||||
$.not_operator,
|
||||
$.boolean_operator,
|
||||
$.await,
|
||||
$.lambda,
|
||||
$.primary_expression,
|
||||
$.conditional_expression,
|
||||
@@ -759,6 +758,7 @@ module.exports = grammar({
|
||||
),
|
||||
|
||||
primary_expression: $ => choice(
|
||||
$.await,
|
||||
$.binary_operator,
|
||||
$.identifier,
|
||||
$.keyword_identifier,
|
||||
@@ -1202,7 +1202,7 @@ module.exports = grammar({
|
||||
|
||||
await: $ => prec(PREC.unary, seq(
|
||||
'await',
|
||||
$.expression
|
||||
$.primary_expression
|
||||
)),
|
||||
|
||||
comment: $ => token(seq('#', /.*/)),
|
||||
|
||||
Reference in New Issue
Block a user