[ABNF] Improve the grammar for operator calls.

Introduce the notion of postfix expression in the grammar, which will also go
well with some expected upcoming extensions to Leo.

This does not change the Leo language. It does not necessarily involve modifying
the parser. It merely reorganizes some rules slightly.
This commit is contained in:
Alessandro Coglio 2022-06-18 15:45:33 -07:00
parent 846c976c63
commit 5539ce11a6

View File

@ -233,20 +233,22 @@ primary-expression = identifier
/ literal
/ "(" expression ")"
/ function-call
/ operator-call
function-call = identifier function-arguments
operator-call = unary-operator-call / binary-operator-call
unary-operator-call = primary-expression "." identifier "(" ")"
binary-operator-call =
primary-expression "." identifier "(" expression [ "," ] ")"
function-arguments = "(" [ expression *( "," expression ) [ "," ] ] ")"
unary-expression = primary-expression
postfix-expression = primary-expression
/ operator-call
operator-call = unary-operator-call / binary-operator-call
unary-operator-call = postfix-expression "." identifier "(" ")"
binary-operator-call =
postfix-expression "." identifier "(" expression [ "," ] ")"
unary-expression = postfix-expression
/ "!" unary-expression
/ "-" unary-expression