Documentation

Lean.Parser.Extension

Extensible parsing via attributes

Instances For
Instances For
Equations
@[reducible, inline]
Equations
def Lean.Parser.addLeadingParser (categories : ParserCategories) (catName declName : Name) (p : Parser) (prio : Nat) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.addTrailingParser (categories : ParserCategories) (catName declName : Name) (p : TrailingParser) (prio : Nat) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.addParser (categories : ParserCategories) (catName declName : Name) (leading : Bool) (p : Parser) (prio : Nat) :
Equations
Equations
inductive Lean.Parser.AliasValue (α : Type) :

Parser aliases for making ParserDescr extensible

def Lean.Parser.registerAliasCore {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) (value : AliasValue α) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.getAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
Equations
def Lean.Parser.getConstAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
IO α
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.getUnaryAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
IO (αα)
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.getBinaryAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
IO (ααα)
Equations
  • One or more equations did not get rendered due to their size.
  • declName : Name
  • stackSz? : Option Nat

    Number of syntax nodes produced by this parser. none means "sum of input sizes".

  • autoGroupArgs : Bool

    Whether arguments should be wrapped in group(·) if they do not produce exactly one syntax node.

Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.registerAlias (aliasName declName : Name) (p : ParserAliasValue) (kind? : Option SyntaxNodeKind := none) (info : ParserAliasInfo := { declName := Name.anonymous, stackSz? := some 1, autoGroupArgs := (some 1).isSome }) :
Equations
  • One or more equations did not get rendered due to their size.
Equations
unsafe def Lean.Parser.mkParserOfConstantUnsafe (constName : Name) (compileParserDescr : ParserDescrImportM Parser) :
Equations
  • One or more equations did not get rendered due to their size.
@[implemented_by Lean.Parser.mkParserOfConstantUnsafe]
opaque Lean.Parser.mkParserOfConstantAux (constName : Name) (compileParserDescr : ParserDescrImportM Parser) :
  • postAdd (catName declName : Name) (builtin : Bool) : AttrM Unit

    Called after a parser attribute is applied to a declaration.

def Lean.Parser.runParserAttributeHooks (catName declName : Name) (builtin : Bool) :
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
@[implemented_by Lean.Parser.evalParserConstUnsafe]

Run declName if possible and inside a quotation, or else p. The ParserInfo will always be taken from p.

Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.addBuiltinParser (catName declName : Name) (leading : Bool) (p : Parser) (prio : Nat) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.addBuiltinLeadingParser (catName declName : Name) (p : Parser) (prio : Nat) :
Equations
def Lean.Parser.addBuiltinTrailingParser (catName declName : Name) (p : TrailingParser) (prio : Nat) :
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.mkInputContext (input fileName : String) (normalizeLineEndings : Bool := true) :
Equations
  • One or more equations did not get rendered due to their size.
Equations
def Lean.Parser.runParserCategory (env : Environment) (catName : Name) (input : String) (fileName : String := "<input>") :

convenience function for testing

Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.declareBuiltinParser (addFnName catName declName : Name) (prio : Nat) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.declareLeadingBuiltinParser (catName declName : Name) (prio : Nat) :
Equations
def Lean.Parser.declareTrailingBuiltinParser (catName declName : Name) (prio : Nat) :
Equations
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.registerBuiltinParserAttribute (attrName declName : Name) (behavior : LeadingIdentBehavior := LeadingIdentBehavior.default) (ref : Name := by exact decl_name%) :

The parsing tables for builtin parsers are "stored" in the extracted source code.

Equations
def Lean.Parser.mkParserAttributeImpl (attrName catName : Name) (ref : Name := by exact decl_name%) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.registerBuiltinDynamicParserAttribute (attrName catName : Name) (ref : Name := by exact decl_name%) :

A builtin parser attribute that can be extended by users.

Equations
def Lean.Parser.registerParserCategory (env : Environment) (attrName catName : Name) (behavior : LeadingIdentBehavior := LeadingIdentBehavior.default) (ref : Name := by exact decl_name%) :
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.

If the parsing stack is of the form #[.., openCommand], we process the open command, and execute p

Equations
  • One or more equations did not get rendered due to their size.

If the parsing stack is of the form #[.., openDecl], we process the open declaration, and execute p

Equations

Helper environment extension that gives us access to built-in aliases in pure parser functions.

Result of resolving a parser name.

  • category (cat : Name) : ParserResolution

    Reference to a category.

  • parser (decl : Name) (isDescr : Bool) : ParserResolution

    Reference to a parser declaration in the environment. A (Trailing)ParserDescr if isDescr is true.

  • alias (p : ParserAliasValue) : ParserResolution

    Reference to a parser alias. Note that as aliases are built-in, a corresponding declaration may not be in the environment (yet).

def Lean.Parser.resolveParserNameCore (env : Environment) (currNamespace : Name) (openDecls : List OpenDecl) (ident : Ident) :

Resolve the given parser name and return a list of candidates.

Equations
Equations
  • One or more equations did not get rendered due to their size.

Resolve the given parser name and return a list of candidates.

Equations

Resolve the given parser name and return a list of candidates.

Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Parser.parserOfStack (offset : Nat) (prec : Nat := 0) :
Equations
  • One or more equations did not get rendered due to their size.