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

Information

nameparser-comb-def
version1.28
descriptionDefinition of stream parser combinators
authorJoe Hurd <joe@gilith.com>
licenseMIT
provenanceHOL Light theory extracted on 2011-11-29
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

p a s. parse p (stream 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 T | 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')

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

Input Type Operators

Input Constants

Assumptions

T

() = λP. P ((select) P)

t. (x. t) t

() = λp. p = λx. T

() = λp q. p q p

b f. case b f none = b

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

() = λP. q. (x. P x q) q

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