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
* Added char_of_int built_in function.
* Now int_of also accepts octal binary and hexadecimals
* Added split_atom, make_atom. Removed atom_of.
* Bug fix in configure
......@@ -4,8 +4,9 @@ let eval = ref (fun ppf err s -> assert false)
(* Types *)
let stringn = Types.cons string
let namespaces = (Types.times (Types.cons string) (Types.cons string)) (Types.times stringn stringn)
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 ( Ns.empty s));;
register_fun "split_atom"
atom (Types.times stringn stringn)
| Value.Atom v ->
let (ns,l) = Atoms.V.value v in
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 ( ( ns) l));;
binary_op_warning2 "dump_to_file"
string_latin1 string string_latin1 nil
......@@ -611,11 +611,13 @@ using the same pretty-printing function as the CDuce interpreter itself.
<section title="Creating atoms from strings">
<section title="Creating and decomposing atoms from strings">
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).
......@@ -57,7 +57,8 @@ _" character, starting by a capitalized letter or underscore.</li>
<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>
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