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 1783 - (download) (annotate)
Wed May 4 15:32:16 2005 UTC (14 years, 5 months ago) by mblume
File size: 1986 byte(s)
added join to parser combinators
(* 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 =
  sig

    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 join   : ('a option, 'strm) parser -> ('a, '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.
	   *)

  end;

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