Skip to content

Commit

Permalink
DOCS Expressions: additions
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasverraes committed Dec 1, 2020
1 parent 7861a1e commit 96a5d31
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/tutorial/20_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96a5d31

Please sign in to comment.