Package parser-comb-def: Definition of stream parser combinators

Information

nameparser-comb-def
version1.83
descriptionDefinition of stream parser combinators
authorJoe Leslie-Hurd <joe@gilith.com>
licenseMIT
provenanceHOL Light theory extracted on 2014-11-04
checksumfcd38ea1bffc7be4eb681d09fa66b22ef4a97266
requiresbool
option
parser-stream
showData.Bool
Data.List
Data.Option
Data.Pair
Parser
Parser.Stream

Files

Defined Type Operator

Defined Constants

Theorems

parseAll = mkParser parseAll.pa

parseNone = mkParser parseNone.pn

a. mkParser (destParser a) = a

p. parse p eof = none

p. parse p error = none

f. parseOption f = partialMap f parseAll

a s. parseNone.pn a s = none

r. isParser r destParser (mkParser r) = r

a s. parseAll.pa a s = some (a, s)

pb pc. parsePair pb pc = mkParser (parsePair.pbc pb pc)

f p. partialMap f p = mkParser (partialMap.pf f p)

p. parseSome p = parseOption (λa. if p a then some a else none)

f p. map f p = partialMap (λb. some (f b)) p

f g p. mapToken f g p = mkParser (mapToken.pf f g p)

p a s. parse p (cons a s) = destParser p a s

p e. inverse p e x s. parse p (append (e x) s) = some (x, s)

p.
    isParser p
    x xs. case p x xs of none | some (y, xs') isSuffix xs' xs

p e.
    strongInverse p e
    inverse p e s x s'. parse p s = some (x, s') s = append (e x) s'

f p a s.
    partialMap.pf f p a s =
    case destParser p a s of
      none none
    | some (b, s') case f b of none none | some c some (c, s')

f g p b s.
    mapToken.pf f g p b s =
    case destParser p (g b) (map g s) of
      none none
    | some (c, s') some (c, map f s')

pb pc a s.
    parsePair.pbc pb pc a s =
    case destParser pb a s of
      none none
    | some (b, s')
        case parse pc s' of
          none none
        | some (c, s'') some ((b, c), s'')

External Type Operators

External Constants

Assumptions

() = λp. p ((select) p)

t. (x. t) t

() = λp. p = λx.

() = λp q. p q p

b f. case b f none = b

() = λp q. (λf. f p q) = λf. f

() = λp. q. (x. p x q) q

f0 f1 f2.
    fn.
      fn error = f0 fn eof = f1
      a0 a1. fn (cons a0 a1) = f2 a0 a1 (fn a1)