Commit 3307edb7 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 2a5d0350
...@@ -12,9 +12,10 @@ let fun load_include (String -> [Any*]) ...@@ -12,9 +12,10 @@ let fun load_include (String -> [Any*])
<include file=(s & String)>[] -> load_include s;; <include file=(s & String)>[] -> load_include s;;
let fun hilight (String -> [ (Char | Xvar)* ] ) let fun highlight (String -> [ (Char | Xvar)* ] )
| [ '{{' h ::(Char *?) '}}' ; rest ] -> [ <var class="hilight">h; hilight rest ] | [ '{{' h ::(Char *?) '}}' ; rest ] ->
| [ c; rest ] -> [ c; hilight rest ] [ <var class="highlight">h; highlight rest ]
| [ c; rest ] -> [ c; highlight rest ]
| [] -> [];; | [] -> [];;
...@@ -74,7 +75,7 @@ let fun authors ([Author+] -> String) ...@@ -74,7 +75,7 @@ let fun authors ([Author+] -> String)
let fun text (t : [InlineText*]) : Inlines = let fun text (t : [InlineText*]) : Inlines =
map t with map t with
| <duce>x -> <b>[ <tt>(hilight x) ] | <duce>x -> <b>[ <tt>(highlight x) ]
| <(tag & (`b|`i|`tt|`em))>x -> <(tag)>(text x) | <(tag & (`b|`i|`tt|`em))>x -> <(tag)>(text x)
| z -> z;; | z -> z;;
...@@ -93,7 +94,7 @@ let fun content (t : Content) : Flow = ...@@ -93,7 +94,7 @@ let fun content (t : Content) : Flow =
| <include-verbatim file=f>[] -> | <include-verbatim file=f>[] ->
[ <div class="code">[ <pre>(load_file f) ] ] [ <div class="code">[ <pre>(load_file f) ] ]
| <sample>s -> | <sample>s ->
[ <div class="code">[ <pre>(hilight s) ] ] [ <div class="code">[ <pre>(highlight s) ] ]
| <link url=url; title=title>com -> | <link url=url; title=title>com ->
[ <a href=url>title '. ' !(text com) ] [ <a href=url>title '. ' !(text com) ]
| <ul>lis -> | <ul>lis ->
......
...@@ -42,8 +42,8 @@ This page is a step-by-step introduction to CDuce. ...@@ -42,8 +42,8 @@ This page is a step-by-step introduction to CDuce.
<box title="First functions" link="t2"> <box title="First functions" link="t2">
<p> <p>
A first example of transformation is \msf{names}, which extracts the A first example of transformation is <duce>names</duce>, which extracts the
sequences of all names of parents in a \msf {ParentBook} element: sequences of all names of parents in a <duce>ParentBook</duce> element:
</p> </p>
<sample><![CDATA[ <sample><![CDATA[
...@@ -51,21 +51,21 @@ let fun names (ParentBook -> [Name*]) ...@@ -51,21 +51,21 @@ let fun names (ParentBook -> [Name*])
<parentbook>x -> (map x with <person>[ n _*] -> n) <parentbook>x -> (map x with <person>[ n _*] -> n)
]]></sample> ]]></sample>
The name of the transformation is followed by an {\it interface\/} that The name of the transformation is followed by an {\it interface\/} that
states that \msf{names} is a function from states that <duce>names</duce> is a function from
\msf{ParentBook} elements to (possibly empty) sequences of <duce>ParentBook</duce> elements to (possibly empty) sequences of
\msf{Name} elements. This is obtained by matching the argument of the <duce>Name</duce> elements. This is obtained by matching the argument of the
function against the pattern <sample><![CDATA[<parentbook>x ]]></sample> 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 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 <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 \msf{map} transformation defined by the subsequent pattern matching. Here <duce>map</duce>
returns the sequence obtained by replacing each person in \msf{x} by its returns the sequence obtained by replacing each person in <duce>x</duce> by its
\msf{Name} element. Note that we use the pattern <duce>Name</duce> element. Note that we use the pattern
<sample><![CDATA[<person>[ n \_*], <sample><![CDATA[<person>[ n _*],
]]></sample> ]]></sample>
to to
match the person elements: \msf{n} matches (and captures) the \msf{Name} match the person elements: <duce>n</duce> matches (and captures) the <duce>Name</duce>
element-that is, the first element of the sequence-, \msf{\_*} matches (and discards) the sequence of elements that 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 follow, and person matches the tag of the person (although the
latter contains an attribute). The interface and the type definitions latter contains an attribute). The interface and the type definitions
ensure that the tags will be the expected ones, so we could optimize the 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