Skip to content
GitLab
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
00fb8d55
Commit
00fb8d55
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2005-03-06 16:46:10 by afrisch] Doc
Original author: afrisch Date: 2005-03-06 16:46:11+00:00
parent
00a7791a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Makefile.distrib
View file @
00fb8d55
...
...
@@ -288,6 +288,7 @@ clean:
rm
-f
web/www/
*
.html web/
*
~
rm
-f
web/
*
.cdo
rm
-f
configure.log
rm
-rf
web/doc
distclean
:
clean
rm
-f
Makefile.conf
...
...
parser/ulexer.ml
View file @
00fb8d55
...
...
@@ -74,7 +74,7 @@ let rec token = lexer
return
lexbuf
(
"INT"
,
L
.
utf8_lexeme
lexbuf
)
|
[
"<>=.,:;+-*/@&{}[]()|?`!"
]
|
"->"
|
"::"
|
";;"
|
"--"
|
"//"
|
"/@"
|
":="
|
"
\\
"
|
"++"
|
"{|"
|
"|}"
|
"<="
|
">="
|
"<<"
|
">>"
|
"||"
|
"&&"
|
"**"
|
"<="
|
">="
|
"<<"
|
">>"
|
"||"
|
"&&"
|
"**"
|
".."
|
[
"?+*"
]
"?"
|
"#"
->
return
lexbuf
(
""
,
L
.
utf8_lexeme
lexbuf
)
...
...
schema/schema_builtin.ml
View file @
00fb8d55
...
...
@@ -85,7 +85,7 @@ let time_kind kind = (qualify "time_kind", Value.Atom (Atoms.V.mk_ascii kind))
(* TODO the constraint that at least one part should be present isn't easily
expressible with CDuce types *)
let
duration_type
=
Types
.
rec_of_list
'
[
let
duration_type
=
Types
.
rec_of_list
false
[
time_kind_field
;
positive_field
;
true
,
qualify
"year"
,
Builtin_defs
.
int
;
...
...
@@ -95,23 +95,23 @@ let duration_type = Types.rec_of_list' [
true
,
qualify
"minute"
,
Builtin_defs
.
int
;
true
,
qualify
"second"
,
Builtin_defs
.
int
;
(* TODO this should be a decimal *)
]
let
timezone_type
=
Types
.
rec_of_list
'
[
let
timezone_type
=
Types
.
rec_of_list
false
[
positive_field
;
hour_field
;
minute_field
]
let
timezone_type_fields
=
[
true
,
qualify
"timezone"
,
timezone_type
]
let
time_type
=
Types
.
rec_of_list
'
(
time_kind_field
::
time_type_fields
@
timezone_type_fields
)
let
date_type
=
Types
.
rec_of_list
'
(
time_kind_field
::
positive_field
::
date_type_fields
)
let
time_type
=
Types
.
rec_of_list
false
(
time_kind_field
::
time_type_fields
@
timezone_type_fields
)
let
date_type
=
Types
.
rec_of_list
false
(
time_kind_field
::
positive_field
::
date_type_fields
)
let
dateTime_type
=
Types
.
rec_of_list
'
(
time_kind_field
::
positive_field
::
Types
.
rec_of_list
false
(
time_kind_field
::
positive_field
::
(
date_type_fields
@
time_type_fields
@
timezone_type_fields
))
let
gYearMonth_type
=
Types
.
rec_of_list
'
[
let
gYearMonth_type
=
Types
.
rec_of_list
false
[
positive_field
;
time_kind_field
;
year_field
;
month_field
]
let
gYear_type
=
Types
.
rec_of_list
'
[
time_kind_field
;
positive_field
;
year_field
]
let
gMonthDay_type
=
Types
.
rec_of_list
'
[
time_kind_field
;
month_field
;
day_field
]
let
gDay_type
=
Types
.
rec_of_list
'
[
time_kind_field
;
day_field
]
let
gMonth_type
=
Types
.
rec_of_list
'
[
time_kind_field
;
month_field
]
let
gYear_type
=
Types
.
rec_of_list
false
[
time_kind_field
;
positive_field
;
year_field
]
let
gMonthDay_type
=
Types
.
rec_of_list
false
[
time_kind_field
;
month_field
;
day_field
]
let
gDay_type
=
Types
.
rec_of_list
false
[
time_kind_field
;
day_field
]
let
gMonth_type
=
Types
.
rec_of_list
false
[
time_kind_field
;
month_field
]
let
nonPositiveInteger_type
=
Builtin_defs
.
non_pos_int
let
negativeInteger_type
=
Builtin_defs
.
neg_int
let
nonNegativeInteger_type
=
Builtin_defs
.
non_neg_int
...
...
types/types.ml
View file @
00fb8d55
...
...
@@ -1218,7 +1218,7 @@ struct
TR
.
pi2_restricted
t
(
split
d
l
)
(* TODO: eliminate this cap ... (record l absent_node) when
not necessary. eg. {
|
.....
|
} \ l *)
not necessary. eg. { ..... } \ l *)
let
remove_field
d
l
=
cap
(
TR
.
pi2
(
split
d
l
))
(
record
l
absent_node
)
...
...
@@ -1903,44 +1903,25 @@ module Char = struct
let
any
=
{
empty
with
hash
=
0
;
chars
=
any
.
chars
}
end
(* <helpers> *)
let
rec
tuple
=
function
|
[
t1
;
t2
]
->
times
t1
t2
|
t
::
tl
->
times
t
(
cons
(
tuple
tl
))
|
_
->
assert
false
let
choice_of_list
=
List
.
fold_left
cup
empty
let
xml'
tag
attrs
cont
=
xml
(
cons
tag
)
(
cons
(
times
(
cons
attrs
)
(
cons
cont
)))
let
rec_of_list
?
(
opened
=
true
)
l
=
let
map
=
List
.
fold_left
(
fun
acc
(
qname
,
typ
)
->
LabelMap
.
union_disj
acc
(
LabelMap
.
singleton
(
LabelPool
.
mk
qname
)
(
cons
typ
)))
LabelMap
.
empty
l
in
record'
(
opened
,
map
)
let
rec_of_list'
?
(
opened
=
true
)
l
=
let
map
=
List
.
fold_left
(
fun
acc
(
opt
,
qname
,
typ
)
->
LabelMap
.
union_disj
acc
(
LabelMap
.
singleton
(
LabelPool
.
mk
qname
)
(
if
opt
then
cons
(
Record
.
or_absent
typ
)
else
(
cons
typ
))))
LabelMap
.
empty
l
let
rec_of_list
o
l
=
let
map
=
LabelMap
.
from_list
(
fun
_
_
->
assert
false
)
(
List
.
map
(
fun
(
opt
,
qname
,
typ
)
->
LabelPool
.
mk
qname
,
cons
(
if
opt
then
Record
.
or_absent
typ
else
typ
))
l
)
in
record'
(
o
pened
,
map
)
record'
(
o
,
map
)
let
empty_closed_record
=
rec_of_list
~
opened
:
false
[]
let
empty_open
ed
_record
=
rec_of_list
~
opened
:
true
[]
let
empty_closed_record
=
rec_of_list
false
[]
let
empty_open_record
=
rec_of_list
true
[]
(* </helpers> *)
let
cond_partition
univ
qs
=
let
rec
add
accu
(
t
,
s
)
=
...
...
types/types.mli
View file @
00fb8d55
...
...
@@ -96,23 +96,10 @@ val abstract : Abstract.t -> t
val
tuple
:
Node
.
t
list
->
t
(** given a list of descrs create an OR type including all descrs *)
val
choice_of_list
:
t
list
->
t
(** do it yourself: create an Xml type from three types (tag type, attribute
type, content type) *)
val
xml'
:
t
->
t
->
t
->
t
(** Build a record from a list of <name,t> pairs. Open defaults to true.
All specified fields are required. *)
val
rec_of_list
:
?
opened
:
bool
->
(
Ns
.
qname
*
t
)
list
->
t
(** Similiar to rec_of_list, the additional boolean value specify whether the
specified field is optional (true) or not (false. *)
val
rec_of_list'
:
?
opened
:
bool
->
(
bool
*
Ns
.
qname
*
t
)
list
->
t
val
rec_of_list
:
bool
->
(
bool
*
Ns
.
qname
*
t
)
list
->
t
val
empty_closed_record
:
t
val
empty_open
ed
_record
:
t
val
empty_open_record
:
t
(** Positive systems and least solutions **)
...
...
typing/typer.ml
View file @
00fb8d55
...
...
@@ -1834,7 +1834,7 @@ module Schema_converter =
and
complex_type_def
nil
=
function
|
AnyType
->
itype
(
Types
.
times
(
Types
.
cons
Types
.
empty_open
ed
_record
)
(
Types
.
cons
Types
.
empty_open_record
)
(
Types
.
cons
xsd_any_type
))
|
Simple
st
->
let
nonnil
=
...
...
web/manual/expressions.xml
View file @
00fb8d55
...
...
@@ -672,7 +672,7 @@ channels and its exit code. The type for <code>system</code>
is:
</p>
<sample>
<![CDATA[
Latin1 ->
{
|
stdout = Latin1; stderr = Latin1;
Latin1 ->
{ stdout = Latin1; stderr = Latin1;
status = (`exited,Int) | (`stopped,Int) | (`signaled,Int) |}
]]>
</sample>
...
...
@@ -727,7 +727,7 @@ The construction <code>ref %%T%% %%e%%</code> is used to build a
<em>
reference
</em>
initialized with the result of the expression
<code>
%%e%%
</code>
; later, the reference can receive any value
of type
<code>
%%T%%
</code>
. The reference is actually a value of type
<code>
{
|
get = [] -> T ; set = T -> []
|
}
</code>
.
<code>
{ get = [] -> T ; set = T -> [] }
</code>
.
</p>
<p>
...
...
web/manual/interface.xml
View file @
00fb8d55
...
...
@@ -83,8 +83,8 @@ Polymorphic variant types are treated similarly.
<li>
A record type with a declaration
<code>
{ l1 : %%t%%1; ...; ln : %%t%%n
}
</code>
is translated to a closed record type
<code>
{
|
l1 = T(%%t%%1);
... ; ln = T(%%t%%n)
|
}
</code>
. Mutable fields are just copied.
}
</code>
is translated to a closed record type
<code>
{ l1 = T(%%t%%1);
... ; ln = T(%%t%%n) }
</code>
. Mutable fields are just copied.
</li>
<li>
...
...
@@ -160,7 +160,7 @@ The canonical translation is summarized in the following box:
<td><tt>
(`A, T(
<i>
t
</i>
)) | (`B, T(
<i>
s
</i>
)) | `C
</tt></td></tr>
<tr><td><tt>
{ x :
<i>
t
</i>
; y :
<i>
s
</i>
}
</tt></td>
<td><tt>
{
|
x = T(
<i>
t
</i>
); y = T(
<i>
s
</i>
)
|
}
</tt></td></tr>
<td><tt>
{ x = T(
<i>
t
</i>
); y = T(
<i>
s
</i>
) }
</tt></td></tr>
<tr><td><tt><i>
t
</i>
ref
</tt></td>
<td><tt>
ref T(
<i>
t
</i>
)
</tt></td></tr>
...
...
web/manual/schema.xml
View file @
00fb8d55
...
...
@@ -289,16 +289,16 @@ let is_valid_mail (Any -> Bool)
</p>
<sample>
<![CDATA[
# #print_type Mails.envelopeType;;
<(Any)
{| |}
>
[
<From
{|
|}
>
String
<To
{|
|}
>
String
<Date
{|
|}
>
{
<(Any)>
[
<From>
String
<To>
String
<Date>
{
positive = Bool;
year = Int; month = Int; day = Int;
hour = Int; minute = Int; second = Int;
timezone =? { positive = Bool; hour = Int; minute = Int }
}
<Subject
{|
|
}
>
String
<Subject
}
>
String
]
]]>
</sample>
</li>
...
...
@@ -339,7 +339,7 @@ let is_valid_mail (Any -> Bool)
</p>
<sample>
<![CDATA[
# #print_type Mails.header;;
<header
{|
name = String
|}
>
String
<header name = String>
String
]]>
</sample>
<p>
Note that the type of the element content
<em>
is not a sequence
</em>
...
...
@@ -349,7 +349,7 @@ let is_valid_mail (Any -> Bool)
</p>
<sample>
<![CDATA[
# #print_type Mails.Date;;
<Date
{| |}
>
{
<Date>
{
positive = Bool;
year = Int; month = Int; day = Int; hour = Int;
minute = Int; second = Int;
...
...
@@ -383,10 +383,10 @@ let is_valid_mail (Any -> Bool)
</p>
<sample>
# #print_type Mails.mimeTypeAttributes;;
{
|
type = [
{ type = [
'image' | 'text' | 'application' | 'audio' | 'message' | 'multipart' | 'video'
];
subtype = String
|
}
subtype = String }
</sample>
</li>
<li>
...
...
@@ -427,7 +427,7 @@ let is_valid_mail (Any -> Bool)
</p>
<sample>
<![CDATA[
# #print_type Mails.attachmentContent;;
[ X1 <content
{| |
}>
String | X1 ] where
[ X1 <content}>
String | X1 ] where
X1 =
<mimetype
S.mimeTypeAttributes
>
[ ]
]]>
</sample>
</li>
...
...
@@ -592,12 +592,11 @@ val xml : Any = <ignored_tag From="fake@microsoft.com">[
As an example:
</p>
<sample><![CDATA[
# let record = { name = "User-Agent"; added_by = "mutt" };;
val record : {| name = [ 'User-Agent' ]; added_by = [ 'mutt' ] |}
=
{ name="User-Agent"; added_by="mutt" }
# let record = { name = "User-Agent" added_by = "mutt" };;
val record : { name = [ 'User-Agent' ] added_by = [ 'mutt' ] }
= { name="User-Agent" added_by="mutt" }
# validate record with Mails.name ;;
- : { name = String } = { name="User-Agent"
;
added_by="mutt" }
- : { name = String } = { name="User-Agent" added_by="mutt" }
]]></sample>
</li>
-->
...
...
@@ -616,11 +615,11 @@ val xml : Any = <ignored_tag From="fake@microsoft.com">[
<sample>
<![CDATA[
# let record = { type = "image"; subtype = "png" };;
val record :
{
|
type = [ 'image' ]
;
subtype = [ 'png' ]
|
} =
{ type="image"
;
subtype="png" }
{ type = [ 'image' ] subtype = [ 'png' ] } =
{ type="image" subtype="png" }
# validate record with Mails.mimeTypeAttributes ;;
- : {
|
type = [ 'image' | 'text' | ... ]
;
subtype = String
|
} =
{ type="image"
;
subtype="png" }
- : { type = [ 'image' | 'text' | ... ] subtype = String } =
{ type="image" subtype="png" }
]]>
</sample>
</li>
</ul>
...
...
web/memento.xml
View file @
00fb8d55
...
...
@@ -72,9 +72,9 @@ _" character, starting by a capitalized letter or underscore.</li>
<br/><code>
int_of
</code>
: String -> Int,
<br/><code>
string_of
</code>
: Any -> Latin1,
<br/><code>
atom_of
</code>
: String -> Atom,
<br/><code>
system
</code>
: Latin1 -> {
|
stdout = Latin1; stderr = Latin1;
<br/><code>
system
</code>
: Latin1 -> { stdout = Latin1; stderr = Latin1;
status = (`exited,Int) | (`stopped,Int) | (`signaled,Int)
|
},
},
<br/><code>
exit
</code>
: 0--255 -> Empty,
<br/><code>
getenv
</code>
: Latin1 -> Latin1,
<br/><code>
argv
</code>
: [] -> [ String* ],
...
...
@@ -135,16 +135,15 @@ _" character, starting by a capitalized letter or underscore.</li>
<box
title=
"Record"
link=
"record"
>
<ul>
<li>
Records literal
<code>
{ l1 = e1; ...; ln = en }
</code></li>
<li>
Types:
<code>
{
|
l1 = t1; ...; ln = tn
|
}
</code>
(closed, no more
fields allowed),
<code>
>{ l1 = t1; ...; ln = tn }
</code>
(open,
<li>
Types:
<code>
{ l1 = t1; ...; ln = tn }
</code>
(closed, no more
fields allowed),
<code>
>{ l1 = t1; ...; ln = tn
; ..
}
</code>
(open,
any other field allowed). Optional fields:
<code>
li =? ti
</code>
instead of
<code>
li = ti
</code>
.
</li>
instead of
<code>
li = ti
</code>
.
Semi-colons are optional.
</li>
<li>
Record concatenation:
<code>
e1 + e2
</code>
(priority to the fields from the right argument)
</li>
<li>
Field removal:
<code>
e1 \ l
</code>
(does nothing if the
field
<code>
l
</code>
is not present)
</li>
<li>
Field access:
<code>
e1 . l
</code></li>
<li>
Record:
<code>
{ l1 = p1; ...; ln = pn }
</code></li>
<li>
Field access:
<code>
e1.l
</code></li>
<li>
Labels are in fact Qualified Names (see
<local
href=
"namespaces"
/>
)
</li>
</ul>
</box>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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