Documentation

StrataDDM.Parser

Create an input context from a string.

Equations
Instances For

    The characters an identifier may begin with. With strataIsIdRest, this is the alphabet the lexer accepts unquoted.

    Equations
    Instances For

      The characters an identifier may continue with. Wider than strataIsIdFirst, and note it admits ', so a primed name such as x' lexes bare.

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

                            Parses a token and asserts the result is of the given kind. desc is used in error messages as the token 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
                                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 StrataDDM.Parser.longestMatchFnAux (left? : Option Lean.Syntax) (startSize startLhsPrec : Nat) (startPos : String.Pos.Raw) (prevPrio : Nat) (ps : List (Parser × Nat)) :
                                          Equations
                                          Instances For
                                            Equations
                                            Instances For
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For

                                                Implements a variant of Pratt's algorithm. In Pratt's algorithms tokens have a right and left binding power. In our implementation, parsers have precedence instead. This method selects a parser (or more, via longestMatchFn) from leadingTable based on the current token. Note that the unindexed leadingParsers parsers are also tried. We have the unidexed leadingParsers because some parsers do not have a "first token". Example:

                                                syntax term:51 "≤" ident "<" term "|" term : index
                                                

                                                Example, in principle, the set of first tokens for this parser is any token that can start a term, but this set is always changing. Thus, this parsing rule is stored as an unindexed leading parser at leadingParsers. After processing the leading parser, we chain with parsers from trailingTable/trailingParsers that have precedence at least c.prec where c is the ParsingContext. Recall that c.prec is set by categoryParser.

                                                Note that in the original Pratt's algorithm, precedences are only checked before calling trailing parsers. In our implementation, leading and trailing parsers check the precedence. We claim our algorithm is more flexible, modular and easier to understand.

                                                antiquotParser should be a mkAntiquot parser (or always fail) and is tried before all other parsers. It should not be added to the regular leading parsers because it would heavily overlap with antiquotation parsers nested inside them.

                                                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

                                                    Describes the atoms in a pattern to identify left-recusive syntax.

                                                    • isLeading (atoms : List SyntaxDefAtom) : LhsRec

                                                      This atom is not left-recursive and uses the seq atoms.

                                                    • isTrailing (minArgPrec : Nat) (remaining : List SyntaxDefAtom) : LhsRec

                                                      This atom is left-recursive The initial argument must have precedence ≥ prec. The remaining syntax is given.

                                                    • invalid (message : StrataFormat) : LhsRec

                                                      Classification failed with message

                                                    Instances For

                                                      Information about a parser.

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

                                                          Parser function for given syntax category

                                                          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

                                                                Parser function for given syntax category

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  Equations
                                                                  Instances For
                                                                    Equations
                                                                    Instances For
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def StrataDDM.Parser.runCatParser (tokenTable : Lean.Parser.TokenTable) (parsingTableMap : PrattParsingTableMap) (leanEnv : Lean.Environment) (inputContext : InputContext) (pos stopPos : String.Pos.Raw) (cat : QualifiedIdent) :
                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For