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 /sml/trunk/src/smlnj-lib/RegExp/Glue/regexp-fn.sml
ViewVC logotype

Annotation of /sml/trunk/src/smlnj-lib/RegExp/Glue/regexp-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 104 - (view) (download)

1 : monnier 104 (* regexp-fn.sml
2 :     *
3 :     * COPYRIGHT (c) 1998 Bell Labs, Lucent Technologies.
4 :     *
5 :     * Functor that implements a regular expressions matcher by combining
6 :     * a surface syntax and a matching engine.
7 :     *)
8 :    
9 :     functor RegExpFn (structure P : REGEXP_PARSER
10 :     structure E : REGEXP_ENGINE) : REGEXP =
11 :     struct
12 :    
13 :     structure M = MatchTree
14 :    
15 :     type regexp = E.regexp
16 :    
17 :     fun compile reader s = (case (P.scan reader s)
18 :     of NONE => NONE
19 :     | SOME (syntax,s') => let val v = E.compile syntax
20 :     in
21 :     SOME (v,s')
22 :     end)
23 :    
24 :     fun compileString str = (case (StringCvt.scanString P.scan str)
25 :     of SOME r => E.compile (r)
26 :     | NONE => raise RegExpSyntax.CannotParse)
27 :    
28 :     val prefix = E.prefix
29 :     val find = E.find
30 :     fun match l =
31 :     let val l' = map (fn (s,f) => ((case (StringCvt.scanString P.scan s)
32 :     of SOME r => r
33 :     | NONE => raise RegExpSyntax.CannotParse),
34 :     f)) l
35 :     val m = E.match l'
36 :     in
37 :     fn getc => fn stream => m getc stream
38 :     end
39 :    
40 :     end

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