regexp doc repairs and links

svn: r9876
This commit is contained in:
Matthew Flatt 2008-05-17 12:29:58 +00:00
parent 5e23e8c683
commit 6f6d8d74b4
3 changed files with 21 additions and 20 deletions

View File

@ -17,7 +17,7 @@
@title[#:tag "classes"]{Classes and Objects} @title[#:tag "classes"]{Classes and Objects}
@margin-note{This section is based on a paper @cite["Flatt06"].} @margin-note{This chapter is based on a paper @cite["Flatt06"].}
A @scheme[class] expression denotes a first-class value, A @scheme[class] expression denotes a first-class value,
just like a @scheme[lambda] expression: just like a @scheme[lambda] expression:

View File

@ -5,7 +5,7 @@
@title[#:tag "regexp" #:style 'toc]{Regular Expressions} @title[#:tag "regexp" #:style 'toc]{Regular Expressions}
@margin-note{This section is based on @cite["Sitaram05"].} @margin-note{This chapter is a modified version of @cite["Sitaram05"].}
A @deftech{regexp} value encapsulates a pattern that is described by a A @deftech{regexp} value encapsulates a pattern that is described by a
string or @tech{byte string}. The regexp matcher tries to match this string or @tech{byte string}. The regexp matcher tries to match this
@ -16,6 +16,8 @@ not as a pattern.
@local-table-of-contents[] @local-table-of-contents[]
@refdetails["regexp"]{regexps}
@; ---------------------------------------- @; ----------------------------------------
@section[#:tag "regexp-intro"]{Writing Regexp Patterns} @section[#:tag "regexp-intro"]{Writing Regexp Patterns}
@ -26,21 +28,19 @@ pattern, or it can be prefixed with @litchar{#rx} to form a literal
@tech{regexp} value, and @scheme[#rx#"abc"] is a @tech{byte @tech{regexp} value, and @scheme[#rx#"abc"] is a @tech{byte
string}-based @tech{regexp} value. Alternately, a string or byte string}-based @tech{regexp} value. Alternately, a string or byte
string can be prefixed with @litchar{#px}, as in @scheme[#px"abc"], string can be prefixed with @litchar{#px}, as in @scheme[#px"abc"],
for a slightly different syntax of patterns within the string. for a slightly extended syntax of patterns within the string.
Most of the characters in a @tech{regexp} pattern are meant to match Most of the characters in a @tech{regexp} pattern are meant to match
occurrences of themselves in the text string. Thus, the pattern occurrences of themselves in the text string. Thus, the pattern
@scheme[#rx"abc"] matches a string that contains the characters @scheme[#rx"abc"] matches a string that contains the characters
@litchar{a}, @litchar{b}, and @litchar{c} in succession. @litchar{a}, @litchar{b}, and @litchar{c} in succession. Other
characters act as @deftech{metacharacters}, and some character
In the regexp pattern, some characters act as sequences act as @deftech{metasequences}. That is, they specify
@deftech{metacharacters}, and some character sequences act as something other than their literal selves. For example, in the
@deftech{metasequences}. That is, they specify something other than pattern @scheme[#rx"a.c"], the characters @litchar{a} and @litchar{c}
their literal selves. For example, in the pattern @scheme[#rx"a.c"], stand for themselves, but the @tech{metacharacter} @litchar{.} can
the characters @litchar{a} and @litchar{c} stand for themselves, but match @emph{any} character. Therefore, the pattern @scheme[#rx"a.c"]
the @tech{metacharacter} @litchar{.} can match @emph{any} character. matches an @litchar{a}, any character, and @litchar{c} in succession.
Therefore, the pattern @scheme[#rx"a.c"] matches an @litchar{a}, any
character, and @litchar{c} in succession.
@margin-note{When we want a literal @litchar{\} inside a Scheme string @margin-note{When we want a literal @litchar{\} inside a Scheme string
or regexp literal, we must escape it so that it shows up in the string or regexp literal, we must escape it so that it shows up in the string
@ -55,17 +55,16 @@ it by precede it with a @litchar{\}. The character sequence
@litchar{\.} is thus a @tech{metasequence}, since it doesn't match @litchar{\.} is thus a @tech{metasequence}, since it doesn't match
itself but rather just @litchar{.}. So, to match @litchar{a}, itself but rather just @litchar{.}. So, to match @litchar{a},
@litchar{.}, and @litchar{c} in succession, we use the regexp pattern @litchar{.}, and @litchar{c} in succession, we use the regexp pattern
@scheme["a\\.c"]; the double @litchar{\} is an artifact of Scheme @scheme[#rx"a\\.c"]; the double @litchar{\} is an artifact of Scheme
strings, not the @tech{regexp} pattern itself. strings, not the @tech{regexp} pattern itself.
The @scheme[regexp] function takes a string or byte string and The @scheme[regexp] function takes a string or byte string and
produces a @tech{regexp} value. Use @scheme[regexp] when you construct produces a @tech{regexp} value. Use @scheme[regexp] when you construct
a pattern to be matched against multiple strings, since a pattern must a pattern to be matched against multiple strings, since a pattern is
be compiled to a @tech{regexp} value before it can be used in a match. compiled to a @tech{regexp} value before it can be used in a match.
The @scheme[pregexp] function is like @scheme[regexp], but it parses The @scheme[pregexp] function is like @scheme[regexp], but using the
the pattern in an alternate syntax. Regexp values with as literals extended syntax. Regexp values as literals with @litchar{#rx} or
with @litchar{#rx} or @litchar{#px} are compiled once and for all when @litchar{#px} are compiled once and for all when they are read.
they are read.
The @scheme[regexp-quote] function takes an arbitrary string and The @scheme[regexp-quote] function takes an arbitrary string and

View File

@ -10,6 +10,8 @@
@section-index["strings" "pattern matching"] @section-index["strings" "pattern matching"]
@section-index["input ports" "pattern matching"] @section-index["input ports" "pattern matching"]
@guideintro["regexp"]{regular expressions}
@local-table-of-contents[] @local-table-of-contents[]
Regular expressions are specified as strings or byte strings, using Regular expressions are specified as strings or byte strings, using