Commit 86155dfc authored by Pietro Abate's avatar Pietro Abate

[r2003-07-02 18:05:03 by cvscast] Update manual for namespaces and bug fix...

[r2003-07-02 18:05:03 by cvscast] Update manual for namespaces and bug fix pretty printing p:* -- Alain

Original author: cvscast
Date: 2003-07-02 18:05:04+00:00
parent 60c7c7a4
......@@ -139,8 +139,8 @@ module Printer = struct
if (ns != empty) || (U.get_str pr <> "")
then p.prefixes <- (pr, ns) :: p.prefixes
let register_tag p (ns,_) =
ensure p ns;
let register_ns p ns =
ensure p ns;
match p.ns_to_prefix.(ns) with
| Hint l ->
let pr = find_good_prefix p ns l in
......@@ -148,6 +148,7 @@ module Printer = struct
add_prefix p pr ns
| Set _ -> ()
let register_tag p (ns,_) = register_ns p ns
let register_attr = register_tag
let prefixes p = p.prefixes
......@@ -169,6 +170,15 @@ module Printer = struct
if pr = "" then assert false
else pr ^ ":" ^ (U.get_str l)
| _ -> assert false
let any_ns p ns =
match p.ns_to_prefix.(ns) with
| Set pr ->
let pr = U.get_str pr in
if pr = "" then ".:*"
else pr ^ ":*"
| _ -> assert false
end
......@@ -179,8 +189,9 @@ struct
let set_table t =
p := Printer.printer t
let ns ns =
U.to_string (value ns)
let any_ns ns =
Printer.register_ns !p ns;
Printer.any_ns !p ns
let tag x =
Printer.register_tag !p x;
......
......@@ -49,7 +49,7 @@ end
module InternalPrinter : sig
val set_table: table -> unit
val ns: t -> string
val any_ns: t -> string
val tag: qname -> string
val attr: qname -> string
......
......@@ -27,9 +27,7 @@ let vprint ppf (ns,x) =
Format.fprintf ppf "%s" (Ns.InternalPrinter.tag (ns, Symbol.value x))
let print_any_in_ns ppf ns =
let ns = Ns.InternalPrinter.ns ns in
if ns = "" then Format.fprintf ppf ".:*"
else Format.fprintf ppf "%s:*" ns
Format.fprintf ppf "%s" (Ns.InternalPrinter.any_ns ns)
let print_v ppf a =
Format.fprintf ppf "`%a" vprint a
......
......@@ -9,6 +9,7 @@
<include file="memento.xml"/>
<include file="manual/types_patterns.xml"/>
<include file="manual/expressions.xml"/>
<include file="manual/namespaces.xml"/>
<box title="Table of Contents" link="toc">
......
......@@ -581,4 +581,22 @@ argument is the filename and the second one is the string to dump.
</box>
<box title="Namespaces" link="ns">
<p>
It is possible in expression position to define a local
prefix-namespace binding or to set a local default namespace.
</p>
<sample><![CDATA[
namespace %%p%% = "%%...%%" in %%e%%
namespace "%%...%%" in %%e%%
]]></sample>
<p>
See <local href="namespaces"/> for more details.
</p>
</box>
</page>
......@@ -157,8 +157,11 @@ you must quit the toplevel with <code>#quit</code>.
</p>
<p>
The topelevel directive <code>#env</code> prints the current
environment (that is, the set of defined global types and values).
The toplevel directive <code>#env</code> prints the current
environment: the set of defined global types and values, and also
the current sets of prefix-to-<local href="namespaces">namespace</local> bindings used
for parsing (as defined by the user) and
for pretty-printing (as computed by CDuce itself).
</p>
<p>
......
......@@ -188,6 +188,7 @@ integers, characters, and atoms. To each kind corresponds a family of types.
literal): atom singleton type.</li>
<li><code>Bool</code>: the two atoms <code>`true</code> and
<code>`false</code>.</li>
<li>See also: <local href="namespaces"/>.</li>
</ul>
</li>
</ul>
......@@ -366,7 +367,8 @@ must not), and double quotes must be.
<p>
Records are set of finite (name,value) bindings. They are used
in particular to represent XML attribute sets.
in particular to represent XML attribute sets. Names are
actually Qualified Names (see <local href="namespaces"/>).
</p>
<p>
......
......@@ -42,6 +42,7 @@ _" 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>CDuce also supports <local href="namespaces">XML Namespaces</local></li>
</ul>
</li>
</ul>
......@@ -123,6 +124,7 @@ instead of <code>li = ti</code>.</li>
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>Labels are in fact Qualified Names (see <local href="namespaces"/>)</li>
</ul>
</box>
......@@ -201,12 +203,20 @@ Tn = tn</code>.</li>
<box title="Toplevel statements" link="toplevel">
<ul>
<li>Global expression to evaluate.</li>
<li>Global let-binding.</li>
<li>Global function declaration.</li>
<li>Type declarations: <code>type T = t</code>.</li>
<li>Source inclusion: <code>include </code> <i> filename_string</i></li>
<li>Debug directives: <code>debug </code> <i> directive argument</i> <br/>
where <i> directive</i> is one of the following: <code>accept</code>,
<code>subtype</code>, <code>compile</code>.
<li>Global <local href="namespaces">namespace</local>:
<code>namespace p = "..."</code>,
<code>namespace "..."</code>.</li>
<li>Source inclusion: <code>include %%filename_string%%</code>.</li>
<li>Debug directives: <code>debug %%directive argument%%</code> <br/>
where <code>%%directive%%</code> is one of the following: <code>accept</code>,
<code>subtype</code>, <code>compile</code>, <code>sample</code>, <code>filter</code>.
</li>
<li>Toplevel directives: <code>#env</code>, <code>#quit</code>,
<code>#reinit_ns</code>.</li>
</ul>
</box>
......
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