From 0eb44f044b6a4f051126e2e46fd8840dcb105ae9 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sat, 7 May 2022 11:23:43 +0900 Subject: Make #prec directive change only precedence and not associativity --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index f73d2a6..b7f6206 100644 --- a/README.md +++ b/README.md @@ -384,7 +384,7 @@ Labels are intended to identify elements in directives. An AST doesn't contain l #### `#prec ` -A `#prec` directive gives alternatives the same precedence and associativety as `symbol`. To be precise, precedence and associativity are given to the right-most symbol in an alternative, not to an alternative. +A `#prec` directive gives alternatives the same precedence as `symbol`. See [Operator precedence and associativity](#operator-precedence-and-associativity) section for more details on the `#prec` directive. @@ -499,7 +499,9 @@ foobar `%left` and `%right` allow you to define precedence and associativiry of symbols. `%left`/`%right` each assign the left/right associativity to symbols. -`#prec` directive assigns the same precedence and associativity as a specified symbol to an alternative. +When the right-most terminal symbol of an alternative has precedence or associativity defined explicitly, the alternative inherits its precedence and associativity. + +`#prec` directive assigns the same precedence as a specified symbol to an alternative. The grammar for simple four arithmetic operations and assignment expression can be defined as follows: -- cgit v1.2.3