Commit a67a5785 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-11-08 13:43:23 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-08 13:43:23+00:00
parent ff2205f9
......@@ -26,4 +26,4 @@ let base : Person =
]
]
]
in sort base;;
in sort 3;;
type Company = <company>[ Worker* ];;
type Worker = <worker>[Surname Name Salary];;
type Surname = <surname>String;;
type Surname = <surname>[PCDATA];;
type Name = <name>String;;
type Salary = <salary>[Int];;
type PlusQueMoi = <salary>[5000--10000000];;
type PlusQueMoi = <salary>[5000--*];;
let my_company : Company =
<company>[
......@@ -31,7 +31,9 @@ let q1 =
let q2 =
let <company>[(x::<worker>[ Any Any PlusQueMoi ] | _)*] = my_company in
map x with <worker>[x y z ] -> <worker>[x y] in
let <company>[(x::<worker>[ _ _ <salary>[ 1800 ] ] | _)*] = my_company in
map x with <worker>[x y z ] -> <worker>[x y] in
(q1,q2);;
q2;;
......@@ -19,7 +19,7 @@ let empty_buf buf =
the prompt :-> at the first line *)
let first_line = ref true
let got_eof = ref false;;
let got_eof = ref false
let refill_buf buffer len =
......@@ -48,15 +48,15 @@ let refill_buf buffer len =
(* The function scan takes a linebuffer buffer
and returns a function fomr the current stream count to a char
option that is used to create the Stream
and returns a function (from the current stream count
to a char option) that is used to create the Stream
*)
let rec scan line_buf count =
let element = count-(line_buf.abs_pos) in
if element < line_buf.length-1 then (* send to stream the character *)
if element < line_buf.length-1 then (* send to stream the character *)
Some line_buf.buffer.[element]
else ( (* read another line*)
else ( (* read another line*)
line_buf.abs_pos <- (line_buf.abs_pos) + line_buf.length;
line_buf.length <- refill_buf line_buf.buffer line_buf.maxlength;
scan line_buf count)
......@@ -85,7 +85,29 @@ let loop =
done
(* THE REAL LOOP
(* JUST FOR TESTING 2 *)
let loop =
fprintf stdout " CDuce version 0.2a1\n\n";
let line_buffer =
{ buffer = " ";
length = 0;
abs_pos = 0;
maxlength = 60;
} in
let input = Stream.from (scan line_buffer) in
Sys.catch_break true;
while true do
empty_buf line_buffer;
first_line := true;
try Parser.prog input
with
| Stdpp.Exc_located (loc, e) -> raise (Location (loc, e))
done
(* THE REAL LOOP
let loop ppf =
fprintf ppf " CDuce version 0.2a1";
(*
......@@ -103,13 +125,16 @@ let loop ppf =
try
empty_buf line_buffer;
first_line := true;
let
try Parser.prog input
with
| Stdpp.Exc_located (loc, e) -> raise (Location (loc, e))
(*
while not lexed ";;"
Parse and catch ";;" to end inner loop
update_toplevel_env(????)
print type line
print execution line
*)
with
| End_of_file -> exit 0
| Sys.Break -> fprintf ppf "Interrupted.@."
......
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