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) ...@@ -63,7 +63,7 @@ all.cmxa: $(XOBJECTS)
cduce: $(CDUCE) cduce: $(CDUCE)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(CDUCE) $(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(CDUCE)
toplevel: $(TOPLEVEL) toplevel.out: $(TOPLEVEL)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(TOPLEVEL) $(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(TOPLEVEL)
webiface: $(WEBIFACE) 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,19 +210,21 @@ let rec comp_fv s = ...@@ -210,19 +210,21 @@ let rec comp_fv s =
if List.memq s !comp_fv_seen then () if List.memq s !comp_fv_seen then ()
else ( else (
comp_fv_seen := s :: !comp_fv_seen; comp_fv_seen := s :: !comp_fv_seen;
(match s.descr' with match s.fv with
| `Alias (_,x) -> comp_fv x | Some fv -> comp_fv_res := List.rev_append fv !comp_fv_res
| `Or (s1,s2) | None ->
| `And (s1,s2,_) (match s.descr' with
| `Diff (s1,s2) | `Alias (_,x) -> comp_fv x
| `Times (s1,s2) | `Xml (s1,s2) | `Or (s1,s2)
| `Arrow (s1,s2) -> comp_fv s1; comp_fv s2 | `And (s1,s2,_)
| `Record (l,opt,s) -> comp_fv s | `Diff (s1,s2)
| `Type _ -> () | `Times (s1,s2) | `Xml (s1,s2)
| `Capture x | `Arrow (s1,s2) -> comp_fv s1; comp_fv s2
| `Constant (x,_) -> comp_fv_res := x :: !comp_fv_res); | `Record (l,opt,s) -> comp_fv s
if (!comp_fv_res = []) then s.fv <- Some []; | `Type _ -> ()
(* TODO: check that the above line is correct *) | `Capture x
| `Constant (x,_) -> comp_fv_res := x :: !comp_fv_res
)
) )
...@@ -253,7 +255,12 @@ let rec typ seen s : Types.descr = ...@@ -253,7 +255,12 @@ let rec typ seen s : Types.descr =
| `Xml (s1,s2) -> Types.xml (typ_node s1) (typ_node s2) | `Xml (s1,s2) -> Types.xml (typ_node s1) (typ_node s2)
| `Arrow (s1,s2) -> Types.arrow (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) | `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 = and typ_node s : Types.node =
match s.type_node with 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