cast-expression in abnf

This commit is contained in:
gluax 2021-03-24 13:38:45 -04:00
parent f71d77762c
commit 5ae7771050

View File

@ -855,14 +855,19 @@ unary-expression = primary-expression
/ "!" unary-expression
/ "-" unary-expression
; Next in the operator precedence is casting.
; The current rule below makes exponentiation left-associative,
cast-expression = unary-expression
/ cast-expression %s"as" type
; Next in the operator precedence is exponentiation,
; following mathematical practice.
; The current rule below makes exponentiation left-associative,
; i.e. 'a ** b ** c' must be parsed as '(a ** b) ** c'.
; This is easy to change if we want it to be right-associative instead.
exponential-expression = unary-expression
/ exponential-expression "**" unary-expression
exponential-expression = cast-expression
/ exponential-expression "**" cast-expression
; Next in precedence come multiplication and division, both left-associative.
@ -902,17 +907,13 @@ conjunctive-expression = equality-expression
disjunctive-expression = conjunctive-expression
/ disjunctive-expression "||" conjunctive-expression
; Next come conditional expressions.
; Finally we have conditional expressions.
conditional-expression = disjunctive-expression
/ conditional-expression
"?" expression
":" conditional-expression
; Need to decide on operator precedence for as.
cast-expression = conditional-expression
/ cast-expression %s"as" type
; These are all the expressions.
; Recall that conditional expressions
; may be disjunctive expressions,