From 96a5d31a62703f826455316fa518bbf8c96a0d47 Mon Sep 17 00:00:00 2001 From: Mathias Verraes Date: Tue, 1 Dec 2020 12:23:56 +0100 Subject: [PATCH] DOCS Expressions: additions --- docs/tutorial/20_expressions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/tutorial/20_expressions.md b/docs/tutorial/20_expressions.md index f384a18..0efdb27 100644 --- a/docs/tutorial/20_expressions.md +++ b/docs/tutorial/20_expressions.md @@ -122,6 +122,12 @@ assertSame(-4, $result->output()); You can play around with the precedence and the associativity to see how it impacts the result. As an exercise, make a parser that solves `1 - 2 - 3 = (1 - (2 - 3) = (1 - (-1)) = 2`. +## Non-associative operators + +Non-associative means that an expression like `1 + 2 + 3` cannot be resolved, because there is no way to decide whether it's associates left `(1 + 2) + 3` or right `1 + (2 + 3)`. The parser will simply fail. Of course, for addition, non-associativity wouldn't make sense, but for other languages or operators it might. + +## Unary operators + You can add unary operators, such as the negation prefix operator `-`, and the increment and decrement postfix operators `++` and `--`. ```php