# SML/NJ Library Manual

## The `REGEXP` signature

#### Synopsis

> `signature `REGEXP`
> `

This is the signature of a regular expressions matching structure. Such a structure is created by applying the functor `RegExpFn` to a given concrete syntax for regular expressions and a given matching engine.

#### Interface

> `type regexp
> val compile : (char,'a) StringCvt.reader -> (regexp,'a) StringCvt.reader
> val compileString : string -> regexp
> val find : regexp -> (char,'a) StringCvt.reader -> ({pos : 'a, len : int} option MatchTree.match_tree,'a) StringCvt.reader
> val prefix : regexp -> (char,'a) StringCvt.reader -> ({pos : 'a, len : int} option MatchTree.match_tree,'a) StringCvt.reader
> val match : (string * ({pos : 'a, len : int} option MatchTree.match_tree -> 'b)) list -> (char,'a) StringCvt.reader -> ('b,'a) StringCvt.reader
> `

#### Description

`type regexp`
  the type of a compiled regular expression
`compile getc`
  Given a character reader getc, this function returns a reader that parses a regular expression in the concrete syntax from the stream and compiles it.
`compileString s`
  compiles a string representing a regular expression in the concrete syntax. The function `compileString` is equivalent to `StringCvt.scanString compile`.
`find r getc`
  Given a compiled regular expression r and a character reader getc, this function returns a reader that scans the stream for the first match of the regular expression. The reader returns `NONE` if no match is found.
`prefix r getc`
  Given a compiled regular expression r and a character reader getc, this functions returns a reader that attempts to match the stream at its current position with the regular expression. The reader returns `NONE` if there is not match at the current position of the stream.
`match l getc`
  Given a list l of tuples made up of a string representing a regular expression in the concrete syntax and a function from matching tree to values of type `'b`, and given a character reader getc, this function returns a reader that attempts to match one of the given regular expressions at the current position of the stream. If a match is found, the corresponding function is applied to the match tree and the result is returned. The reader returns `NONE` if no match is found.

#### See Also

> RegExpFn, MatchTree

[ Top | Parent | Contents | Index | Root ]

Last Modified June 3, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies