Documentation

Lean.Parser.Extension

Extensible parsing via attributes

inductive Lean.Parser.AliasValue (α : Type) :

Parser aliases for making ParserDescr extensible

Instances For
    @[reducible, inline]
    Equations
    Instances For
      Instances For
        Instances For
          Instances For
            Equations
            Instances For
              @[reducible, inline]
              Equations
              Instances For
                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.
                Instances For
                  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.
                  Instances For
                    def Lean.Parser.addParser (categories : ParserCategories) (catName declName : Name) (leading : Bool) (p : Parser) (prio : Nat) :
                    Equations
                    Instances For
                      Equations
                      Instances For
                        Equations
                        Instances For
                          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.
                          Instances For
                            def Lean.Parser.getAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
                            Equations
                            Instances For
                              def Lean.Parser.AliasTable.getConst {α : Type} (aliases : AliasTable α) (aliasName : Name) :
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Lean.Parser.AliasTable.getUnary {α : Type} (aliases : AliasTable α) (aliasName : Name) :
                                Except String (α → α)
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  def Lean.Parser.AliasTable.getBinary {α : Type} (aliases : AliasTable α) (aliasName : Name) :
                                  Except String (α → α → α)
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    def Lean.Parser.getConstAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
                                    IO α
                                    Equations
                                    Instances For
                                      def Lean.Parser.getUnaryAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
                                      IO (α → α)
                                      Equations
                                      Instances For
                                        def Lean.Parser.getBinaryAlias {α : Type} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) :
                                        IO (α → α → α)
                                        Equations
                                        Instances For
                                          • 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.

                                          Instances For
                                            Equations
                                            Instances For
                                              def Lean.Parser.registerAlias (aliasName declName : Name) (p : ParserAliasValue) (kind? : Option SyntaxNodeKind := none) (info : ParserAliasInfo := { }) :
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                Equations
                                                Instances For
                                                  unsafe def Lean.Parser.mkParserOfConstantUnsafe (env : Environment) (opts : Options) (constName : Name) (compileParserDescr : ParserDescr → Except String Parser) :
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    @[implemented_by Lean.Parser.mkParserOfConstantUnsafe]
                                                    opaque Lean.Parser.mkParserOfConstantAux (env : Environment) (opts : Options) (constName : Name) (compileParserDescr : ParserDescr → Except String Parser) :

                                                    Compiles d, evaluating the parser declarations it refers to in env and resolving parser aliases in aliases.

                                                    Equations
                                                    Instances For
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        def Lean.Parser.mkParserOfConstantCore (env : Environment) (opts : Options) (aliases : AliasTable Parser) (categories : ParserCategories) (constName : Name) :

                                                        Evaluates the parser declaration constName in env, returning whether it is a leading parser.

                                                        Equations
                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            • postAdd (catName declName : Name) (builtin : Bool) : AttrM Unit

                                                              Called after a parser attribute is applied to a declaration.

                                                            Instances For
                                                              def Lean.Parser.runParserAttributeHooks (catName declName : Name) (builtin : Bool) :
                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                Equations
                                                                Instances For

                                                                  Returns the names of the parser categories containing a parser for the syntax node kind kind.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For
                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def Lean.Parser.evalParserConst (declName : Name) (evalFallback? : Option ParserFn := none) :
                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For

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

                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For
                                                                            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.
                                                                            Instances For
                                                                              def Lean.Parser.addBuiltinLeadingParser (catName declName : Name) (p : Parser) (prio : Nat) :
                                                                              Equations
                                                                              Instances For
                                                                                def Lean.Parser.addBuiltinTrailingParser (catName declName : Name) (p : TrailingParser) (prio : Nat) :
                                                                                Equations
                                                                                Instances For
                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For
                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For
                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For
                                                                                          def Lean.Parser.mkInputContext (input fileName : String) (normalizeLineEndings : Bool := true) (endPos : String.Pos.Raw := input.rawEndPos) (endPos_valid : endPos ≤ input.rawEndPos := by simp) :
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            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.
                                                                                            Instances For
                                                                                              def Lean.Parser.declareBuiltinParser (addFnName catName declName : Name) (prio : Nat) :
                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                def Lean.Parser.declareLeadingBuiltinParser (catName declName : Name) (prio : Nat) :
                                                                                                Equations
                                                                                                Instances For
                                                                                                  def Lean.Parser.declareTrailingBuiltinParser (catName declName : Name) (prio : Nat) :
                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      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
                                                                                                      Instances For
                                                                                                        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.
                                                                                                        Instances For
                                                                                                          def Lean.Parser.registerBuiltinDynamicParserAttribute (attrName catName : Name) (ref : Name := by exact decl_name%) :

                                                                                                          A builtin parser attribute that can be extended by users.

                                                                                                          Equations
                                                                                                          Instances For
                                                                                                            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.
                                                                                                            Instances For
                                                                                                              @[inline]
                                                                                                              Equations
                                                                                                              Instances For
                                                                                                                Equations
                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                Instances For

                                                                                                                  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.
                                                                                                                  Instances For

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

                                                                                                                    Equations
                                                                                                                    Instances For

                                                                                                                      If the parsing stack's last element is a set_option command, then its value is set in the context while parsing p.

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

                                                                                                                        If the parsing stack ends with an the option name and value, then the option is set in the context while parsing p. The value is the top of the stack and the name is the identifier two entries below it.

                                                                                                                        Equations
                                                                                                                        Instances For

                                                                                                                          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).

                                                                                                                          Instances For

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

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

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

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