You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 5, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: Manual/NotationsMacros/Precedence.lean
+41-3Lines changed: 41 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,23 +19,41 @@ set_option pp.rawOnError true
19
19
20
20
set_option linter.unusedVariables false
21
21
22
+
/-
22
23
#doc (Manual) "Precedence" =>
24
+
-/
25
+
#doc (Manual) "優先順位(Precedence)" =>
23
26
%%%
24
27
tag := "precedence"
25
28
%%%
26
29
27
-
Infix operators, notations, and other syntactic extensions to Lean make use of explicit {tech}[優先順位]precedence annotations.
30
+
:::comment
31
+
Infix operators, notations, and other syntactic extensions to Lean make use of explicit {tech}[precedence] annotations.
28
32
While precedences in Lean can technically be any natural number, by convention they range from {evalPrec}`min` to {evalPrec}`max`, respectively denoted `min` and `max`.{TODO}[Fix the keywordOf operator and use it here]
Most operator precedences consist of explicit numbers.
33
42
The named precedence levels denote the outer edges of the range, close to the minimum or maximum, and are typically used by more involved syntax extensions.
Precedences may also be denoted as sums or differences of precedences; these are typically used to assign precedences that are relative to one of the named precedences.
The maximum precedence is used to parse terms that occur in a function position.
50
69
Operators should typically not use use this level, because it can interfere with users' expectation that function application binds more tightly than any other operator, but it is useful in more involved syntax extensions to indicate how other constructs interact with function application.
Argument precedence is one less than the maximum precedence.
56
80
This level is useful for defining syntax that should be treated as an argument to a function, such as {keywordOf Lean.Parser.Term.fun}`fun` or {keywordOf Lean.Parser.Term.do}`do`.
Lead precedence is less that argument precedence, and should be used for custom syntax that should not occur as a function argument, such as {keywordOf Lean.Parser.Term.let}`let`.
0 commit comments