Documentation

Lean.Parser.Syntax

@[inline]
Instances For
    @[inline]
    Instances For

      Parses the literal symbol.

      The symbol is automatically included in the set of reserved tokens ("keywords"). Keywords cannot be used as identifiers, unless the identifier is otherwise escaped. For example, "fun" reserves fun as a keyword; to refer an identifier named fun one can write «fun». Adding a & prefix prevents it from being reserved, for example &"true".

      Whitespace before or after the atom is used as a pretty printing hint. For example, " + " parses + and pretty prints it with whitespace on both sides. The whitespace has no effect on parsing behavior.

      Instances For

        Parses a literal symbol. The & prefix prevents it from being included in the set of reserved tokens ("keywords"). This means that the symbol can still be recognized as an identifier by other parsers.

        Some syntax categories, such as tactic, automatically apply & to the first symbol.

        Whitespace before or after the atom is used as a pretty printing hint. For example, " + " parses + and pretty prints it with whitespace on both sides. The whitespace has no effect on parsing behavior.

        (Not exposed by parser description syntax: If the includeIdent argument is true, lets ident be reinterpreted as atom if it matches.)

        Instances For
          • unicode("→", "->") parses a symbol matching either or ->. Each symbol is reserved. The second symbol is an ASCII version of the first. The pp.unicode option controls which is used when pretty printing.
          • unicode("→", "->", preserveForPP) is the same except for pretty printing behavior. When the pp.unicode option is enabled, then the pretty printer uses whichever symbol matches the underlying atom in the syntax. The intent is that preserveForPP means that the ASCII variant is preferred. For example, fun notation uses preserveForPP for its arrow; the delaborator chooses or => depending on the value of pp.unicode.fun, letting users opt-in to formatting with . Note that notation creates a pretty printer preferring the ASCII version.
          Instances For

            prefix:prec "op" => f is equivalent to notation:prec "op" x:prec => f x.

            Instances For

              infix:prec "op" => f is equivalent to notation:prec x:prec1 "op" y:prec1 => f x y, where prec1 := prec + 1.

              Instances For

                infixl:prec "op" => f is equivalent to notation:prec x:prec "op" y:prec1 => f x y, where prec1 := prec + 1.

                Instances For

                  infixr:prec "op" => f is equivalent to notation:prec x:prec1 "op" y:prec => f x y, where prec1 := prec + 1.

                  Instances For

                    postfix:prec "op" => f is equivalent to notation:prec x:prec "op" => f x.

                    Instances For

                      Declares a binder predicate. For example:

                      binder_predicate x " > " y:term => `($x > $y)
                      
                      Instances For