Changeset 12

Show
Ignore:
Timestamp:
07/12/08 01:31:33 (2 years ago)
Author:
thesz
Message:

Removed unnecessary SP type.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fort/Parser.hs

    r11 r12  
    33-- but went into slightly more than that. 
    44-- I don't mind it, I'll deal with it later. 
    5 -- BTW, it is quite buggy and unfriendly. Again, I'll sort it later. 
     5-- BTW, it is quite buggy and unfriendly. Again, I'll sort that later. 
    66 
    77module Parser where 
     
    2323 
    2424------------------------------------------------------------------------------- 
    25 -- A parser monad
     25-- Position type
    2626 
    2727data Pos = Pos { 
     
    3636type PosString = [PosChar] 
    3737 
    38 data SP i o = 
    39                 N 
    40         |       O       o       (SP i o) 
    41         |       I       (i -> SP i o) 
    42  
    43 spPar N b = b 
    44 spPar (O o a) b = O o $ spPar a b 
    45 spPar a N = a 
    46 spPar a (O o b) = O o $ spPar a b 
    47 spPar (I f) (I g) = I $ \x -> spPar (f x) (g x) 
    48  
    49 instance Monad (SP i) where 
    50         return x = O x N 
    51  
    52         N >>= _ = N 
    53         (O o a) >>= q = (a >>= q) `spPar` q o 
    54         (I f) >>= q = I $ \x -> f x >>= q 
    55  
    5638------------------------------------------------------------------------------- 
    57 -- Parser
     39-- Parser monad
    5840 
    5941data P s a = P { unP :: ((s,String) -> [(a,(s,String))]) }