Commit 7eefc5b0 authored by Pietro Abate's avatar Pietro Abate

[r2002-11-11 18:55:45 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-11 18:55:45+00:00
parent a9b124b5
......@@ -63,7 +63,7 @@ all.cmxa: $(XOBJECTS)
cduce: $(CDUCE)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(CDUCE)
toplevel: $(TOPLEVEL)
toplevel.out: $(TOPLEVEL)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(TOPLEVEL)
webiface: $(WEBIFACE)
......
type Doc = <doc>Text;;
type Text = [ (Char | (Letter+ ' '* Note))* ];;
type Letter = 'a'--'z' | 'A'--'Z';;
type Note = <note>[ PCDATA ];;
type Flow = [ (Char | <ref no=Int>[ PCDATA ])* ];;
type Notes = [ <note no=Int>[ PCDATA ]* ];;
type Result = <doc>[ <body>Flow <notes>Notes ];;
let fun format (<doc>s : Doc) : Result =
let (body,notes) = text (s,1) in
<doc>[ <body>body <notes>notes ];;
let fun text ( (Text,Int) -> (Flow,Notes) )
| ([ pre::Char*? (word::Letter+ ' '* <note>n); rem ], count) ->
let (body,notes) = text (rem, count + 1) in
(pre @ [<ref no=count>word] @ body,
[<note no=count>n] @ notes)
| (body,_) -> (body, []);;
match load_xml "tests/notes.xml" with
| x & Doc -> format x
| _ -> raise "Invalid input document";;
<doc>
CDuce <note>Frisch, Castagna, Benzaken</note> is
an XML <note>a W3C standard</note>-friendly programming language.
</doc>
\ No newline at end of file
......@@ -210,6 +210,9 @@ let rec comp_fv s =
if List.memq s !comp_fv_seen then ()
else (
comp_fv_seen := s :: !comp_fv_seen;
match s.fv with
| Some fv -> comp_fv_res := List.rev_append fv !comp_fv_res
| None ->
(match s.descr' with
| `Alias (_,x) -> comp_fv x
| `Or (s1,s2)
......@@ -220,9 +223,8 @@ let rec comp_fv s =
| `Record (l,opt,s) -> comp_fv s
| `Type _ -> ()
| `Capture x
| `Constant (x,_) -> comp_fv_res := x :: !comp_fv_res);
if (!comp_fv_res = []) then s.fv <- Some [];
(* TODO: check that the above line is correct *)
| `Constant (x,_) -> comp_fv_res := x :: !comp_fv_res
)
)
......@@ -253,7 +255,12 @@ let rec typ seen s : Types.descr =
| `Xml (s1,s2) -> Types.xml (typ_node s1) (typ_node s2)
| `Arrow (s1,s2) -> Types.arrow (typ_node s1) (typ_node s2)
| `Record (l,o,s) -> Types.record l o (typ_node s)
| `Capture _ | `Constant _ -> assert false
| `Capture x -> failwith ("bla1:" ^ x)
| `Constant (x,_) ->
(match s.fv with
| Some fv ->
List.iter (fun y -> Printf.eprintf "+++%s++++\n" y) fv);
failwith ("bla:" ^ x); assert false
and typ_node s : Types.node =
match s.type_node with
......
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