10.3.3. Regexp Constructors

The procedures in this section construct regexp objects that are used by the subparsing procedures.

(regexp-node proc)

Returns a regexp that matches a node-list with respect to any search list if the node-list contains exactly one node and proc applied to that node-list returns a true value.

(regexp-seq regexp1 regexp2 ... regexpn)

Returns a regexp that matches a node-list with respect to a search list x if the node-list can be split into sublists s1, s2,..., sn such that regexpi matches si with respect to the search list x for 1 <= i <= n and such that si immediately precedes si+1 with respect to x for 1 <= i <= n-1.

(regexp-or regexp1 regexp2 ... regexpn)

Returns a regexp that matches a node-list with respect to a search list x if, for some i such that 1 <= i <= n, the node-list matches regexpi with respect to x.

(regexp-and regexp1 regexp2 ... regexpn)

Returns a regexp that matches a node-list with respect to a search list x if, for every i such that 1 <= i <= n, the node-list matches regexpi with respect to x.

(regexp-rep regexp)

Returns a regexp that matches a node-list with respect to a search list x if the node-list is empty or if there is some integer n >= 1 such that the node-list can be split into sublists s1,s2,...,sn such that si matches regexp for each i such that 1 <= i <= n and such that si immediately precedes si+1 with respect to x for each i such that 1 <= i <= n-1.

(regexp-plus regexp)

Returns a regexp that matches a node-list with respect to a search list x if there is some integer n >= 1 such that the node-list can be split into sublists s1, s2,...,sn such that si matches regexp for each i such that 1 <= i <= n and such that si immediately precedes si+1 with respect to x for each i such that 1 <= i <= n-1.

(regexp-opt regexp)

Returns a regexp that matches a node-list with respect to a search list x if either the node-list is empty or the node-list matches regexp with respect to x.

(regexp-range regexp k1 k2)

Returns a regexp that matches a node-list with respect to a search list x if there is some integer n with k1 <= n <= k2 such that the node-list can be split into sublists s1,s2,...,sn such that si matches regexp for each i such that 1 <= i <= n and such that si immediately precedes si+1 with respect to x for each i such that 1 <= i <= n-1. If k1 is zero, then the returned regexp shall match the empty node-list.

(string->regexp string)

Returns the regexp represented by string. It shall be an error if string is not a valid representation of an extended regular expression as defined in ISO 9945-2. A normal character in string matches a node with a char property whose value is that character.

NOTE 28: This could be implemented in terms of the above primitives.