Commit 4f5ad7a1 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-14 14:29:36 by cvscast] Empty log message

Original author: cvscast
Date: 2003-05-14 14:29:36+00:00
parent 72f04964
......@@ -12,9 +12,10 @@ let fun load_include (String -> [Any*])
<include file=(s & String)>[] -> load_include s;;
let fun hilight (String -> [ (Char | Xvar)* ] )
| [ '{{' h ::(Char *?) '}}' ; rest ] -> [ <var class="hilight">h; hilight rest ]
| [ c; rest ] -> [ c; hilight rest ]
let fun highlight (String -> [ (Char | Xvar)* ] )
| [ '{{' h ::(Char *?) '}}' ; rest ] ->
[ <var class="highlight">h; highlight rest ]
| [ c; rest ] -> [ c; highlight rest ]
| [] -> [];;
......@@ -74,7 +75,7 @@ let fun authors ([Author+] -> String)
let fun text (t : [InlineText*]) : Inlines =
map t with
| <duce>x -> <b>[ <tt>(hilight x) ]
| <duce>x -> <b>[ <tt>(highlight x) ]
| <(tag & (`b|`i|`tt|`em))>x -> <(tag)>(text x)
| z -> z;;
......@@ -93,7 +94,7 @@ let fun content (t : Content) : Flow =
| <include-verbatim file=f>[] ->
[ <div class="code">[ <pre>(load_file f) ] ]
| <sample>s ->
[ <div class="code">[ <pre>(hilight s) ] ]
[ <div class="code">[ <pre>(highlight s) ] ]
| <link url=url; title=title>com ->
[ <a href=url>title '. ' !(text com) ]
| <ul>lis ->
......
......@@ -42,8 +42,8 @@ This page is a step-by-step introduction to CDuce.
<box title="First functions" link="t2">
<p>
A first example of transformation is \msf{names}, which extracts the
sequences of all names of parents in a \msf {ParentBook} element:
A first example of transformation is <duce>names</duce>, which extracts the
sequences of all names of parents in a <duce>ParentBook</duce> element:
</p>
<sample><![CDATA[
......@@ -51,21 +51,21 @@ let fun names (ParentBook -> [Name*])
<parentbook>x -> (map x with <person>[ n _*] -> n)
]]></sample>
The name of the transformation is followed by an {\it interface\/} that
states that \msf{names} is a function from
\msf{ParentBook} elements to (possibly empty) sequences of
\msf{Name} elements. This is obtained by matching the argument of the
states that <duce>names</duce> is a function from
<duce>ParentBook</duce> elements to (possibly empty) sequences of
<duce>Name</duce> elements. This is obtained by matching the argument of the
function against the pattern <sample><![CDATA[<parentbook>x ]]></sample>
which binds \msf{x} to
which binds <duce>x</duce> to
the sequence of person elements forming the parentbook. The operator
\msf{map} applies to each element of a sequence (in this case \msf{x}) the
transformation defined by the subsequent pattern matching. Here \msf{map}
returns the sequence obtained by replacing each person in \msf{x} by its
\msf{Name} element. Note that we use the pattern
<sample><![CDATA[<person>[ n \_*],
<duce>map</duce> applies to each element of a sequence (in this case <duce>x</duce>) the
transformation defined by the subsequent pattern matching. Here <duce>map</duce>
returns the sequence obtained by replacing each person in <duce>x</duce> by its
<duce>Name</duce> element. Note that we use the pattern
<sample><![CDATA[<person>[ n _*],
]]></sample>
to
match the person elements: \msf{n} matches (and captures) the \msf{Name}
element-that is, the first element of the sequence-, \msf{\_*} matches (and discards) the sequence of elements that
match the person elements: <duce>n</duce> matches (and captures) the <duce>Name</duce>
element-that is, the first element of the sequence-, <duce>_*</duce> matches (and discards) the sequence of elements that
follow, and person matches the tag of the person (although the
latter contains an attribute). The interface and the type definitions
ensure that the tags will be the expected ones, so we could optimize the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment