Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /smlnj-lib/trunk/Util/parser-comb-sig.sml
ViewVC logotype

Annotation of /smlnj-lib/trunk/Util/parser-comb-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1783 - (view) (download)
Original Path: sml/trunk/src/smlnj-lib/Util/parser-comb-sig.sml

1 : monnier 2 (* parser-comb-sig.sml
2 :     *
3 :     * COPYRIGHT (c) 1996 AT&T Research.
4 :     *
5 :     * Parser combinators over readers. These are modeled after the Haskell
6 :     * combinators of Hutton and Meijer. The main difference is that they
7 :     * return a single result, instead of a list of results. This means that
8 :     * "or" is a committed choice; once one branch succeeds, the others will not
9 :     * be enabled. While this is somewhat limiting, for many applications it
10 :     * will not be a problem. For more substantial parsing problems, one should
11 :     * use ML-Yacc and/or ML-Lex.
12 :     *)
13 :    
14 :     signature PARSER_COMB =
15 :     sig
16 :    
17 :     type ('a, 'strm) parser =
18 :     (char, 'strm) StringCvt.reader -> ('a, 'strm) StringCvt.reader
19 :    
20 :     val result : 'a -> ('a, 'strm) parser
21 :    
22 :     val failure : ('a, 'strm) parser
23 :    
24 :     val wrap : (('a, 'strm) parser * ('a -> 'b)) -> ('b, 'strm) parser
25 :    
26 :     val seq : (('a, 'strm) parser * ('b, 'strm) parser) -> (('a * 'b), 'strm) parser
27 :     val seqWith : (('a * 'b) -> 'c)
28 :     -> (('a, 'strm) parser * ('b, 'strm) parser)
29 :     -> ('c, 'strm) parser
30 :    
31 :     val bind : (('a, 'strm) parser * ('a -> ('b, 'strm) parser))
32 :     -> ('b, 'strm) parser
33 :    
34 :     val eatChar : (char -> bool) -> (char, 'strm) parser
35 :    
36 :     val char : char -> (char, 'strm) parser
37 :     val string : string -> (string, 'strm) parser
38 :    
39 :     val skipBefore : (char -> bool) -> ('a, 'strm) parser -> ('a, 'strm) parser
40 :    
41 :     val or : (('a, 'strm) parser * ('a, 'strm) parser) -> ('a, 'strm) parser
42 :     val or' : ('a, 'strm) parser list -> ('a, 'strm) parser
43 :    
44 :     val zeroOrMore : ('a, 'strm) parser -> ('a list, 'strm) parser
45 :     val oneOrMore : ('a, 'strm) parser -> ('a list, 'strm) parser
46 :    
47 :     val option : ('a, 'strm) parser -> ('a option, 'strm) parser
48 : mblume 1783 val join : ('a option, 'strm) parser -> ('a, 'strm) parser
49 : monnier 2
50 :     val token : (char -> bool) -> (string, 'strm) parser
51 :     (* parse a token consisting of characters satisfying the predicate.
52 :     * If this succeeds, then the resulting string is guaranteed to be
53 :     * non-empty.
54 :     *)
55 :    
56 :     end;

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0