Commit 35736e93 authored by Pietro Abate's avatar Pietro Abate

[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 081fd2b7
0.3.2+1 0.3.2+1
* Added char_of_int built_in function. * Added char_of_int built_in function.
* Now int_of also accepts octal binary and hexadecimals * Now int_of also accepts octal binary and hexadecimals
* Added split_atom, make_atom. Removed atom_of.
0.3.2 0.3.2
* Bug fix in configure * Bug fix in configure
......
...@@ -4,8 +4,9 @@ let eval = ref (fun ppf err s -> assert false) ...@@ -4,8 +4,9 @@ let eval = ref (fun ppf err s -> assert false)
(* Types *) (* Types *)
let stringn = Types.cons string
let namespaces = let namespaces =
Sequence.star (Types.times (Types.cons string) (Types.cons string)) Sequence.star (Types.times stringn stringn)
let types = let types =
[ [
...@@ -249,11 +250,35 @@ unary_op_warning "int_of" ...@@ -249,11 +250,35 @@ unary_op_warning "int_of"
(* modified to allow 0x 0b 0o notations *) (* modified to allow 0x 0b 0o notations *)
(*
register_fun "atom_of" register_fun "atom_of"
string atom string atom
(fun v -> (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));; 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" binary_op_warning2 "dump_to_file"
string_latin1 string string_latin1 nil string_latin1 string string_latin1 nil
......
...@@ -611,11 +611,13 @@ using the same pretty-printing function as the CDuce interpreter itself. ...@@ -611,11 +611,13 @@ using the same pretty-printing function as the CDuce interpreter itself.
</section> </section>
<section title="Creating atoms from strings"> <section title="Creating and decomposing atoms from strings">
<p> <p>
The operator <code>atom_of</code> converts a string to an atom. The built-in functions <code>split_atom: Atom ->
E.g.: <code>atom_of "x"</code> evaluates to <code>`x</code> (String,String)</code> and <code>make_atom: (String,String) ->
Atom</code> converts between atoms and pair of strings
(namespace,local name).
</p> </p>
</section> </section>
......
...@@ -57,7 +57,8 @@ _" character, starting by a capitalized letter or underscore.</li> ...@@ -57,7 +57,8 @@ _" character, starting by a capitalized letter or underscore.</li>
<ul> <ul>
<li>Values: <code>`A, `B, `a, `b, `true, `false, ...</code> </li> <li>Values: <code>`A, `B, `a, `b, `true, `false, ...</code> </li>
<li>Types: singletons <code>`A, `B, ...</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> <li>CDuce also supports <local href="namespaces">XML Namespaces</local></li>
</ul> </ul>
</li> </li>
......
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