Attribute Macro rust_sitter::prec_right

source ·
#[prec_right]
Expand description

Defines a precedence level for a non-terminal that should be right-associative. For example, with cons we could have 1 :: 2 :: 3 to be parsed as 1 :: (2 :: 3), which corresponds to a right-associativity.

This annotation takes a single, unnamed parameter, which specifies the precedence level. This is used to resolve conflicts with other non-terminals, so that the one with the higher precedence will bind more tightly (appear lower in the parse tree).

Example

#[rust_sitter::prec_right(1)]
Cons(Box<Expr>, Box<Expr>)