Skip to content

Commit c09ef05

Browse files
committed
[Syntax] Add 'UnresolvedTernaryExpr'
that resembles `IfExpr` before folding in AST parsing.
1 parent 5bfef4f commit c09ef05

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

utils/gyb_syntax_support/ExprNodes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,21 @@
311311
])
312312
]),
313313

314+
# ? expr :
315+
# Ternary expression without the condition and the second choice.
316+
# NOTE: This appears only in SequenceExpr.
317+
Node('UnresolvedTernaryExpr', kind='Expr',
318+
children=[
319+
Child("QuestionMark", kind='InfixQuestionMarkToken'),
320+
Child("FirstChoice", kind='Expr'),
321+
Child("ColonMark", kind='ColonToken'),
322+
]),
323+
324+
314325
# a ? 1 : 0
326+
# NOTE: This won't come directly out of the parser. Rather, it is the
327+
# result of "folding" a SequenceExpr based on knowing the precedence
328+
# relationships amongst the different infix operators.
315329
Node('TernaryExpr', kind='Expr',
316330
children=[
317331
Child("ConditionExpression", kind='Expr'),

utils/gyb_syntax_support/NodeSerializationCodes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@
271271
'LabeledStmt': 267,
272272
'InfixOperatorExpr': 268,
273273
'MoveExpr': 269,
274+
'UnresolvedTernaryExpr': 270,
274275
}
275276

276277

0 commit comments

Comments
 (0)