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
07e16909
Commit
07e16909
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2005-05-27 16:14:07 by afrisch] split_atom, make_atom
Original author: afrisch Date: 2005-05-27 16:14:07+00:00
parent
e75ef6c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
07e16909
0.3.2+1
* Added char_of_int built_in function.
* Now int_of also accepts octal binary and hexadecimals
* Added split_atom, make_atom. Removed atom_of.
0.3.2
* Bug fix in configure
...
...
types/builtin.ml
View file @
07e16909
...
...
@@ -4,8 +4,9 @@ let eval = ref (fun ppf err s -> assert false)
(* Types *)
let
stringn
=
Types
.
cons
string
let
namespaces
=
Sequence
.
star
(
Types
.
times
(
Types
.
cons
string
)
(
Types
.
cons
string
)
)
Sequence
.
star
(
Types
.
times
stringn
string
n
)
let
types
=
[
...
...
@@ -249,11 +250,35 @@ unary_op_warning "int_of"
(* modified to allow 0x 0b 0o notations *)
(*
register_fun "atom_of"
string atom
(fun v ->
let
(
s
,_
)
=
Value
.
get_string_utf8
v
in
(* TODO: check that s is a correct Name wrt XML *)
let (s,_) = Value.get_string_utf8 v in
Value.Atom (Atoms.V.mk Ns.empty s));;
*)
register_fun
"split_atom"
atom
(
Types
.
times
stringn
stringn
)
(
function
|
Value
.
Atom
v
->
let
(
ns
,
l
)
=
Atoms
.
V
.
value
v
in
Value
.
Pair
(
Value
.
string_utf8
(
Ns
.
value
ns
)
,
Value
.
string_utf8
l
)
|
_
->
assert
false
);;
register_fun
"make_atom"
(
Types
.
times
stringn
stringn
)
atom
(
fun
v
->
let
v1
,
v2
=
Value
.
get_pair
v
in
let
ns
,_
=
Value
.
get_string_utf8
v1
in
let
l
,_
=
Value
.
get_string_utf8
v2
in
(* TODO: check that l is a correct Name wrt XML *)
Value
.
Atom
(
Atoms
.
V
.
mk
(
Ns
.
mk
ns
)
l
));;
binary_op_warning2
"dump_to_file"
string_latin1
string
string_latin1
nil
...
...
web/manual/expressions.xml
View file @
07e16909
...
...
@@ -611,11 +611,13 @@ using the same pretty-printing function as the CDuce interpreter itself.
</section>
<section
title=
"Creating atoms from strings"
>
<section
title=
"Creating
and decomposing
atoms from strings"
>
<p>
The operator
<code>
atom_of
</code>
converts a string to an atom.
E.g.:
<code>
atom_of "x"
</code>
evaluates to
<code>
`x
</code>
The built-in functions
<code>
split_atom: Atom ->
(String,String)
</code>
and
<code>
make_atom: (String,String) ->
Atom
</code>
converts between atoms and pair of strings
(namespace,local name).
</p>
</section>
...
...
web/memento.xml
View file @
07e16909
...
...
@@ -57,7 +57,8 @@ _" character, starting by a capitalized letter or underscore.</li>
<ul>
<li>
Values:
<code>
`A, `B, `a, `b, `true, `false, ...
</code>
</li>
<li>
Types: singletons
<code>
`A, `B, ...
</code>
</li>
<li>
Operators:
<code>
atom_of
</code>
: String -> Atom
</li>
<li>
Operators:
<code>
make_atom
</code>
: (String,String) -> Atom,
<code>
split_atom
</code>
: Atom -> (String,String)
</li>
<li>
CDuce also supports
<local
href=
"namespaces"
>
XML Namespaces
</local></li>
</ul>
</li>
...
...
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