diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-07 11:23:43 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-10 23:14:41 +0900 |
commit | 0eb44f044b6a4f051126e2e46fd8840dcb105ae9 (patch) | |
tree | 187217bcf636830a4746e4fc80ac8282d72ddd12 /README.md | |
parent | Add --json option to vartan-parse command (diff) | |
download | cotia-0eb44f044b6a4f051126e2e46fd8840dcb105ae9.tar.gz cotia-0eb44f044b6a4f051126e2e46fd8840dcb105ae9.tar.xz |
Make #prec directive change only precedence and not associativity
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -384,7 +384,7 @@ Labels are intended to identify elements in directives. An AST doesn't contain l #### `#prec <symbol: Identifier>` -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: |