Documentation

PrimParser.Utf8

UTF-8 Character parsers #

@[reducible, inline]
abbrev Parser.Utf8Parser (ε : Type) (g : Grade) (α : Type) :
Equations
Instances For
    def Parser.runParser {α ε : Type} {g : Grade} (p : Parser ByteArray Char ε g α) (s : String) :
    Except ε α

    Run a parser on a String.

    Equations
    Instances For
      def Parser.runOption {α ε : Type} {ge gc : Necessity} (p : Parser ByteArray Char ε { errors := ge, consumes := gc } α) (s : String) :

      Run a parser on a String, discarding the error and returning the value as an Option.

      Equations
      Instances For

        Consume a single byte.

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

          Consume a single UTF-8 character.

          Equations
          Instances For

            Match a specific character.

            Equations
            Instances For
              def Parser.Utf8.string (str : String) (h : str ≠ "" := by decide) :

              Match an exact non-empty string

              Equations
              Instances For

                Consume characters while f holds, returning the collected string.

                Equations
                Instances For

                  Consume one or more characters while f holds.

                  Equations
                  Instances For

                    Skip characters while f holds.

                    Equations
                    Instances For

                      Skip one or more characters while f holds.

                      Equations
                      Instances For
                        theorem Parser.Utf8.takeWhile1_run_accept {n : ℕ} {f : Char → Bool} {c : Char} {t : Input ByteArray n} (h : t.nextTok = some c := by assumption) (hf : f c = true := by assumption) :
                        (takeWhile1 f).run t = success { result := Input.takeWhile f t, restSize := ↑(Input.skipWhile f t), witness := ⋯ }
                        theorem Parser.Utf8.takeWhile1_run_failure {n : ℕ} {f : Char → Bool} {t : Input ByteArray n} {fl : Failure n Error} (hs : (satisfy f).run t = failure fl) :

                        takeWhile1 fails exactly as the leading satisfy does.

                        theorem Parser.Utf8.skipWhile1_run_accept {n : ℕ} {f : Char → Bool} {c : Char} {t : Input ByteArray n} (h : t.nextTok = some c) (hf : f c = true) :
                        (skipWhile1 f).run t = success { result := (), restSize := ↑(Input.skipWhile f t), witness := ⋯ }
                        theorem Parser.Utf8.skipWhile1_run_failure {n : ℕ} {f : Char → Bool} {t : Input ByteArray n} {fl : Failure n Error} (hs : (satisfy f).run t = failure fl) :

                        skipWhile1 fails exactly as takeWhile1 does.

                        def Parser.Utf8.lexeme {α : Type} {ge gc : Necessity} (p : Utf8Parser Error { errors := ge, consumes := gc } α) :
                        Utf8Parser Error { errors := ge, consumes := max gc possibly } α

                        Run p then skip trailing whitespace.

                        Equations
                        Instances For
                          def Parser.Utf8.bracket {α : Type} {ge gc : Necessity} (l r : Utf8Parser Error conditional PUnit.{1}) (p : Utf8Parser Error { errors := ge, consumes := gc } α) :
                          Utf8Parser Error { errors := max ge possibly, consumes := always } α

                          Parse p surrounded by the delimiters l and r. Delimiters consume whitespace after them.

                          Equations
                          Instances For
                            def Parser.Utf8.parens {α : Type} {ge gc : Necessity} (p : Utf8Parser Error { errors := ge, consumes := gc } α) :
                            Utf8Parser Error { errors := max ge possibly, consumes := always } α

                            Parse p surrounded by parentheses.

                            Equations
                            Instances For
                              def Parser.Utf8.brackets {α : Type} {ge gc : Necessity} (p : Utf8Parser Error { errors := ge, consumes := gc } α) :
                              Utf8Parser Error { errors := max ge possibly, consumes := always } α

                              Parse p surrounded by square brackets.

                              Equations
                              Instances For
                                def Parser.Utf8.braces {α : Type} {ge gc : Necessity} (p : Utf8Parser Error { errors := ge, consumes := gc } α) :
                                Utf8Parser Error { errors := max ge possibly, consumes := always } α

                                Parse p surrounded by curly braces.

                                Equations
                                Instances For

                                  Parse a single decimal digit, returning its numeric value.

                                  Equations
                                  Instances For
                                    theorem Parser.Utf8.digit_run_accept {n : ℕ} {c : Char} {t : Input ByteArray n} (h : t.nextTok = some c := by assumption) (hd : c.isDigit = true := by assumption) :
                                    digit.run t = success { result := c.toNat - '0'.toNat, restSize := n - Reader.width ByteArray c, witness := ⋯ }
                                    theorem Parser.Utf8.digit_run_reject {n : ℕ} {c : Char} {t : Input ByteArray n} (h : t.nextTok = some c := by assumption) (hd : ¬c.isDigit = true := by assumption) :
                                    digit.run t = failure { error := Error.fail, restSize := n - Reader.width ByteArray c, witness := ⋯ }
                                    theorem Parser.Utf8.digit_run_eof {n : ℕ} {t : Input ByteArray n} (h : t.nextTok = none := by first | assumption | exact Input.nextTok_eq_none) :
                                    digit.run t = failure { error := Error.eof, restSize := n, witness := ⋯ }

                                    Parse a natural number (one or more digits).

                                    Equations
                                    Instances For

                                      Parse an integer (optional leading - followed by digits).

                                      Equations
                                      Instances For

                                        Match an ASCII control character.

                                        Equations
                                        Instances For

                                          Match a binary digit.

                                          Equations
                                          Instances For

                                            Match an octal digit, returning its numeric value.

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

                                              Match a hexadecimal digit, returning its numeric value.

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