Commit 365818df authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-13 17:13:48 by cvscast] Starting tutorial

Original author: cvscast
Date: 2003-05-13 17:13:52+00:00
parent 4c407dda
......@@ -130,10 +130,10 @@ and eval_transform env brs = function
and eval_xtrans env brs = function
| Pair (x,y) ->
let y = eval_xtrans env brs y in (* Beware of evaluation order !! Reverse it ? *)
(try
let x = eval_branches env brs x in
(* TODO: avoid raising exceptions (for each character/element !) *)
let y = eval_xtrans env brs y in
eval_concat x y
with EMatchFail ->
let x = match x with
......@@ -142,6 +142,7 @@ and eval_xtrans env brs = function
Xml (tag, Pair (attr, child))
| Xml (_,_) -> assert false
| x -> x in
let y = eval_xtrans env brs y in
Pair (x,y))
| String_latin1 (_,_,_,_) | String_utf8 (_,_,_,_) as v -> eval_xtrans env brs (normalize v)
(* TODO: optimize for strings, to avoid decomposing compound String values *)
......
let x : `A | `B = `A;;
let y : `A | `B = `B;;
(* let z : (`A,`A)|(`B,`B) = (x,y);; *)
let a : { x = `A; y = `A } | { x = `B; y = `B } = { x = x; y = y };;
\ No newline at end of file
......@@ -164,7 +164,7 @@ and derecurs_regexp vars env = function
| Seq (p1,p2) -> PSeq (derecurs_regexp vars env p1, derecurs_regexp vars env p2)
| Alt (p1,p2) -> PAlt (derecurs_regexp vars env p1, derecurs_regexp vars env p2)
| Star p -> PStar (derecurs_regexp vars env p)
| WeakStar p -> PStar (derecurs_regexp vars env p)
| WeakStar p -> PWeakStar (derecurs_regexp vars env p)
| SeqCapture (x,p) -> derecurs_regexp (fun p -> PAnd (vars p, PCapture x)) env p
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="bench.php">
<title>Benchmarks</title>
<banner>Benchmarks</banner>
......
......@@ -43,7 +43,9 @@ p {
pre {
margin: 1ex 1em 0 1em;
}
var.hilight {
color: #FF0000;
}
div.abstract {
font: bold 80% helvetica;
......@@ -83,6 +85,11 @@ div.box {
margin: 2ex 1em 2ex 1em;
padding: 0ex 0ex 0.5em 0ex;
}
div.code {
background: #E0E0E0;
margin: 0.5ex 0.5em 0 0.5em;
padding: 0.2ex;
}
div.title {
background: #FFFFFF;
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="examples.php">
<title>CDuce: code examples</title>
<banner>CDuce: code examples</banner>
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="index.php">
<title>CDuce</title>
<banner>
......@@ -14,12 +14,14 @@
<box>
<ul>
<li><a href="plan.php">Site map</a></li>
<li><a href="/cgi-bin/cduce">Online demo</a></li>
<li><a href="papers.php">Papers and talks</a></li>
<li><a href="team.php">CDuce team</a></li>
<li><a href="plan.php">Site map</a></li>
<li><a href="bench.php">Benchmarks</a></li>
<li><a href="examples.php">Examples</a></li>
<li><a href="memento.php">Memento</a></li>
<li><a href="tutorial.php">Tutorial</a></li>
</ul>
</box>
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="memento.php">
<title>CDuce memento</title>
<banner> CDuce memento </banner>
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="papers.php">
<title>Papers and talks about CDuce</title>
<banner>Papers and talks about CDuce</banner>
......
......@@ -4,13 +4,27 @@
include "xhtml-strict.cd";; (* XHTML 1 Strict DTD *)
include "xhtml-categ.cd";; (* Categories (Inline, ...) from this DTD *)
let fun load_include (String -> [Any*])
name ->
let _ = print [ 'Loading ' !name '... \n' ] in
xtransform [ (load_xml name) ] with
<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 ]
| [] -> [];;
type SitePage =
<page {|input=String; output=String|}>[]
Page
| <external {|href=String; title=String|}>[];;
type Site = <site>[ SitePage* ];;
type Page =
<page>[
<page output=String>[
<title>String
<banner>[InlineText*]
<navig>[ NavigBox* ] <main>[ Box* ] ];;
......@@ -36,6 +50,7 @@ type Content =
[ ( <p {||}>[InlineText*]
| <ul {||}>[<li {||}>Content +]
| <section title=String>Content
| <sample>String
| Xtable
| Paper | Slides | Link
| <include-verbatim file=String>[]
......@@ -43,8 +58,8 @@ type Content =
type InlineText =
Char
| <(`b|`i|`tt) {||}>[InlineText*]
| <duce>[InlineText*]
| <(`b|`i|`tt|`em) {||}>[InlineText*]
| <duce>String
| Xa
| Ximg | Xbr ;;
......@@ -59,8 +74,8 @@ let fun authors ([Author+] -> String)
let fun text (t : [InlineText*]) : Inlines =
map t with
| <duce>x -> <b>[ <tt>(text x) ]
| <(tag & (`b|`i|`tt))>x -> <(tag)>(text x)
| <duce>x -> <b>[ <tt>(hilight x) ]
| <(tag & (`b|`i|`tt|`em))>x -> <(tag)>(text x)
| z -> z;;
let fun content (t : Content) : Flow =
......@@ -77,6 +92,8 @@ let fun content (t : Content) : Flow =
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
| <include-verbatim file=f>[] ->
[ <div class="code">[ <pre>(load_file f) ] ]
| <sample>s ->
[ <div class="code">[ <pre>(hilight s) ] ]
| <link url=url; title=title>com ->
[ <a href=url>title '. ' !(text com) ]
| <ul>lis ->
......@@ -150,7 +167,7 @@ let fun page2html (Page -> Xhtml)
type P = (String,<title>String);;
let fun make_plan (l : [ P+ ]) : Page =
<page>[
<page output="plan.php">[
<title>"CDuce site"
<banner>"CDuce site"
<navig>[ <box>[ <a href="/">"Home" ] ]
......@@ -162,36 +179,26 @@ let fun make_plan (l : [ P+ ]) : Page =
]
];;
let fun do_page((Page,String) -> [])
(page,outf) ->
let _ = print [ 'Generating html ... ' ] in
let fun do_page(Page -> P)
<page output=outf>[ tit & <title>_; _ ] & page ->
let _ = print [ 'Generating html... ' ] in
let html : String =
[ (* '<?xml version="1.0" encoding="iso-8859-1"?>' *)
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
!(patch_css (print_xml (page2html page))) ] in
let _ = print [ 'Saving to ' !outf '...\n' ] in
dump_to_file outf html;;
let fun do_file((String,String) -> P)
(inf,outf) ->
let _ = print [ 'Loading ' !inf '... ' ] in
let page = match load_xml inf with
| Page & p -> p
| _ -> raise ("Invalid input document: " @ inf) in
let _ = do_page (page,outf) in
let tit = match [page]/<title>_ with [t] -> t in
let _ = dump_to_file outf html in
(outf, tit);;
let site =
let _ = print [ 'Loading site.xml ...\n' ] in
match load_xml "site.xml" with
| Site & <site>s ->
match load_include "site.xml" with
| [ Site & <site>s ] ->
let ts = map s with
| <page input=inf; output=outf>_ -> do_file(inf,outf)
| Page & p -> do_page p
| <external href=url; title=t>_ -> (url,<title>t) in
let _ = print [ 'Create plan... ' ] in
let plan = make_plan (ts @ [("plan.php", <title>"CDuce site")]) in
do_page(plan,"plan.php")
let _ = do_page plan in
[]
| _ -> raise "Invalid site.xml";;
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<site>
<page input="index.xml" output="index.php"/>
<include file="index.xml"/>
<external href="cgi-bin/cduce" title="CDuce prototype"/>
<page input="memento.xml" output="memento.php"/>
<page input="bench.xml" output="bench.php"/>
<page input="papers.xml" output="papers.php"/>
<page input="examples.xml" output="examples.php"/>
<page input="team.xml" output="team.php"/>
<include file="memento.xml"/>
<include file="bench.xml"/>
<include file="papers.xml"/>
<include file="examples.xml"/>
<include file="tutorial.xml"/>
<include file="team.xml"/>
</site>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<page output="team.php">
<title>CDuce team</title>
<banner> The CDuce team </banner>
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page output="tutorial.php">
<title>CDuce tutorial</title>
<banner> CDuce tutorial </banner>
<!-- ********* Left panel ********* -->
<navig>
<toc/>
<box>
<p>
This page is a step-by-step introduction to CDuce.
</p>
<ul>
<li><a href="/cgi-bin/cduce">Online demo</a></li>
<li><a href="/">Home page</a></li>
<li><a href="memento.php">Memento</a></li>
</ul>
</box>
</navig>
<!-- ********* Main panel ********* -->
<main>
<box title="Tutorial" link="tut">
<p>
<b>This tutorial is under construction !</b>
</p>
</box>
<box title="Starting with CDuce" link="starting">
<p>
Here is the CDuce syntax for XML documents.
</p>
<sample><![CDATA[
{{<language>}}[ {{<name>}}"CDuce" {{<url>}}"http://www.cduce.org/" ];;
]]></sample>
<p>
The hilighted parts are <em>tags</em>. Note that contrary to XML,
there is no end-tags for elements.
</p>
<sample><![CDATA[
let x = {{<a>[]}} in
let y = <a>[] in ...
]]></sample>
</box>
</main>
</page>
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