git @ Cat's Eye Technologies Parc / 3b43a59
Add more example combinators to the ParcSt2St demo. Chris Pressey 1 year, 5 months ago
1 changed file(s) with 8 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1111
1212 char x = pred (\c v -> if x == c then Just v else Nothing)
1313 try c = alt c ok
14 fol f [] = ok
15 fol f (c:cs) = seq (f c) (fol f cs)
16 seqn = fol (id)
17 str = fol (char)
1418
1519 -- Grammar
1620
2125 bits = seq bit (many bit)
2226 bitstring = seq bits (try (char 'B'))
2327 docco = many (seq (many whitespace) bitstring)
28 keyword s st = seqn [many whitespace, str s, update $ \v -> (s:v)] st
29 proggo = seqn $ map (keyword) ["while", "do", "that"]
2430
2531 -- Demo
32
2633 test1 = docco $ Parsing "1110B 100B" 0
2734 test2 = docco $ Parsing "1110G 100B" 0
35 test3 = proggo $ Parsing "while do that" []