⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regexp-intro.mldoc

📁 这是我们参加06年全国开源软件的竞赛作品
💻 MLDOC
字号:
<!-- regexp-intro.mldoc --><!DOCTYPE ML-DOC SYSTEM><AUTHOR  NAME="Riccardo Pucella"  EMAIL="riccardo@research.bell-labs.com"  YEAR=1998><COPYRIGHT OWNER="Bell Labs, Lucent Technologies" YEAR=1998><VERSION VERID="1.0" YEAR=1998 MONTH=6 DAY=1><TITLE>Introduction</TITLE><SECTION><HEAD>Introduction</HEAD><PP>This is a regular expressions library. It is based on a decouplingof the surface syntax used to specify regular expressions (thefrontend) and the engine that implements the matcher (the matcher). Anabstract syntax is used to communicate between the front end and theback end of the system.<PP>Given a structure <CD/S1/ describing a surface syntax and a structure<CD/S2/ describing a matching engine, a regular expression package canbe defined by applying the functor <FCTREF/RegExpFn/ like so:<CODE>RegExpFn (structure P=S1  structure E=S2)</CODE><PP>To match a regular expression, one first needs to compile arepresentation in the surface syntax. The type of a compiled regularexpression is given in the <SIGREF/REGEXP/ signature as: <CODE>type regexp</CODE><PP>Once a regular expression has been compiled, three functions areprovided to perform the matching, <CD/find/, <CD/prefix/ and<CD/match/. These functions operate on readers as defined in the<CD/StringCvt/ structure of the Basis Library. A readerof type <CD/('a,'b) reader/ is a function <CD/'b -> ('a,'b) option/taking a stream of type <CD/'b/ and returning an element of type<CD/'a/ and the remainder of the stream, or <CD/NONE/ if the end ofthe stream is reached.<PP> The function <CD/find/ returns a reader that searches a stream andattempts to match the given regular expression. The function<CD/prefix/ returns a reader that attempts to match the regularexpression at the current position in the stream. The function<CD/match/ takes a list of regular expressions and functions andreturns a reader that attempts to match one of the regular expressionsat the current position in the stream. The function corresponding tothe matched regular expression is invoked on the matchinginformation. <PP>Once a match is found, it is returned as a <CD/match_tree/ datatypeThis is a hierarchical structure describing the matches of the varioussubexpressions appearing in the matched regular expression. A matchfor an expression is a record containing the position of the match andits length. The root of the structure always describes the outermostmatch (the whole string matched by the regular expression). <PP></SECTION>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -