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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2 - (download) (annotate)
Sat Oct 4 23:33:09 1997 UTC (22 years, 6 months ago) by monnier
File size: 1921 byte(s)
Initial revision
(* parser-comb-sig.sml
 * COPYRIGHT (c) 1996 AT&T Research.
 * Parser combinators over readers.  These are modeled after the Haskell
 * combinators of Hutton and Meijer.  The main difference is that they
 * return a single result, instead of a list of results.  This means that
 * "or" is a committed choice; once one branch succeeds, the others will not
 * be enabled.  While this is somewhat limiting, for many applications it
 * will not be a problem.  For more substantial parsing problems, one should
 * use ML-Yacc and/or ML-Lex.

signature PARSER_COMB =

    type ('a, 'strm) parser =
	  (char, 'strm) StringCvt.reader -> ('a, 'strm) StringCvt.reader

    val result : 'a -> ('a, 'strm) parser

    val failure : ('a, 'strm) parser

    val wrap : (('a, 'strm) parser * ('a -> 'b)) -> ('b, 'strm) parser

    val seq : (('a, 'strm) parser * ('b, 'strm) parser) -> (('a * 'b), 'strm) parser
    val seqWith : (('a * 'b) -> 'c)
	  -> (('a, 'strm) parser * ('b, 'strm) parser)
	    -> ('c, 'strm) parser

    val bind : (('a, 'strm) parser * ('a -> ('b, 'strm) parser))
	  -> ('b, 'strm) parser

    val eatChar : (char -> bool) -> (char, 'strm) parser

    val char   : char -> (char, 'strm) parser
    val string : string -> (string, 'strm) parser

    val skipBefore : (char -> bool) -> ('a, 'strm) parser -> ('a, 'strm) parser

    val or : (('a, 'strm) parser * ('a, 'strm) parser) -> ('a, 'strm) parser
    val or' : ('a, 'strm) parser list -> ('a, 'strm) parser

    val zeroOrMore : ('a, 'strm) parser -> ('a list, 'strm) parser
    val oneOrMore  : ('a, 'strm) parser -> ('a list, 'strm) parser

    val option : ('a, 'strm) parser -> ('a option, 'strm) parser

    val token : (char -> bool) -> (string, 'strm) parser
	  (* parse a token consisting of characters satisfying the predicate.
	   * If this succeeds, then the resulting string is guaranteed to be
	   * non-empty.


ViewVC Help
Powered by ViewVC 1.0.0