Documentation

Lean.Parser.Types

@[reducible, inline]
abbrev Lean.Parser.mkAtom (info : SourceInfo) (val : String) :
Equations
    Instances For
      @[reducible, inline]
      abbrev Lean.Parser.mkIdent (info : SourceInfo) (rawVal : Substring) (val : Name) :
      Equations
        Instances For
          def Lean.Parser.getNext (input : String) (pos : String.Pos) :

          Return character after position pos

          Equations
            Instances For

              Maximal (and function application) precedence. In the standard lean language, no parser has precedence higher than maxPrec.

              Note that nothing prevents users from using a higher precedence, but we strongly discourage them from doing it.

              Equations
                Instances For
                  Equations
                    Instances For
                      Equations
                        Instances For
                          Equations
                            Instances For
                              @[reducible, inline]
                              Equations
                                Instances For
                                  @[reducible, inline]
                                  Equations
                                    Instances For
                                      @[reducible, inline]
                                      Equations
                                        Instances For

                                          Input string and related data. Recall that the FileMap is a helper structure for mapping String.Pos in the input string to line/column information.

                                          Instances For

                                            Input context derived from elaboration of previous commands.

                                            Instances For

                                              Parser context parts that can be updated without invalidating the parser cache.

                                              Instances For
                                                Instances For
                                                  Equations
                                                    Instances For
                                                      Equations
                                                        Instances For
                                                          Instances For
                                                            Instances For
                                                              Equations
                                                                Instances For

                                                                  A syntax array with an inaccessible prefix, used for sound caching.

                                                                  Instances For
                                                                    Equations
                                                                      Instances For
                                                                        Equations
                                                                          Instances For
                                                                            Equations
                                                                              Instances For
                                                                                Equations
                                                                                  Instances For
                                                                                    Equations
                                                                                      Instances For
                                                                                        Equations
                                                                                          Instances For
                                                                                            Equations
                                                                                              Instances For
                                                                                                Equations
                                                                                                  Instances For
                                                                                                    • stxStack : SyntaxStack
                                                                                                    • lhsPrec : Nat

                                                                                                      Set to the precedence of the preceding (not surrounding) parser by runLongestMatchParser for the use of checkLhsPrec in trailing parsers. Note that with chaining, the preceding parser can be another trailing parser: in 1 * 2 + 3, the preceding parser is '*' when '+' is executed.

                                                                                                    • cache : ParserCache
                                                                                                    • errorMsg : Option Error
                                                                                                    • recoveredErrors : Array (String.Pos × SyntaxStack × Error)
                                                                                                    Instances For
                                                                                                      @[inline]
                                                                                                      Equations
                                                                                                        Instances For
                                                                                                          Equations
                                                                                                            Instances For
                                                                                                              Equations
                                                                                                                Instances For
                                                                                                                  Equations
                                                                                                                    Instances For
                                                                                                                      Equations
                                                                                                                        Instances For
                                                                                                                          Equations
                                                                                                                            Instances For
                                                                                                                              Equations
                                                                                                                                Instances For
                                                                                                                                  @[inline]
                                                                                                                                  Equations
                                                                                                                                    Instances For
                                                                                                                                      Equations
                                                                                                                                        Instances For
                                                                                                                                          def Lean.Parser.ParserState.mkUnexpectedError (s : ParserState) (msg : String) (expected : List String := []) (pushMissing : Bool := true) :
                                                                                                                                          Equations
                                                                                                                                            Instances For
                                                                                                                                              Equations
                                                                                                                                                Instances For
                                                                                                                                                  Equations
                                                                                                                                                    Instances For
                                                                                                                                                      Equations
                                                                                                                                                        Instances For

                                                                                                                                                          Reports given 'expected' messages at range of top stack element (assumed to be a single token). Replaces the element with missing and resets position to the token position. iniPos can be specified to avoid this position lookup but still must be identical to the token position.

                                                                                                                                                          Equations
                                                                                                                                                            Instances For

                                                                                                                                                              Reports given 'expected' message at range of top stack element (assumed to be a single token). Replaces the element with missing and resets position to the token position. iniPos can be specified to avoid this position lookup but still must be identical to the token position.

                                                                                                                                                              Equations
                                                                                                                                                                Instances For
                                                                                                                                                                  Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      Instances For
                                                                                                                                                                        Instances For
                                                                                                                                                                          Instances For
                                                                                                                                                                            @[reducible, inline]
                                                                                                                                                                            Equations
                                                                                                                                                                              Instances For
                                                                                                                                                                                @[inline]

                                                                                                                                                                                Create a simple parser combinator that inherits the info of the nested parser.

                                                                                                                                                                                Equations
                                                                                                                                                                                  Instances For

                                                                                                                                                                                    Run p with a fresh cache, restore outer cache afterwards. p may access the entire syntax stack.

                                                                                                                                                                                    Equations
                                                                                                                                                                                      Instances For

                                                                                                                                                                                        Run p with a fresh cache, restore outer cache afterwards. p may access the entire syntax stack.

                                                                                                                                                                                        Equations
                                                                                                                                                                                          Instances For

                                                                                                                                                                                            Run p under the given context transformation with a fresh cache (see also withResetCacheFn).

                                                                                                                                                                                            Equations
                                                                                                                                                                                              Instances For
                                                                                                                                                                                                def Lean.Parser.withCacheFn (parserName : Name) (p : ParserFn) :

                                                                                                                                                                                                Run p and record result in parser cache for any further invocation with this parserName, parser context, and parser state. p cannot access syntax stack elements pushed before the invocation in order to make caching independent of parser history. As this excludes trailing parsers from being cached, we also reset lhsPrec, which is not read but set by leading parsers, to 0 in order to increase cache hits. Finally, errorMsg is also reset to none as a leading parser should not be called in the first place if there was an error.

                                                                                                                                                                                                Equations
                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    def Lean.Parser.withCache (parserName : Name) :

                                                                                                                                                                                                    Run p and record result in parser cache for any further invocation with this parserName, parser context, and parser state. p cannot access syntax stack elements pushed before the invocation in order to make caching independent of parser history. As this excludes trailing parsers from being cached, we also reset lhsPrec, which is not read but set by leading parsers, to 0 in order to increase cache hits. Finally, errorMsg is also reset to none as a leading parser should not be called in the first place if there was an error.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        Equations
                                                                                                                                                                                                          Instances For