Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
e3c65a06
Commit
e3c65a06
authored
Jul 10, 2007
by
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
692deac3
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests/overloading.cd
View file @
e3c65a06
...
@@ -26,4 +26,4 @@ let base : Person =
...
@@ -26,4 +26,4 @@ let base : Person =
]
]
]
]
]
]
in sort
base
;;
in sort
3
;;
tests/security.cd
View file @
e3c65a06
type Company = <company>[ Worker* ];;
type Company = <company>[ Worker* ];;
type Worker = <worker>[Surname Name Salary];;
type Worker = <worker>[Surname Name Salary];;
type Surname = <surname>
String
;;
type Surname = <surname>
[PCDATA]
;;
type Name = <name>String;;
type Name = <name>String;;
type Salary = <salary>[Int];;
type Salary = <salary>[Int];;
type PlusQueMoi = <salary>[5000--
10000000
];;
type PlusQueMoi = <salary>[5000--
*
];;
let my_company : Company =
let my_company : Company =
<company>[
<company>[
...
@@ -31,7 +31,9 @@ let q1 =
...
@@ -31,7 +31,9 @@ let q1 =
let q2 =
let q2 =
let <company>[(x::<worker>[
Any Any PlusQueMoi
] | _)*] = my_company in
let <company>[(x::<worker>[
_ _ <salary>[ 1800 ]
] | _)*] = my_company in
map x with <worker>[x y z ] -> <worker>[x y] in
map x with <worker>[x y z ] -> <worker>[x y] in
(q1,q2);;
q2;;
toplevel/toploop.ml
View file @
e3c65a06
...
@@ -19,7 +19,7 @@ let empty_buf buf =
...
@@ -19,7 +19,7 @@ let empty_buf buf =
the prompt :-> at the first line *)
the prompt :-> at the first line *)
let
first_line
=
ref
true
let
first_line
=
ref
true
let
got_eof
=
ref
false
;;
let
got_eof
=
ref
false
let
refill_buf
buffer
len
=
let
refill_buf
buffer
len
=
...
@@ -48,15 +48,15 @@ let refill_buf buffer len =
...
@@ -48,15 +48,15 @@ let refill_buf buffer len =
(* The function scan takes a linebuffer buffer
(* The function scan takes a linebuffer buffer
and returns a function
f
om
r
the current stream count
to a char
and returns a function
(fr
om the current stream count
option that is used to create the Stream
to a char
option
)
that is used to create the Stream
*)
*)
let
rec
scan
line_buf
count
=
let
rec
scan
line_buf
count
=
let
element
=
count
-
(
line_buf
.
abs_pos
)
in
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
]
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
.
abs_pos
<-
(
line_buf
.
abs_pos
)
+
line_buf
.
length
;
line_buf
.
length
<-
refill_buf
line_buf
.
buffer
line_buf
.
maxlength
;
line_buf
.
length
<-
refill_buf
line_buf
.
buffer
line_buf
.
maxlength
;
scan
line_buf
count
)
scan
line_buf
count
)
...
@@ -85,7 +85,29 @@ let loop =
...
@@ -85,7 +85,29 @@ let loop =
done
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 =
let loop ppf =
fprintf ppf " CDuce version 0.2a1";
fprintf ppf " CDuce version 0.2a1";
(*
(*
...
@@ -103,13 +125,16 @@ let loop ppf =
...
@@ -103,13 +125,16 @@ let loop ppf =
try
try
empty_buf line_buffer;
empty_buf line_buffer;
first_line := true;
first_line := true;
let
try Parser.prog input
with
| Stdpp.Exc_located (loc, e) -> raise (Location (loc, e))
(*
while not lexed ";;"
while not lexed ";;"
Parse and catch ";;" to end inner loop
Parse and catch ";;" to end inner loop
update_toplevel_env(????)
print type line
print type line
print execution line
print execution line
*)
with
with
| End_of_file -> exit 0
| End_of_file -> exit 0
| Sys.Break -> fprintf ppf "Interrupted.@."
| Sys.Break -> fprintf ppf "Interrupted.@."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment