) of
+ the keyword table. The default is __idx-odd__.
+
+ - string *class.keyword*
+
+ This variable contains the class name used to label the keyword cells/column
+ () in the keyword table of the document. The default is __idx-keyword__.
+
+ - string *class.refs*
+
+ This variable contains the class name used to label the reference
+ cells/column ( | ) in the keyword table of the document. The default is
+ __idx-refs__.
+
+ - string *class.footer*
+
+ This variable contains the class name for the footer 'ision of the
+ generated document. The default is __idx-footer__. This division contains a
+ browser-visible separator line and the user specified __footer__, if any.
+
+*Note* that this plugin ignores the standard configuration variable __format__,
+and its value.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[HTML](../../../../index.md#html), [doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [index](../../../../index.md#index),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_export_json.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_export_json.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_export_json.md
@@ -0,0 +1,250 @@
+
+[//000000001]: # (doctools::idx::export::json - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::export::json(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::export::json - JSON export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [JSON notation of keyword indices](#section3)
+
+ - [Configuration](#section4)
+
+ - [Keyword index serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::export::json ?0.1?
+package require textutil::adjust
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index export plugin for the
+generation of JSON markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::export](idx_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::export](idx_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a keyword index, as
+ specified in section [Keyword index serialization format](#section5), and
+ contained in *serial*, the *configuration*, a dictionary, and generates JSON
+ markup encoding the index. The created string is then returned as the result
+ of the command.
+
+# JSON notation of keyword indices
+
+The JSON format used for keyword indices is a direct translation of the [Keyword
+index serialization format](#section5), mapping Tcl dictionaries as JSON objects
+and Tcl lists as JSON arrays. For example, the Tcl serialization
+
+ doctools::idx {
+ label {Keyword Index}
+ keywords {
+ changelog {changelog.man cvs.man}
+ conversion {doctools.man docidx.man doctoc.man apps/dtplite.man mpexpand.man}
+ cvs cvs.man
+ }
+ references {
+ apps/dtplite.man {manpage dtplite}
+ changelog.man {manpage doctools::changelog}
+ cvs.man {manpage doctools::cvs}
+ docidx.man {manpage doctools::idx}
+ doctoc.man {manpage doctools::toc}
+ doctools.man {manpage doctools}
+ mpexpand.man {manpage mpexpand}
+ }
+ title {}
+ }
+
+is equivalent to the JSON string
+
+ {
+ "doctools::idx" : {
+ "label" : "Keyword Index",
+ "keywords" : {
+ "changelog" : ["changelog.man","cvs.man"],
+ "conversion" : ["doctools.man","docidx.man","doctoc.man","apps\/dtplite.man","mpexpand.man"],
+ "cvs" : ["cvs.man"],
+ },
+ "references" : {
+ "apps\/dtplite.man" : ["manpage","dtplite"],
+ "changelog.man" : ["manpage","doctools::changelog"],
+ "cvs.man" : ["manpage","doctools::cvs"],
+ "docidx.man" : ["manpage","doctools::idx"],
+ "doctoc.man" : ["manpage","doctools::toc"],
+ "doctools.man" : ["manpage","doctools"],
+ "mpexpand.man" : ["manpage","mpexpand"]
+ },
+ "title" : ""
+ }
+ }
+
+# Configuration
+
+The JSON export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - boolean *indented*
+
+ If this flag is set the plugin will break the generated JSON code across
+ lines and indent it according to its inner structure, with each key of a
+ dictionary on a separate line.
+
+ If this flag is not set (the default), the whole JSON object will be written
+ on a single line, with minimum spacing between all elements.
+
+ - boolean *aligned*
+
+ If this flag is set the generator ensures that the values for the keys in a
+ dictionary are vertically aligned with each other, for a nice table effect.
+ To make this work this also implies that __indented__ is set.
+
+ If this flag is not set (the default), the output is formatted as per the
+ value of __indented__, without trying to align the values for dictionary
+ keys.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__format__, __file__, and __map__ and their values.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[JSON](../../../../index.md#json), [doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [index](../../../../index.md#index),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_export_nroff.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_export_nroff.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_export_nroff.md
@@ -0,0 +1,206 @@
+
+[//000000001]: # (doctools::idx::export::nroff - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::export::nroff(n) 0.3 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::export::nroff - nroff export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Configuration](#section3)
+
+ - [Keyword index serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::export::nroff ?0.3?
+package require doctools::text
+package require doctools::nroff::man_macros
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index export plugin for the
+generation of nroff markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::export](idx_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::export](idx_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a keyword index, as
+ specified in section [Keyword index serialization format](#section4), and
+ contained in *serial*, the *configuration*, a dictionary, and generates
+ nroff markup encoding the index. The created string is then returned as the
+ result of the command.
+
+# Configuration
+
+The nroff export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - string *user*
+
+ This standard configuration variable contains the name of the user running
+ the process which invoked the export plugin. The plugin puts this
+ information into the provenance comment at the beginning of the generated
+ document.
+
+ - string *file*
+
+ This standard configuration variable contains the name of the file the index
+ came from. This variable may not be set or contain the empty string. The
+ plugin puts this information, if defined, i.e. set and not the empty string,
+ into the provenance comment at the beginning of the generated document.
+
+ - boolean *inline*
+
+ If this flag is set (default) the plugin will place the definitions of the
+ man macro set directly into the output.
+
+ If this flag is not set, the plugin will place a reference to the
+ definitions of the man macro set into the output, but not the macro
+ definitions themselves.
+
+*Note* that this plugin ignores the standard configuration variables __format__,
+and __map__, and their values.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [index](../../../../index.md#index),
+[nroff](../../../../index.md#nroff),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_export_text.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_export_text.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_export_text.md
@@ -0,0 +1,190 @@
+
+[//000000001]: # (doctools::idx::export::text - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::export::text(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::export::text - plain text export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Configuration](#section3)
+
+ - [Keyword index serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::export::text ?0.2?
+package require doctools::text
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index export plugin for the
+generation of plain text markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::export](idx_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::export](idx_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a keyword index, as
+ specified in section [Keyword index serialization format](#section4), and
+ contained in *serial*, the *configuration*, a dictionary, and generates
+ plain text markup encoding the index. The created string is then returned as
+ the result of the command.
+
+# Configuration
+
+The text export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - dictionary *map*
+
+ This standard configuration variable contains a dictionary mapping from the
+ symbolic files names in manpage references to the actual filenames and/or
+ urls to be used in the output.
+
+ Url references and symbolic file names without a mapping are used unchanged.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__file__, and __format__, and their values.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [index](../../../../index.md#index),
+[plain text](../../../../index.md#plain_text),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_export_wiki.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_export_wiki.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_export_wiki.md
@@ -0,0 +1,206 @@
+
+[//000000001]: # (doctools::idx::export::wiki - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::export::wiki(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::export::wiki - wiki export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Wiki markup](#section3)
+
+ - [Configuration](#section4)
+
+ - [Keyword index serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::export::wiki ?0.2?
+package require doctools::text
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index export plugin for the
+generation of wiki markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::export](idx_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::export](idx_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a keyword index, as
+ specified in section [Keyword index serialization format](#section5), and
+ contained in *serial*, the *configuration*, a dictionary, and generates wiki
+ markup encoding the index. The created string is then returned as the result
+ of the command.
+
+# Wiki markup
+
+The basic syntax of the wiki markup generated by this plugin are described at
+[http://wiki.tcl.tk/14](http://wiki.tcl.tk/14).
+
+The plugin goes beyond the classic markup to generate proper headers and either
+a table or indented list of the keywords and their references.
+
+# Configuration
+
+The wiki export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - dictionary *map*
+
+ This standard configuration variable contains a dictionary mapping from the
+ symbolic files names in manpage references to the actual filenames and/or
+ urls to be used in the output.
+
+ Url references and symbolic file names without a mapping are used unchanged.
+
+ - enum *style*
+
+ This variable recognizes two values as legal, __list__ (default), and
+ __table__. Depending on the value the plugin generates either a list- or
+ table-based wiki page for the index.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__file__ and __format__, and their values.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [index](../../../../index.md#index),
+[serialization](../../../../index.md#serialization),
+[wiki](../../../../index.md#wiki)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_import.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_import.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_import.md
@@ -0,0 +1,515 @@
+
+[//000000001]: # (doctools::idx::import - Documentation tools)
+[//000000002]: # (Generated from file 'idx_import.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::import(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::import - Importing keyword indices
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Concepts](#section2)
+
+ - [API](#section3)
+
+ - [Package commands](#subsection1)
+
+ - [Object command](#subsection2)
+
+ - [Object methods](#subsection3)
+
+ - [Import plugin API v2 reference](#section4)
+
+ - [Keyword index serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::idx::import ?0.2?
+package require Tcl 8.4
+package require doctools::config
+package require doctools::idx::structure
+package require snit
+package require pluginmgr
+
+[__::doctools::idx::import__ *objectName*](#1)
+[__objectName__ __method__ ?*arg arg ...*?](#2)
+[*objectName* __destroy__](#3)
+[*objectName* __import text__ *text* ?*format*?](#4)
+[*objectName* __import file__ *path* ?*format*?](#5)
+[*objectName* __import object text__ *object* *text* ?*format*?](#6)
+[*objectName* __import object file__ *object* *path* ?*format*?](#7)
+[*objectName* __config names__](#8)
+[*objectName* __config get__](#9)
+[*objectName* __config set__ *name* ?*value*?](#10)
+[*objectName* __config unset__ *pattern*...](#11)
+[*objectName* __includes__](#12)
+[*objectName* __include add__ *path*](#13)
+[*objectName* __include remove__ *path*](#14)
+[*objectName* __include clear__](#15)
+[__IncludeFile__ *currentfile* *path*](#16)
+[__[import](../../../../index.md#import)__ *text* *configuration*](#17)
+
+# DESCRIPTION
+
+This package provides a class to manage the plugins for the import of keyword
+indices from other formats, i.e. their conversion from, for example
+*[docidx](../../../../index.md#docidx)*, *[json](../../../../index.md#json)*,
+etc.
+
+This is one of the three public pillars the management of keyword indices
+resides on. The other two pillars are
+
+ 1. *[Exporting keyword indices](idx_export.md)*, and
+
+ 1. *[Holding keyword indices](idx_container.md)*
+
+For information about the [Concepts](#section2) of keyword indices, and their
+parts, see the same-named section. For information about the data structure
+which is the major output of the manager objects provided by this package see
+the section [Keyword index serialization format](#section5).
+
+The plugin system of our class is based on the package
+__[pluginmgr](../pluginmgr/pluginmgr.md)__, and configured to look for plugins
+using
+
+ 1. the environment variable __DOCTOOLS_IDX_IMPORT_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_IDX_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_PLUGINS__,
+
+ 1. the path "~/.doctools/idx/import/plugin"
+
+ 1. the path "~/.doctools/idx/plugin"
+
+ 1. the path "~/.doctools/plugin"
+
+ 1. the path "~/.doctools/idx/import/plugins"
+
+ 1. the path "~/.doctools/idx/plugins"
+
+ 1. the path "~/.doctools/plugins"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\IMPORT\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"
+
+The last three are used only when the package is run on a machine using
+Windows(tm) operating system.
+
+The whole system is delivered with two predefined import plugins, namely
+
+ - docidx
+
+ See *[docidx import plugin](import_docidx.md)* for details.
+
+ - json
+
+ See *json import plugin* for details.
+
+Readers wishing to write their own import plugin for some format, i.e. *plugin
+writer*s reading and understanding the section containing the [Import plugin API
+v2 reference](#section4) is an absolute necessity, as it specifies the
+interaction between this package and its plugins in detail.
+
+# Concepts
+
+ 1. A *[keyword index](../../../../index.md#keyword_index)* consists of a
+ (possibly empty) set of *[keywords](../../../../index.md#keywords)*.
+
+ 1. Each keyword in the set is identified by its name.
+
+ 1. Each keyword has a (possibly empty) set of *references*.
+
+ 1. A reference can be associated with more than one keyword.
+
+ 1. A reference not associated with at least one keyword is not possible
+ however.
+
+ 1. Each reference is identified by its target, specified as either an url or
+ symbolic filename, depending on the type of reference (__url__, or
+ __manpage__).
+
+ 1. The type of a reference (url, or manpage) depends only on the reference
+ itself, and not the keywords it is associated with.
+
+ 1. In addition to a type each reference has a descriptive label as well. This
+ label depends only on the reference itself, and not the keywords it is
+ associated with.
+
+A few notes
+
+ 1. Manpage references are intended to be used for references to the documents
+ the index is made for. Their target is a symbolic file name identifying the
+ document, and export plugins may replace symbolic with actual file names,
+ if specified.
+
+ 1. Url references are intended on the othre hand are inteded to be used for
+ links to anything else, like websites. Their target is an url.
+
+ 1. While url and manpage references share a namespace for their identifiers,
+ this should be no problem, given that manpage identifiers are symbolic
+ filenames and as such they should never look like urls, the identifiers for
+ url references.
+
+# API
+
+## Package commands
+
+ - __::doctools::idx::import__ *objectName*
+
+ This command creates a new import manager object with an associated Tcl
+ command whose name is *objectName*. This
+ *[object](../../../../index.md#object)* command is explained in full detail
+ in the sections [Object command](#subsection2) and [Object
+ methods](#subsection3). The object command will be created under the current
+ namespace if the *objectName* is not fully qualified, and in the specified
+ namespace otherwise.
+
+## Object command
+
+All objects created by the __::doctools::idx::import__ command have the
+following general form:
+
+ - __objectName__ __method__ ?*arg arg ...*?
+
+ The method __method__ and its *arg*'uments determine the exact behavior of
+ the command. See section [Object methods](#subsection3) for the detailed
+ specifications.
+
+## Object methods
+
+ - *objectName* __destroy__
+
+ This method destroys the object it is invoked for.
+
+ - *objectName* __import text__ *text* ?*format*?
+
+ This method takes the *text* and converts it from the specified *format* to
+ the canonical serialization of a keyword index using the import plugin for
+ the format. An error is thrown if no plugin could be found for the format.
+ The serialization generated by the conversion process is returned as the
+ result of this method.
+
+ If no format is specified the method defaults to __docidx__.
+
+ The specification of what a *canonical* serialization is can be found in the
+ section [Keyword index serialization format](#section5).
+
+ The plugin has to conform to the interface specified in section [Import
+ plugin API v2 reference](#section4).
+
+ - *objectName* __import file__ *path* ?*format*?
+
+ This method is a convenient wrapper around the __import text__ method
+ described by the previous item. It reads the contents of the specified file
+ into memory, feeds the result into __import text__ and returns the resulting
+ serialization as its own result.
+
+ - *objectName* __import object text__ *object* *text* ?*format*?
+
+ This method is a convenient wrapper around the __import text__ method
+ described by the previous item. It expects that *object* is an object
+ command supporting a __deserialize__ method expecting the canonical
+ serialization of a keyword index. It imports the text using __import text__
+ and then feeds the resulting serialization into the *object* via
+ __deserialize__. This method returns the empty string as it result.
+
+ - *objectName* __import object file__ *object* *path* ?*format*?
+
+ This method behaves like __import object text__, except that it reads the
+ text to convert from the specified file instead of being given it as
+ argument.
+
+ - *objectName* __config names__
+
+ This method returns a list containing the names of all configuration
+ variables currently known to the object.
+
+ - *objectName* __config get__
+
+ This method returns a dictionary containing the names and values of all
+ configuration variables currently known to the object.
+
+ - *objectName* __config set__ *name* ?*value*?
+
+ This method sets the configuration variable *name* to the specified *value*
+ and returns the new value of the variable.
+
+ If no value is specified it simply returns the current value, without
+ changing it.
+
+ Note that while the user can set the predefined configuration variables
+ __user__ and __format__ doing so will have no effect, these values will be
+ internally overridden when invoking an import plugin.
+
+ - *objectName* __config unset__ *pattern*...
+
+ This method unsets all configuration variables matching the specified glob
+ *pattern*s. If no pattern is specified it will unset all currently defined
+ configuration variables.
+
+ - *objectName* __includes__
+
+ This method returns a list containing the currently specified paths to use
+ to search for include files when processing input. The order of paths in the
+ list corresponds to the order in which they are used, from first to last,
+ and also corresponds to the order in which they were added to the object.
+
+ - *objectName* __include add__ *path*
+
+ This methods adds the specified *path* to the list of paths to use to search
+ for include files when processing input. The path is added to the end of the
+ list, causing it to be searched after all previously added paths. The result
+ of the command is the empty string.
+
+ The method does nothing if the path is already known.
+
+ - *objectName* __include remove__ *path*
+
+ This methods removes the specified *path* from the list of paths to use to
+ search for include files when processing input. The result of the command is
+ the empty string.
+
+ The method does nothing if the path is not known.
+
+ - *objectName* __include clear__
+
+ This method clears the list of paths to use to search for include files when
+ processing input. The result of the command is the empty string.
+
+# Import plugin API v2 reference
+
+Plugins are what this package uses to manage the support for any input format
+beyond the [Keyword index serialization format](#section5). Here we specify the
+API the objects created by this package use to interact with their plugins.
+
+A plugin for this package has to follow the rules listed below:
+
+ 1. A plugin is a package.
+
+ 1. The name of a plugin package has the form doctools::idx::import::__FOO__,
+ where __FOO__ is the name of the format the plugin will generate output
+ for. This name is also the argument to provide to the various __import__
+ methods of import manager objects to get a string encoding a keyword index
+ in that format.
+
+ 1. The plugin can expect that the package __doctools::idx::export::plugin__ is
+ present, as indicator that it was invoked from a genuine plugin manager.
+
+ 1. The plugin can expect that a command named __IncludeFile__ is present, with
+ the signature
+
+ - __IncludeFile__ *currentfile* *path*
+
+ This command has to be invoked by the plugin when it has to process an
+ included file, if the format has the concept of such. An example of
+ such a format would be *[docidx](../../../../index.md#docidx)*.
+
+ The plugin has to supply the following arguments
+
+ * string *currentfile*
+
+ The path of the file it is currently processing. This may be the
+ empty string if no such is known.
+
+ * string *path*
+
+ The path of the include file as specified in the include directive
+ being processed.
+
+ The result of the command will be a 5-element list containing
+
+ A boolean flag indicating the success (__True__) or failure (__False__)
+ of the operation.
+
+ In case of success the contents of the included file, and the empty
+ string otherwise.
+
+ The resolved, i.e. absolute path of the included file, if possible, or
+ the unchanged *path* argument. This is for display in an error message,
+ or as the *currentfile* argument of another call to __IncludeFile__
+ should this file contain more files.
+
+ In case of success an empty string, and for failure a code indicating
+ the reason for it, one of
+
+ * notfound
+
+ The specified file could not be found.
+
+ * notread
+
+ The specified file was found, but not be read into memory.
+
+ An empty string in case of success of a __notfound__ failure, and an
+ additional error message describing the reason for a __notread__ error
+ in more detail.
+
+ 1. A plugin has to provide one command, with the signature shown below.
+
+ - __[import](../../../../index.md#import)__ *text* *configuration*
+
+ Whenever an import manager of __[doctools::idx](idx_container.md)__ has
+ to parse input for an index it will invoke this command.
+
+ * string *text*
+
+ This argument will contain the text encoding the index per the
+ format the plugin is for.
+
+ * dictionary *configuration*
+
+ This argument will contain the current configuration to apply to
+ the parsing, as a dictionary mapping from variable names to values.
+
+ The following configuration variables have a predefined meaning all
+ plugins have to obey, although they can ignore this information at
+ their discretion. Any other other configuration variables
+ recognized by a plugin will be described in the manpage for that
+ plugin.
+
+ + user
+
+ This variable is expected to contain the name of the user
+ owning the process invoking the plugin.
+
+ + format
+
+ This variable is expected to contain the name of the format
+ whose plugin is invoked.
+
+ 1. A single usage cycle of a plugin consists of the invokations of the command
+ __[import](../../../../index.md#import)__. This call has to leave the
+ plugin in a state where another usage cycle can be run without problems.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[conversion](../../../../index.md#conversion),
+[docidx](../../../../index.md#docidx),
+[documentation](../../../../index.md#documentation),
+[import](../../../../index.md#import), [index](../../../../index.md#index),
+[json](../../../../index.md#json), [keyword
+index](../../../../index.md#keyword_index),
+[manpage](../../../../index.md#manpage), [markup](../../../../index.md#markup),
+[parsing](../../../../index.md#parsing), [plugin](../../../../index.md#plugin),
+[reference](../../../../index.md#reference), [url](../../../../index.md#url)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009-2018 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_import_json.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_import_json.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_import_json.md
@@ -0,0 +1,223 @@
+
+[//000000001]: # (doctools::idx::import::json - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::import::json(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::import::json - JSON import plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [JSON notation of keyword indices](#section3)
+
+ - [Keyword index serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::import::json ?0.1?
+package require doctools::idx::structure
+package require json
+
+[__[import](../../../../index.md#import)__ *string* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index import plugin for the parsing
+of JSON markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::import](idx_import.md)__, the import manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::import](idx_import.md)__ and the import manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+import plugin API version 2.
+
+ - __[import](../../../../index.md#import)__ *string* *configuration*
+
+ This command takes the *string* and parses it as JSON markup encoding a
+ keyword index, in the context of the specified *configuration* (a
+ dictionary). The result of the command is the canonical serialization of
+ that keyword index, in the form specified in section [Keyword index
+ serialization format](#section4).
+
+# JSON notation of keyword indices
+
+The JSON format used for keyword indices is a direct translation of the [Keyword
+index serialization format](#section4), mapping Tcl dictionaries as JSON objects
+and Tcl lists as JSON arrays. For example, the Tcl serialization
+
+ doctools::idx {
+ label {Keyword Index}
+ keywords {
+ changelog {changelog.man cvs.man}
+ conversion {doctools.man docidx.man doctoc.man apps/dtplite.man mpexpand.man}
+ cvs cvs.man
+ }
+ references {
+ apps/dtplite.man {manpage dtplite}
+ changelog.man {manpage doctools::changelog}
+ cvs.man {manpage doctools::cvs}
+ docidx.man {manpage doctools::idx}
+ doctoc.man {manpage doctools::toc}
+ doctools.man {manpage doctools}
+ mpexpand.man {manpage mpexpand}
+ }
+ title {}
+ }
+
+is equivalent to the JSON string
+
+ {
+ "doctools::idx" : {
+ "label" : "Keyword Index",
+ "keywords" : {
+ "changelog" : ["changelog.man","cvs.man"],
+ "conversion" : ["doctools.man","docidx.man","doctoc.man","apps\/dtplite.man","mpexpand.man"],
+ "cvs" : ["cvs.man"],
+ },
+ "references" : {
+ "apps\/dtplite.man" : ["manpage","dtplite"],
+ "changelog.man" : ["manpage","doctools::changelog"],
+ "cvs.man" : ["manpage","doctools::cvs"],
+ "docidx.man" : ["manpage","doctools::idx"],
+ "doctoc.man" : ["manpage","doctools::toc"],
+ "doctools.man" : ["manpage","doctools"],
+ "mpexpand.man" : ["manpage","mpexpand"]
+ },
+ "title" : ""
+ }
+ }
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[JSON](../../../../index.md#json),
+[deserialization](../../../../index.md#deserialization),
+[doctools](../../../../index.md#doctools),
+[import](../../../../index.md#import), [index](../../../../index.md#index)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_introduction.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_introduction.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_introduction.md
@@ -0,0 +1,194 @@
+
+[//000000001]: # (doctools2idx_introduction - Documentation tools)
+[//000000002]: # (Generated from file 'idx_introduction.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools2idx_introduction(n) 2.0 tcllib "Documentation tools")
+
+# NAME
+
+doctools2idx_introduction - DocTools - Keyword indices
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Description](#section1)
+
+ - [Related formats](#section2)
+
+ - [Package Overview](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# DESCRIPTION
+
+*[docidx](../../../../index.md#docidx)* (short for *documentation indices*)
+stands for a set of related, yet different, entities which are working together
+for the easy creation and transformation of keyword indices for documentation.
+
+These are
+
+ 1. A tcl based language for the semantic markup of a keyword index. Markup is
+ represented by Tcl commands. Beginners should start with the *[docidx
+ language introduction](../doctools/docidx_lang_intro.md)*. The formal
+ specification is split over two documents, one dealing with the *[docidx
+ language syntax](../doctools/docidx_lang_syntax.md)*, the other a *[docidx
+ language command reference](../doctools/docidx_lang_cmdref.md)*.
+
+ 1. A set of packages for the programmatic manipulation of keyword indices in
+ memory, and their conversion between various formats, reading and writing.
+ The aforementioned markup language is one of the formats which can be both
+ read from and written to.
+
+ 1. The system for the conversion of indices is based on a plugin mechanism,
+ for this we have two APIs describing the interface between the packages
+ above and the import/export plugins.
+
+Which of the more detailed documents are relevant to the reader of this
+introduction depends on their role in the documentation process.
+
+ 1. A *writer* of documentation has to understand the markup language itself. A
+ beginner to docidx should read the more informally written *[docidx
+ language introduction](../doctools/docidx_lang_intro.md)* first. Having
+ digested this the formal *[docidx language
+ syntax](../doctools/docidx_lang_syntax.md)* specification should become
+ understandable. A writer experienced with docidx may only need the *[docidx
+ language command reference](../doctools/docidx_lang_cmdref.md)* from time
+ to time to refresh her memory.
+
+ While a document is written the __dtp__ application can be used to validate
+ it, and after completion it also performs the conversion into the chosen
+ system of visual markup, be it *roff, HTML, plain text, wiki, etc. The
+ simpler __[dtplite](../../apps/dtplite.md)__ application makes internal use
+ of docidx when handling directories of documentation, automatically
+ generating a proper keyword index for them.
+
+ 1. A *processor* of documentation written in the
+ *[docidx](../../../../index.md#docidx)* markup language has to know which
+ tools are available for use.
+
+ The main tool is the aforementioned __dtp__ application provided by Tcllib.
+ The simpler __[dtplite](../../apps/dtplite.md)__ does not expose docidx to
+ the user. At the bottom level, common to both applications, however we find
+ the three packages providing the basic facilities to handle keyword
+ indices, i.e. import from textual formats, programmatic manipulation in
+ memory, and export to textual formats. These are
+
+ - __[doctools::idx](idx_container.md)__
+
+ Programmatic manipulation of keyword indices in memory.
+
+ - __[doctools::idx::import](idx_import.md)__
+
+ Import of keyword indices from various textual formats. The set of
+ supported formats is extensible through plugin packages.
+
+ - __[doctools::idx::export](idx_export.md)__
+
+ Export of keyword indices to various textual formats. The set of
+ supported formats is extensible through plugin packages.
+
+ See also section [Package Overview](#section3) for an overview of the
+ dependencies between these and other, supporting packages.
+
+ 1. At last, but not least, *plugin writers* have to understand the interaction
+ between the import and export packages and their plugins. These APIs are
+ described in the documentation for the two relevant packages, i.e.
+
+ - __[doctools::idx::import](idx_import.md)__
+
+ - __[doctools::idx::export](idx_export.md)__
+
+# Related formats
+
+The docidx format does not stand alone, it has two companion formats. These are
+called *[doctoc](../../../../index.md#doctoc)* and
+*[doctools](../../../../index.md#doctools)*, and they are intended for the
+markup of *tables of contents*, and of general documentation, respectively. They
+are described in their own sets of documents, starting at the *DocTools - Tables
+Of Contents* and the *DocTools - General*, respectively.
+
+# Package Overview
+
+ ~~~~~~~~~~~ doctools::idx ~~~~~~~~~~~
+ ~~ | ~~
+ doctools::idx::export ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~ doctools::idx::import
+ | | |
+ +---------------+-------------------------+ | +------------------+---------------+-----------------------+---------------+
+ | | | | | | | | |
+ doctools::config = | | | = doctools::include doctools::config doctools::paths
+ | | | | |
+ doctools::idx::export::<*> | | | doctools::idx::import::<*>
+ docidx | | | docidx, json
+ json | | | | \\
+ html | | | doctools::idx::parse \\
+ nroff | | | | \\
+ wiki | | | +---------------+ json
+ text | | | | |
+ doctools::idx::structure |
+ |
+ +-------+---------------+
+ | |
+ doctools::html doctools::html::cssdefaults doctools::tcl::parse doctools::msgcat
+ | |
+ doctools::text doctools::nroff::man_macros =
+ |
+ doctools::msgcat::idx::<*>
+ c, en, de, fr
+ (fr == en for now)
+ ~~ Interoperable objects, without actual package dependencies
+ -- Package dependency, higher requires lower package
+ = Dynamic dependency through plugin system
+ <*> Multiple packages following the given form of naming.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[docidx_intro](../doctools/docidx_intro.md),
+[doctoc_intro](../doctools/doctoc_intro.md),
+[doctools](../doctools/doctools.md), doctools2doc_introduction,
+[doctools2toc_introduction](../doctools2toc/toc_introduction.md),
+[doctools_lang_cmdref](../doctools/doctools_lang_cmdref.md),
+[doctools_lang_faq](../doctools/doctools_lang_faq.md),
+[doctools_lang_intro](../doctools/doctools_lang_intro.md),
+[doctools_lang_syntax](../doctools/doctools_lang_syntax.md),
+[doctools_plugin_apiref](../doctools/doctools_plugin_apiref.md)
+
+# KEYWORDS
+
+[conversion](../../../../index.md#conversion),
+[formatting](../../../../index.md#formatting),
+[index](../../../../index.md#index), [keyword
+index](../../../../index.md#keyword_index),
+[markup](../../../../index.md#markup), [parsing](../../../../index.md#parsing),
+[plugin](../../../../index.md#plugin), [semantic
+markup](../../../../index.md#semantic_markup)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_c.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_c.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_c.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::idx::c - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::idx::c(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::idx::c - Message catalog for the docidx parser (C)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::idx::c ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::idx::c__ is a support module providing the C
+language message catalog for the docidx parser in the doctools system version 2.
+As such it is an internal package a regular user (developer) should not be in
+direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[C](../../../../index.md#c), [catalog
+package](../../../../index.md#catalog_package),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_de.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_de.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_de.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::idx::de - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::idx::de(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::idx::de - Message catalog for the docidx parser (DE)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::idx::de ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::idx::de__ is a support module providing the DE
+(german) language message catalog for the docidx parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[DE](../../../../index.md#de), [catalog
+package](../../../../index.md#catalog_package),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_en.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_en.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_en.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::idx::en - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::idx::en(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::idx::en - Message catalog for the docidx parser (EN)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::idx::en ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::idx::en__ is a support module providing the EN
+(english) language message catalog for the docidx parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[EN](../../../../index.md#en), [catalog
+package](../../../../index.md#catalog_package),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_fr.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_fr.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_msgcat_fr.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::idx::fr - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::idx::fr(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::idx::fr - Message catalog for the docidx parser (FR)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::idx::fr ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::idx::fr__ is a support module providing the FR
+(french) language message catalog for the docidx parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[FR](../../../../index.md#fr), [catalog
+package](../../../../index.md#catalog_package),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_parse.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_parse.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_parse.md
@@ -0,0 +1,296 @@
+
+[//000000001]: # (doctools::idx::parse - Documentation tools)
+[//000000002]: # (Generated from file 'idx_parse.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::parse(n) 1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::parse - Parsing text in docidx format
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Parse errors](#section3)
+
+ - [[docidx] notation of keyword indices](#section4)
+
+ - [Keyword index serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::idx::parse ?0.1?
+package require Tcl 8.4
+package require doctools::idx::structure
+package require doctools::msgcat
+package require doctools::tcl::parse
+package require fileutil
+package require logger
+package require snit
+package require struct::list
+package require struct::stack
+
+[__::doctools::idx::parse__ __text__ *text*](#1)
+[__::doctools::idx::parse__ __file__ *path*](#2)
+[__::doctools::idx::parse__ __includes__](#3)
+[__::doctools::idx::parse__ __include add__ *path*](#4)
+[__::doctools::idx::parse__ __include remove__ *path*](#5)
+[__::doctools::idx::parse__ __include clear__](#6)
+[__::doctools::idx::parse__ __vars__](#7)
+[__::doctools::idx::parse__ __var set__ *name* *value*](#8)
+[__::doctools::idx::parse__ __var unset__ *name*](#9)
+[__::doctools::idx::parse__ __var clear__ ?*pattern*?](#10)
+
+# DESCRIPTION
+
+This package provides commands to parse text written in the
+*[docidx](../../../../index.md#docidx)* markup language and convert it into the
+canonical serialization of the keyword index encoded in the text. See the
+section [Keyword index serialization format](#section5) for specification of
+their format.
+
+This is an internal package of doctools, for use by the higher level packages
+handling *[docidx](../../../../index.md#docidx)* documents.
+
+# API
+
+ - __::doctools::idx::parse__ __text__ *text*
+
+ The command takes the string contained in *text* and parses it under the
+ assumption that it contains a document written using the
+ *[docidx](../../../../index.md#docidx)* markup language. An error is thrown
+ if this assumption is found to be false. The format of these errors is
+ described in section [Parse errors](#section3).
+
+ When successful the command returns the canonical serialization of the
+ keyword index which was encoded in the text. See the section [Keyword index
+ serialization format](#section5) for specification of that format.
+
+ - __::doctools::idx::parse__ __file__ *path*
+
+ The same as __text__, except that the text to parse is read from the file
+ specified by *path*.
+
+ - __::doctools::idx::parse__ __includes__
+
+ This method returns the current list of search paths used when looking for
+ include files.
+
+ - __::doctools::idx::parse__ __include add__ *path*
+
+ This method adds the *path* to the list of paths searched when looking for
+ an include file. The call is ignored if the path is already in the list of
+ paths. The method returns the empty string as its result.
+
+ - __::doctools::idx::parse__ __include remove__ *path*
+
+ This method removes the *path* from the list of paths searched when looking
+ for an include file. The call is ignored if the path is not contained in the
+ list of paths. The method returns the empty string as its result.
+
+ - __::doctools::idx::parse__ __include clear__
+
+ This method clears the list of search paths for include files.
+
+ - __::doctools::idx::parse__ __vars__
+
+ This method returns a dictionary containing the current set of predefined
+ variables known to the __vset__ markup command during processing.
+
+ - __::doctools::idx::parse__ __var set__ *name* *value*
+
+ This method adds the variable *name* to the set of predefined variables
+ known to the __vset__ markup command during processing, and gives it the
+ specified *value*. The method returns the empty string as its result.
+
+ - __::doctools::idx::parse__ __var unset__ *name*
+
+ This method removes the variable *name* from the set of predefined variables
+ known to the __vset__ markup command during processing. The method returns
+ the empty string as its result.
+
+ - __::doctools::idx::parse__ __var clear__ ?*pattern*?
+
+ This method removes all variables matching the *pattern* from the set of
+ predefined variables known to the __vset__ markup command during processing.
+ The method returns the empty string as its result.
+
+ The pattern matching is done with __string match__, and the default pattern
+ used when none is specified, is __*__.
+
+# Parse errors
+
+The format of the parse error messages thrown when encountering violations of
+the *[docidx](../../../../index.md#docidx)* markup syntax is human readable and
+not intended for processing by machines. As such it is not documented.
+
+*However*, the errorCode attached to the message is machine-readable and has the
+following format:
+
+ 1. The error code will be a list, each element describing a single error found
+ in the input. The list has at least one element, possibly more.
+
+ 1. Each error element will be a list containing six strings describing an
+ error in detail. The strings will be
+
+ 1) The path of the file the error occurred in. This may be empty.
+
+ 1) The range of the token the error was found at. This range is a
+ two-element list containing the offset of the first and last character
+ in the range, counted from the beginning of the input (file). Offsets
+ are counted from zero.
+
+ 1) The line the first character after the error is on. Lines are counted
+ from one.
+
+ 1) The column the first character after the error is at. Columns are
+ counted from zero.
+
+ 1) The message code of the error. This value can be used as argument to
+ __msgcat::mc__ to obtain a localized error message, assuming that the
+ application had a suitable call of __doctools::msgcat::init__ to
+ initialize the necessary message catalogs (See package
+ __[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__).
+
+ 1) A list of details for the error, like the markup command involved. In
+ the case of message code __docidx/include/syntax__ this value is the
+ set of errors found in the included file, using the format described
+ here.
+
+# [docidx] notation of keyword indices
+
+The docidx format for keyword indices, also called the *docidx markup language*,
+is too large to be covered in single section. The interested reader should start
+with the document
+
+ 1. *[docidx language introduction](../doctools/docidx_lang_intro.md)*
+
+and then proceed from there to the formal specifications, i.e. the documents
+
+ 1. *[docidx language syntax](../doctools/docidx_lang_syntax.md)* and
+
+ 1. *[docidx language command reference](../doctools/docidx_lang_cmdref.md)*.
+
+to get a thorough understanding of the language.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools), [lexer](../../../../index.md#lexer),
+[parser](../../../../index.md#parser)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/idx_structure.md
Index: embedded/md/tcllib/files/modules/doctools2idx/idx_structure.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/idx_structure.md
@@ -0,0 +1,226 @@
+
+[//000000001]: # (doctools::idx::structure - Documentation tools)
+[//000000002]: # (Generated from file 'idx_structure.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::structure(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::structure - Docidx serialization utilities
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Keyword index serialization format](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::idx::structure ?0.1?
+package require Tcl 8.4
+package require logger
+package require snit
+
+[__::doctools::idx::structure__ __verify__ *serial* ?*canonvar*?](#1)
+[__::doctools::idx::structure__ __verify-as-canonical__ *serial*](#2)
+[__::doctools::idx::structure__ __canonicalize__ *serial*](#3)
+[__::doctools::idx::structure__ __print__ *serial*](#4)
+[__::doctools::idx::structure__ __merge__ *seriala* *serialb*](#5)
+
+# DESCRIPTION
+
+This package provides commands to work with the serializations of keyword
+indices as managed by the doctools system v2, and specified in section [Keyword
+index serialization format](#section3).
+
+This is an internal package of doctools, for use by the higher level packages
+handling keyword indices and their conversion into and out of various other
+formats, like documents written using *[docidx](../../../../index.md#docidx)*
+markup.
+
+# API
+
+ - __::doctools::idx::structure__ __verify__ *serial* ?*canonvar*?
+
+ This command verifies that the content of *serial* is a valid *regular*
+ serialization of a keyword index and will throw an error if that is not the
+ case. The result of the command is the empty string.
+
+ If the argument *canonvar* is specified it is interpreted as the name of a
+ variable in the calling context. This variable will be written to if and
+ only if *serial* is a valid regular serialization. Its value will be a
+ boolean, with __True__ indicating that the serialization is not only valid,
+ but also *canonical*. __False__ will be written for a valid, but
+ non-canonical serialization.
+
+ For the specification of regular and canonical keyword index serializations
+ see the section [Keyword index serialization format](#section3).
+
+ - __::doctools::idx::structure__ __verify-as-canonical__ *serial*
+
+ This command verifies that the content of *serial* is a valid *canonical*
+ serialization of a keyword index and will throw an error if that is not the
+ case. The result of the command is the empty string.
+
+ For the specification of canonical keyword index serializations see the
+ section [Keyword index serialization format](#section3).
+
+ - __::doctools::idx::structure__ __canonicalize__ *serial*
+
+ This command assumes that the content of *serial* is a valid *regular*
+ serialization of a keyword index and will throw an error if that is not the
+ case.
+
+ It will then convert the input into the *canonical* serialization of the
+ contained keyword index and return it as its result. If the input is already
+ canonical it will be returned unchanged.
+
+ For the specification of regular and canonical keyword index serializations
+ see the section [Keyword index serialization format](#section3).
+
+ - __::doctools::idx::structure__ __print__ *serial*
+
+ This command assumes that the argument *serial* contains a valid regular
+ serialization of a keyword index and returns a string containing that index
+ in a human readable form.
+
+ The exact format of this form is not specified and cannot be relied on for
+ parsing or other machine-based activities.
+
+ For the specification of regular keyword index serializations see the
+ section [Keyword index serialization format](#section3).
+
+ - __::doctools::idx::structure__ __merge__ *seriala* *serialb*
+
+ This command accepts the regular serializations of two keyword indices and
+ uses them to create their union. The result of the command is the canonical
+ serialization of this unified keyword index.
+
+ Title and label of the resulting index are taken from the index contained in
+ *serialb*. The set of keys, references and their connections is the union of
+ the set of keys and references of the two inputs.
+
+ For the specification of regular and canonical keyword index serializations
+ see the section [Keyword index serialization format](#section3).
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[deserialization](../../../../index.md#deserialization),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2idx/import_docidx.md
Index: embedded/md/tcllib/files/modules/doctools2idx/import_docidx.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2idx/import_docidx.md
@@ -0,0 +1,201 @@
+
+[//000000001]: # (doctools::idx::import::docidx - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::idx::import::docidx(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::idx::import::docidx - docidx import plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [[docidx] notation of keyword indices](#section3)
+
+ - [Keyword index serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::idx::import::docidx ?0.1?
+package require doctools::idx::parse
+package require doctools::idx::structure
+package require doctools::msgcat
+package require doctools::tcl::parse
+package require fileutil
+package require logger
+package require snit
+package require struct::list
+package require struct::set
+package require struct::stack
+package require struct::tree
+package require treeql
+
+[__[import](../../../../index.md#import)__ *string* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools keyword index import plugin for the parsing
+of docidx markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling keyword indices, especially
+__[doctools::idx::import](idx_import.md)__, the import manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::idx::import](idx_import.md)__ and the import manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the docidx
+import plugin API version 2.
+
+ - __[import](../../../../index.md#import)__ *string* *configuration*
+
+ This command takes the *string* and parses it as docidx markup encoding a
+ keyword index, in the context of the specified *configuration* (a
+ dictionary). The result of the command is the canonical serialization of
+ that keyword index, in the form specified in section [Keyword index
+ serialization format](#section4).
+
+# [docidx] notation of keyword indices
+
+The docidx format for keyword indices, also called the *docidx markup language*,
+is too large to be covered in single section. The interested reader should start
+with the document
+
+ 1. *[docidx language introduction](../doctools/docidx_lang_intro.md)*
+
+and then proceed from there to the formal specifications, i.e. the documents
+
+ 1. *[docidx language syntax](../doctools/docidx_lang_syntax.md)* and
+
+ 1. *[docidx language command reference](../doctools/docidx_lang_cmdref.md)*.
+
+to get a thorough understanding of the language.
+
+# Keyword index serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize keyword
+indices as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a keyword
+index may have more than one regular serialization only exactly one of them will
+be *canonical*.
+
+ - regular serialization
+
+ An index serialization is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::idx__, and its value. This
+ value holds the contents of the index.
+
+ The contents of the index are a Tcl dictionary holding the title of the
+ index, a label, and the keywords and references. The relevant keys and their
+ values are
+
+ * __title__
+
+ The value is a string containing the title of the index.
+
+ * __label__
+
+ The value is a string containing a label for the index.
+
+ * __keywords__
+
+ The value is a Tcl dictionary, using the keywords known to the
+ index as keys. The associated values are lists containing the
+ identifiers of the references associated with that particular
+ keyword.
+
+ Any reference identifier used in these lists has to exist as a key
+ in the __references__ dictionary, see the next item for its
+ definition.
+
+ * __references__
+
+ The value is a Tcl dictionary, using the identifiers for the
+ references known to the index as keys. The associated values are
+ 2-element lists containing the type and label of the reference, in
+ this order.
+
+ Any key here has to be associated with at least one keyword, i.e.
+ occur in at least one of the reference lists which are the values
+ in the __keywords__ dictionary, see previous item for its
+ definition.
+
+ The *[type](../../../../index.md#type)* of a reference can be one of two
+ values,
+
+ * __manpage__
+
+ The identifier of the reference is interpreted as symbolic file
+ name, referring to one of the documents the index was made for.
+
+ * __url__
+
+ The identifier of the reference is interpreted as an url, referring
+ to some external location, like a website, etc.
+
+ - canonical serialization
+
+ The canonical serialization of a keyword index has the format as specified
+ in the previous item, and then additionally satisfies the constraints below,
+ which make it unique among all the possible serializations of the keyword
+ index.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+ The references listed for each keyword of the index, if any, are listed in
+ ascending dictionary order of their *labels*, as generated by Tcl's builtin
+ command __lsort -increasing -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[deserialization](../../../../index.md#deserialization),
+[docidx](../../../../index.md#docidx),
+[doctools](../../../../index.md#doctools),
+[import](../../../../index.md#import), [index](../../../../index.md#index)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/export_doctoc.md
Index: embedded/md/tcllib/files/modules/doctools2toc/export_doctoc.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/export_doctoc.md
@@ -0,0 +1,272 @@
+
+[//000000001]: # (doctools::toc::export::doctoc - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::doctoc(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::doctoc - doctoc export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [[doctoc] notation of tables of contents](#section3)
+
+ - [Configuration](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::doctoc ?0.1?
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of doctoc markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section5), and contained in
+ *serial*, the *configuration*, a dictionary, and generates doctoc markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# [doctoc] notation of tables of contents
+
+The doctoc format for tables of contents, also called the *doctoc markup
+language*, is too large to be covered in single section. The interested reader
+should start with the document
+
+ 1. *[doctoc language introduction](../doctools/doctoc_lang_intro.md)*
+
+and then proceed from there to the formal specifications, i.e. the documents
+
+ 1. *[doctoc language syntax](../doctools/doctoc_lang_syntax.md)* and
+
+ 1. *[doctoc language command reference](../doctools/doctoc_lang_cmdref.md)*.
+
+to get a thorough understanding of the language.
+
+# Configuration
+
+The doctoc export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - string *user*
+
+ This standard configuration variable contains the name of the user running
+ the process which invoked the export plugin. The plugin puts this
+ information into the provenance comment at the beginning of the generated
+ document.
+
+ - string *file*
+
+ This standard configuration variable contains the name of the file the table
+ of contents came from. This variable may not be set or contain the empty
+ string. The plugin puts this information, if defined, i.e. set and not the
+ empty string, into the provenance comment at the beginning of the generated
+ document.
+
+ - boolean *newlines*
+
+ If this flag is set the plugin will break the generated doctoc code across
+ lines, with each markup command on a separate line.
+
+ If this flag is not set (the default), the whole document will be written on
+ a single line, with minimum spacing between all elements.
+
+ - boolean *indented*
+
+ If this flag is set the plugin will indent the markup commands according to
+ the structure of tables of contents. To make this work this also implies
+ that __newlines__ is set. This effect is independent of the value for
+ __aligned__ however.
+
+ If this flag is not set (the default), the output is formatted as per the
+ value of __newlines__, and no indenting is done.
+
+ - boolean *aligned*
+
+ If this flag is set the generator ensures that the arguments for the
+ __item__ commands in a division are aligned vertically for a nice table
+ effect. To make this work this also implies that __newlines__ is set. This
+ effect is independent of the value for __indented__ however.
+
+ If this flag is not set (the default), the output is formatted as per the
+ values of __newlines__ and __indented__, and no alignment is done.
+
+*Note* that this plugin ignores the standard configuration variables __format__,
+and __map__, and their values.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/import_doctoc.md
Index: embedded/md/tcllib/files/modules/doctools2toc/import_doctoc.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/import_doctoc.md
@@ -0,0 +1,231 @@
+
+[//000000001]: # (doctools::toc::import::doctoc - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::import::doctoc(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::import::doctoc - doctoc import plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [[doctoc] notation of tables of contents](#section3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::import::doctoc ?0.1?
+package require doctools::toc::parse
+package require doctools::toc::structure
+package require doctools::msgcat
+package require doctools::tcl::parse
+package require fileutil
+package require logger
+package require snit
+package require struct::list
+package require struct::set
+package require struct::stack
+package require struct::tree
+package require treeql
+
+[__[import](../../../../index.md#import)__ *string* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents import plugin for the
+parsing of doctoc markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::import](toc_import.md)__, the import manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::import](toc_import.md)__ and the import manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+import plugin API version 2.
+
+ - __[import](../../../../index.md#import)__ *string* *configuration*
+
+ This command takes the *string* and parses it as doctoc markup encoding a
+ table of contents, in the context of the specified *configuration* (a
+ dictionary). The result of the command is the canonical serialization of
+ that table of contents, in the form specified in section [ToC serialization
+ format](#section4).
+
+# [doctoc] notation of tables of contents
+
+The doctoc format for tables of contents, also called the *doctoc markup
+language*, is too large to be covered in single section. The interested reader
+should start with the document
+
+ 1. *[doctoc language introduction](../doctools/doctoc_lang_intro.md)*
+
+and then proceed from there to the formal specifications, i.e. the documents
+
+ 1. *[doctoc language syntax](../doctools/doctoc_lang_syntax.md)* and
+
+ 1. *[doctoc language command reference](../doctools/doctoc_lang_cmdref.md)*.
+
+to get a thorough understanding of the language.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[deserialization](../../../../index.md#deserialization),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools),
+[import](../../../../index.md#import), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_container.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_container.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_container.md
@@ -0,0 +1,504 @@
+
+[//000000001]: # (doctools::toc - Documentation tools)
+[//000000002]: # (Generated from file 'toc_container.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc(n) 2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc - Holding tables of contents
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Concepts](#section2)
+
+ - [API](#section3)
+
+ - [Package commands](#subsection1)
+
+ - [Object command](#subsection2)
+
+ - [Object methods](#subsection3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::toc ?2?
+package require Tcl 8.4
+package require doctools::toc::structure
+package require struct::tree
+package require snit
+
+[__::doctools::toc__ *objectName*](#1)
+[__objectName__ __method__ ?*arg arg ...*?](#2)
+[*objectName* __destroy__](#3)
+[*objectName* __+ reference__ *id* *label* *docid* *desc*](#4)
+[*objectName* __+ division__ *id* *label* ?*docid*?](#5)
+[*objectName* __remove__ *id*](#6)
+[*objectName* __up__ *id*](#7)
+[*objectName* __next__ *id*](#8)
+[*objectName* __prev__ *id*](#9)
+[*objectName* __child__ *id* *label* ?*...*?](#10)
+[*objectName* __element__ ?*...*?](#11)
+[*objectName* __children__ *id*](#12)
+[*objectName* __type__ *id*](#13)
+[*objectName* __full-label__ *id*](#14)
+[*objectName* __elabel__ *id* ?*newlabel*?](#15)
+[*objectName* __description__ *id* ?*newdesc*?](#16)
+[*objectName* __document__ *id* ?*newdocid*?](#17)
+[*objectName* __title__](#18)
+[*objectName* __title__ *text*](#19)
+[*objectName* __label__](#20)
+[*objectName* __label__ *text*](#21)
+[*objectName* __importer__](#22)
+[*objectName* __importer__ *object*](#23)
+[*objectName* __exporter__](#24)
+[*objectName* __exporter__ *object*](#25)
+[*objectName* __deserialize =__ *data* ?*format*?](#26)
+[*objectName* __deserialize +=__ *data* ?*format*?](#27)
+[*objectName* __serialize__ ?*format*?](#28)
+
+# DESCRIPTION
+
+This package provides a class to contain and programmatically manipulate tables
+of contents.
+
+This is one of the three public pillars the management of tables of contents
+resides on. The other two pillars are
+
+ 1. *[Exporting tables of contents](toc_export.md)*, and
+
+ 1. *Importing tables of contents*
+
+For information about the [Concepts](#section2) of tables of contents, and their
+parts, see the same-named section. For information about the data structure
+which is used to encode tables of contents as values see the section [ToC
+serialization format](#section4). This is the only format directly known to this
+class. Conversions from and to any other format are handled by export and import
+manager objects. These may be attached to a container, but do not have to be, it
+is merely a convenience.
+
+# Concepts
+
+ 1. A *[table of contents](../../../../index.md#table_of_contents)* consists of
+ a (possibly empty) list of *elements*.
+
+ 1. Each element in the list is identified by its label.
+
+ 1. Each element is either a *[reference](../../../../index.md#reference)*, or
+ a *division*.
+
+ 1. Each reference has an associated document, identified by a symbolic id, and
+ a textual description.
+
+ 1. Each division may have an associated document, identified by a symbolic id.
+
+ 1. Each division consists consists of a (possibly empty) list of *elements*,
+ with each element following the rules as specified in item 2 and above.
+
+A few notes
+
+ 1. The above rules span up a tree of elements, with references as the leaf
+ nodes, and divisions as the inner nodes, and each element representing an
+ entry in the whole table of contents.
+
+ 1. The identifying labels of any element E are unique within their division
+ (or toc), and the full label of any element E is the list of labels for all
+ nodes on the unique path from the root of the tree to E, including E.
+
+# API
+
+## Package commands
+
+ - __::doctools::toc__ *objectName*
+
+ This command creates a new container object with an associated Tcl command
+ whose name is *objectName*. This *[object](../../../../index.md#object)*
+ command is explained in full detail in the sections [Object
+ command](#subsection2) and [Object methods](#subsection3). The object
+ command will be created under the current namespace if the *objectName* is
+ not fully qualified, and in the specified namespace otherwise.
+
+## Object command
+
+All objects created by the __::doctools::toc__ command have the following
+general form:
+
+ - __objectName__ __method__ ?*arg arg ...*?
+
+ The method __method__ and its *arg*'uments determine the exact behavior of
+ the command. See section [Object methods](#subsection3) for the detailed
+ specifications.
+
+## Object methods
+
+ - *objectName* __destroy__
+
+ This method destroys the object it is invoked for.
+
+ - *objectName* __+ reference__ *id* *label* *docid* *desc*
+
+ This method adds a new reference element to the table of contents, under the
+ element specified via its handle *id*. This parent element has to be a
+ division element, or the root. An error is thrown otherwise. The new element
+ will be externally identified by its *label*, which has to be be unique
+ within the parent element. An error is thrown otherwise.
+
+ As a reference element it will refer to a document identified by the
+ symbolic *docid*. This reference must not be the empty string, an error is
+ thrown otherwise. Beyond the label the element also has a longer descriptive
+ string, supplied via *desc*.
+
+ The result of the method is the handle (id) of the new element.
+
+ - *objectName* __+ division__ *id* *label* ?*docid*?
+
+ This method adds a new division element to the table of contents, under the
+ element specified via its handle *id*. This parent element has to be a
+ division element, or the root. An error is thrown otherwise. The new element
+ will be externally identified by its *label*, which has to be be unique
+ within the parent element. An error is thrown otherwise.
+
+ As a division element it is can refer to a document, identified by the
+ symbolic *docid*, but may choose not to.
+
+ The result of the method is the handle (id) of the new element.
+
+ - *objectName* __remove__ *id*
+
+ This method removes the element identified by the handle *id* from the table
+ of contents. If the element is a division all of its children, if any, are
+ removed as well. The root element/division of the table of contents cannot
+ be removed however, only its children.
+
+ The result of the method is the empty string.
+
+ - *objectName* __up__ *id*
+
+ This method returns the handle of the parent for the element identified by
+ its handle *id*, or the empty string if *id* referred to the root element.
+
+ - *objectName* __next__ *id*
+
+ This method returns the handle of the right sibling for the element
+ identified by its handle *id*, or the handle of the parent if the element
+ has no right sibling, or the empty string if *id* referred to the root
+ element.
+
+ - *objectName* __prev__ *id*
+
+ This method returns the handle of the left sibling for the element
+ identified by its handle *id*, or the handle of the parent if the element
+ has no left sibling, or the empty string if *id* referred to the root
+ element.
+
+ - *objectName* __child__ *id* *label* ?*...*?
+
+ This method returns the handle of a child of the element identified by its
+ handle *id*. The child itself is identified by a series of labels.
+
+ - *objectName* __element__ ?*...*?
+
+ This method returns the handle of the element identified by a series of
+ labels, starting from the root of the table of contents. The series of
+ labels is allowed to be empty, in which case the handle of the root element
+ is returned.
+
+ - *objectName* __children__ *id*
+
+ This method returns a list containing the handles of all children of the
+ element identified by the handle *id*, from first to last, in that order.
+
+ - *objectName* __type__ *id*
+
+ This method returns the type of the element, either __reference__, or
+ __division__.
+
+ - *objectName* __full-label__ *id*
+
+ This method is the complement of the method __element__, converting the
+ handle *id* of an element into a list of labels full identifying the element
+ within the whole table of contents.
+
+ - *objectName* __elabel__ *id* ?*newlabel*?
+
+ This method queries and/or changes the label of the element identified by
+ the handle *id*. If the argument *newlabel* is present then the label is
+ changed to that value. Regardless of this, the result of the method is the
+ current value of the label.
+
+ If the label is changed the new label has to be unique within the containing
+ division, or an error is thrown.
+
+ Further, of the *id* refers to the root element of the table of contents,
+ then using this method is equivalent to using the method *label*, i.e. it is
+ accessing the global label for the whole table.
+
+ - *objectName* __description__ *id* ?*newdesc*?
+
+ This method queries and/or changes the description of the element identified
+ by the handle *id*. If the argument *newdesc* is present then the
+ description is changed to that value. Regardless of this, the result of the
+ method is the current value of the description.
+
+ The element this method operates on has to be a reference element, or an
+ error will be thrown.
+
+ - *objectName* __document__ *id* ?*newdocid*?
+
+ This method queries and/or changes the document reference of the element
+ identified by the handle *id*. If the argument *newdocid* is present then
+ the description is changed to that value. Regardless of this, the result of
+ the method is the current value of the document reference.
+
+ Setting the reference to the empty string means unsetting it, and is allowed
+ only for division elements. Conversely, if the result is the empty string
+ then the element has no document reference, and this can happen only for
+ division elements.
+
+ - *objectName* __title__
+
+ Returns the currently defined title of the table of contents.
+
+ - *objectName* __title__ *text*
+
+ Sets the title of the table of contents to *text*, and returns it as the
+ result of the command.
+
+ - *objectName* __label__
+
+ Returns the currently defined label of the table of contents.
+
+ - *objectName* __label__ *text*
+
+ Sets the label of the table of contents to *text*, and returns it as the
+ result of the command.
+
+ - *objectName* __importer__
+
+ Returns the import manager object currently attached to the container, if
+ any.
+
+ - *objectName* __importer__ *object*
+
+ Attaches the *object* as import manager to the container, and returns it as
+ the result of the command. Note that the *object* is *not* put into
+ ownership of the container. I.e., destruction of the container will *not*
+ destroy the *object*.
+
+ It is expected that *object* provides a method named __import text__ which
+ takes a text and a format name, and returns the canonical serialization of
+ the table of contents contained in the text, assuming the given format.
+
+ - *objectName* __exporter__
+
+ Returns the export manager object currently attached to the container, if
+ any.
+
+ - *objectName* __exporter__ *object*
+
+ Attaches the *object* as export manager to the container, and returns it as
+ the result of the command. Note that the *object* is *not* put into
+ ownership of the container. I.e., destruction of the container will *not*
+ destroy the *object*.
+
+ It is expected that *object* provides a method named __export object__ which
+ takes the container and a format name, and returns a text encoding table of
+ contents stored in the container, in the given format. It is further
+ expected that the *object* will use the container's method __serialize__ to
+ obtain the serialization of the table of contents from which to generate the
+ text.
+
+ - *objectName* __deserialize =__ *data* ?*format*?
+
+ This method replaces the contents of the table object with the table
+ contained in the *data*. If no *format* was specified it is assumed to be
+ the regular serialization of a table of contents.
+
+ Otherwise the object will use the attached import manager to convert the
+ data from the specified format to a serialization it can handle. In that
+ case an error will be thrown if the container has no import manager attached
+ to it.
+
+ The result of the method is the empty string.
+
+ - *objectName* __deserialize +=__ *data* ?*format*?
+
+ This method behaves like __deserialize =__ in its essentials, except that it
+ merges the table of contents in the *data* to its contents instead of
+ replacing it. The method will throw an error if merging is not possible,
+ i.e. would produce an invalid table. The existing content is left unchanged
+ in that case.
+
+ The result of the method is the empty string.
+
+ - *objectName* __serialize__ ?*format*?
+
+ This method returns the table of contents contained in the object. If no
+ *format* is not specified the returned result is the canonical serialization
+ of its contents.
+
+ Otherwise the object will use the attached export manager to convert the
+ data to the specified format. In that case an error will be thrown if the
+ container has no export manager attached to it.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[HTML](../../../../index.md#html), [TMML](../../../../index.md#tmml),
+[conversion](../../../../index.md#conversion), [doctoc
+markup](../../../../index.md#doctoc_markup),
+[documentation](../../../../index.md#documentation),
+[formatting](../../../../index.md#formatting),
+[generation](../../../../index.md#generation),
+[json](../../../../index.md#json), [latex](../../../../index.md#latex),
+[markup](../../../../index.md#markup), [nroff](../../../../index.md#nroff),
+[parsing](../../../../index.md#parsing), [plugin](../../../../index.md#plugin),
+[reference](../../../../index.md#reference),
+[table](../../../../index.md#table), [table of
+contents](../../../../index.md#table_of_contents), [tcler's
+wiki](../../../../index.md#tcler_s_wiki), [text](../../../../index.md#text),
+[wiki](../../../../index.md#wiki)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export.md
@@ -0,0 +1,473 @@
+
+[//000000001]: # (doctools::toc::export - Documentation tools)
+[//000000002]: # (Generated from file 'toc_export.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export - Exporting tables of contents
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Concepts](#section2)
+
+ - [API](#section3)
+
+ - [Package commands](#subsection1)
+
+ - [Object command](#subsection2)
+
+ - [Object methods](#subsection3)
+
+ - [Export plugin API v2 reference](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::toc::export ?0.2?
+package require Tcl 8.4
+package require doctools::config
+package require doctools::toc::structure
+package require snit
+package require pluginmgr
+
+[__::doctools::toc::export__ *objectName*](#1)
+[__objectName__ __method__ ?*arg arg ...*?](#2)
+[*objectName* __destroy__](#3)
+[*objectName* __export serial__ *serial* ?*format*?](#4)
+[*objectName* __export object__ *object* ?*format*?](#5)
+[*objectName* __config names__](#6)
+[*objectName* __config get__](#7)
+[*objectName* __config set__ *name* ?*value*?](#8)
+[*objectName* __config unset__ *pattern*...](#9)
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#10)
+
+# DESCRIPTION
+
+This package provides a class to manage the plugins for the export of tables of
+contents to other formats, i.e. their conversion to, for example
+*[doctoc](../../../../index.md#doctoc)*, *[HTML](../../../../index.md#html)*,
+etc.
+
+This is one of the three public pillars the management of tables of contents
+resides on. The other two pillars are
+
+ 1. *Importing tables of contents*, and
+
+ 1. *[Holding tables of contents](toc_container.md)*
+
+For information about the [Concepts](#section2) of tables of contents, and their
+parts, see the same-named section. For information about the data structure
+which is the major input to the manager objects provided by this package see the
+section [ToC serialization format](#section5).
+
+The plugin system of our class is based on the package
+__[pluginmgr](../pluginmgr/pluginmgr.md)__, and configured to look for plugins
+using
+
+ 1. the environment variable __DOCTOOLS_TOC_EXPORT_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_TOC_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_PLUGINS__,
+
+ 1. the path "~/.doctools/toc/export/plugin"
+
+ 1. the path "~/.doctools/toc/plugin"
+
+ 1. the path "~/.doctools/plugin"
+
+ 1. the path "~/.doctools/toc/export/plugins"
+
+ 1. the path "~/.doctools/toc/plugins"
+
+ 1. the path "~/.doctools/plugins"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\EXPORT\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"
+
+The last three are used only when the package is run on a machine using
+Windows(tm) operating system.
+
+The whole system is delivered with six predefined export plugins, namely
+
+ - doctoc
+
+ See *[doctoc export plugin](export_doctoc.md)* for details.
+
+ - html
+
+ See *html export plugin* for details.
+
+ - json
+
+ See *json export plugin* for details.
+
+ - nroff
+
+ See *[nroff export plugin](toc_export_nroff.md)* for details.
+
+ - text
+
+ See *text export plugin* for details.
+
+ - wiki
+
+ See *[wiki export plugin](toc_export_wiki.md)* for details.
+
+Readers wishing to write their own export plugin for some format, i.e. *plugin
+writer*s reading and understanding the section containing the [Export plugin API
+v2 reference](#section4) is an absolute necessity, as it specifies the
+interaction between this package and its plugins in detail.
+
+# Concepts
+
+ 1. A *[table of contents](../../../../index.md#table_of_contents)* consists of
+ a (possibly empty) list of *elements*.
+
+ 1. Each element in the list is identified by its label.
+
+ 1. Each element is either a *[reference](../../../../index.md#reference)*, or
+ a *division*.
+
+ 1. Each reference has an associated document, identified by a symbolic id, and
+ a textual description.
+
+ 1. Each division may have an associated document, identified by a symbolic id.
+
+ 1. Each division consists consists of a (possibly empty) list of *elements*,
+ with each element following the rules as specified in item 2 and above.
+
+A few notes
+
+ 1. The above rules span up a tree of elements, with references as the leaf
+ nodes, and divisions as the inner nodes, and each element representing an
+ entry in the whole table of contents.
+
+ 1. The identifying labels of any element E are unique within their division
+ (or toc), and the full label of any element E is the list of labels for all
+ nodes on the unique path from the root of the tree to E, including E.
+
+# API
+
+## Package commands
+
+ - __::doctools::toc::export__ *objectName*
+
+ This command creates a new export manager object with an associated Tcl
+ command whose name is *objectName*. This
+ *[object](../../../../index.md#object)* command is explained in full detail
+ in the sections [Object command](#subsection2) and [Object
+ methods](#subsection3). The object command will be created under the current
+ namespace if the *objectName* is not fully qualified, and in the specified
+ namespace otherwise.
+
+## Object command
+
+All objects created by the __::doctools::toc::export__ command have the
+following general form:
+
+ - __objectName__ __method__ ?*arg arg ...*?
+
+ The method __method__ and its *arg*'uments determine the exact behavior of
+ the command. See section [Object methods](#subsection3) for the detailed
+ specifications.
+
+## Object methods
+
+ - *objectName* __destroy__
+
+ This method destroys the object it is invoked for.
+
+ - *objectName* __export serial__ *serial* ?*format*?
+
+ This method takes the canonical serialization of a table of contents stored
+ in *serial* and converts it to the specified *format*, using the export
+ plugin for the format. An error is thrown if no plugin could be found for
+ the format. The string generated by the conversion process is returned as
+ the result of this method.
+
+ If no format is specified the method defaults to __doctoc__.
+
+ The specification of what a *canonical* serialization is can be found in the
+ section [ToC serialization format](#section5).
+
+ The plugin has to conform to the interface specified in section [Export
+ plugin API v2 reference](#section4).
+
+ - *objectName* __export object__ *object* ?*format*?
+
+ This method is a convenient wrapper around the __export serial__ method
+ described by the previous item. It expects that *object* is an object
+ command supporting a __serialize__ method returning the canonical
+ serialization of a table of contents. It invokes that method, feeds the
+ result into __export serial__ and returns the resulting string as its own
+ result.
+
+ - *objectName* __config names__
+
+ This method returns a list containing the names of all configuration
+ variables currently known to the object.
+
+ - *objectName* __config get__
+
+ This method returns a dictionary containing the names and values of all
+ configuration variables currently known to the object.
+
+ - *objectName* __config set__ *name* ?*value*?
+
+ This method sets the configuration variable *name* to the specified *value*
+ and returns the new value of the variable.
+
+ If no value is specified it simply returns the current value, without
+ changing it.
+
+ Note that while the user can set the predefined configuration variables
+ __user__ and __format__ doing so will have no effect, these values will be
+ internally overridden when invoking an import plugin.
+
+ - *objectName* __config unset__ *pattern*...
+
+ This method unsets all configuration variables matching the specified glob
+ *pattern*s. If no pattern is specified it will unset all currently defined
+ configuration variables.
+
+# Export plugin API v2 reference
+
+Plugins are what this package uses to manage the support for any output format
+beyond the [ToC serialization format](#section5). Here we specify the API the
+objects created by this package use to interact with their plugins.
+
+A plugin for this package has to follow the rules listed below:
+
+ 1. A plugin is a package.
+
+ 1. The name of a plugin package has the form doctools::toc::export::__FOO__,
+ where __FOO__ is the name of the format the plugin will generate output
+ for. This name is also the argument to provide to the various __export__
+ methods of export manager objects to get a string encoding a table of
+ contents in that format.
+
+ 1. The plugin can expect that the package __doctools::toc::export::plugin__ is
+ present, as indicator that it was invoked from a genuine plugin manager.
+
+ 1. A plugin has to provide one command, with the signature shown below.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ Whenever an export manager of
+ __[doctools::toc](../doctools/doctoc.md)__ has to generate output for a
+ table of contents it will invoke this command.
+
+ * string *serial*
+
+ This argument will contain the *canonical* serialization of the
+ table of contents for which to generate the output. The
+ specification of what a *canonical* serialization is can be found
+ in the section [ToC serialization format](#section5).
+
+ * dictionary *configuration*
+
+ This argument will contain the current configuration to apply to
+ the generation, as a dictionary mapping from variable names to
+ values.
+
+ The following configuration variables have a predefined meaning all
+ plugins have to obey, although they can ignore this information at
+ their discretion. Any other other configuration variables
+ recognized by a plugin will be described in the manpage for that
+ plugin.
+
+ + user
+
+ This variable is expected to contain the name of the user
+ owning the process invoking the plugin.
+
+ + format
+
+ This variable is expected to contain the name of the format
+ whose plugin is invoked.
+
+ + file
+
+ This variable, if defined by the user of the table object is
+ expected to contain the name of the input file for which the
+ plugin is generating its output for.
+
+ + map
+
+ This variable, if defined by the user of the table object is
+ expected to contain a dictionary mapping from symbolic document
+ ids used in the table entries to actual paths (or urls). A
+ plugin has to be able to handle the possibility that a document
+ id is without entry in this mapping.
+
+ 1. A single usage cycle of a plugin consists of the invokations of the command
+ __[export](../../../../index.md#export)__. This call has to leave the
+ plugin in a state where another usage cycle can be run without problems.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[HTML](../../../../index.md#html),
+[conversion](../../../../index.md#conversion),
+[doctoc](../../../../index.md#doctoc),
+[documentation](../../../../index.md#documentation),
+[export](../../../../index.md#export),
+[formatting](../../../../index.md#formatting),
+[generation](../../../../index.md#generation),
+[json](../../../../index.md#json), [manpage](../../../../index.md#manpage),
+[markup](../../../../index.md#markup), [nroff](../../../../index.md#nroff),
+[plugin](../../../../index.md#plugin),
+[reference](../../../../index.md#reference),
+[table](../../../../index.md#table), [table of
+contents](../../../../index.md#table_of_contents), [tcler's
+wiki](../../../../index.md#tcler_s_wiki), [text](../../../../index.md#text),
+[url](../../../../index.md#url), [wiki](../../../../index.md#wiki)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009-2018 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export_html.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export_html.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export_html.md
@@ -0,0 +1,329 @@
+
+[//000000001]: # (doctools::toc::export::html - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::html(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::html - HTML export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Configuration](#section3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::html ?0.1?
+package require doctools::text
+package require doctools::html
+package require doctools::html::cssdefaults
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of HTML markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section4), and contained in
+ *serial*, the *configuration*, a dictionary, and generates HTML markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# Configuration
+
+The html export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - string *user*
+
+ This standard configuration variable contains the name of the user running
+ the process which invoked the export plugin. The plugin puts this
+ information into the provenance comment at the beginning of the generated
+ document.
+
+ - string *file*
+
+ This standard configuration variable contains the name of the file the table
+ of contents came from. This variable may not be set or contain the empty
+ string. The plugin puts this information, if defined, i.e. set and not the
+ empty string, into the provenance comment at the beginning of the generated
+ document.
+
+ - dictionary *map*
+
+ This standard configuration variable contains a dictionary mapping from the
+ (symbolic) document ids in reference entries to the actual filenames and/or
+ urls to be used in the output.
+
+ Document ids without a mapping are used unchanged.
+
+ - boolean *newlines*
+
+ If this flag is set the plugin will break the generated html code across
+ lines, with each markup command on a separate line.
+
+ If this flag is not set (the default), the whole document will be written on
+ a single line, with minimum spacing between all elements.
+
+ - boolean *indented*
+
+ If this flag is set the plugin will indent the markup commands according to
+ the structure of indices. To make this work this also implies that
+ __newlines__ is set.
+
+ If this flag is not set (the default), the output is formatted as per the
+ value of __newlines__, and no indenting is done.
+
+ - string *meta*
+
+ This variable is meant to hold a fragment of HTML (default: empty). The
+ fragment it contains will be inserted into the generated output in the
+ section of the document, just after the tag.
+
+ - string *header*
+
+ This variable is meant to hold a fragment of HTML (default: empty). The
+ fragment it contains will be inserted into the generated output just after
+ the title tag in the body of the document, in the class.header
+ 'ision.
+
+ - string *footer*
+
+ This variable is meant to hold a fragment of HTML (default: empty). The
+ fragment it contains will be inserted into the generated output just before
+ the tag, in the class.footer 'ision.
+
+ - dictionary *rid*
+
+ The value of this variable (default: empty) maps references to the
+ identifiers to use as their anchor names. Each reference __FOO__ not found
+ in the dictionary uses __REF-____FOO__ as anchor, i.e. itself prefixed with
+ the string __REF-__.
+
+ - string *sepline*
+
+ The value of this variable is the string to use for the separator comments
+ inserted into the output when the outpout is broken across lines and/or
+ indented. The default string consists of 60 dashes.
+
+ - string *class.main*
+
+ This variable contains the class name for the main 'ivision of the
+ generated document. The default is __doctools__.
+
+ - string *class.header*
+
+ This variable contains the class name for the header 'ision of the
+ generated document. The default is __toc-header__. This division contains
+ the document title, the user specified __header__, if any, and a visible
+ separator line.
+
+ - string *class.title*
+
+ This variable contains the class name for the tag enclosing the
+ document title. The default is __toc-title__.
+
+ - string *class.navsep*
+
+ This variable contains the class name for the separators in the header
+ and footer sections of the generated document. The default is
+ __toc-navsep__.
+
+ - string *class.contents*
+
+ This variable contains the class name for the XXXXX holding the keywords and
+ their references in the generated document. The default is __toc-contents__.
+
+ - string *class.ref*
+
+ This variable contains the class name for the table elements which are
+ references to other documents. The default is __toc-ref__.
+
+ - string *class.div*
+
+ This variable contains the class name for the table elements which are
+ divisions. The default is __toc-div__.
+
+ - string *class.footer*
+
+ This variable contains the class name for the footer 'ision of the
+ generated document. The default is __toc-footer__. This division contains a
+ browser-visible separator line and the user specified __footer__, if any.
+
+*Note* that this plugin ignores the standard configuration variable __format__,
+and its value.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[HTML](../../../../index.md#html), [doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export_json.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export_json.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export_json.md
@@ -0,0 +1,300 @@
+
+[//000000001]: # (doctools::toc::export::json - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::json(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::json - JSON export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [JSON notation of tables of contents](#section3)
+
+ - [Configuration](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::json ?0.1?
+package require textutil::adjust
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of JSON markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section5), and contained in
+ *serial*, the *configuration*, a dictionary, and generates JSON markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# JSON notation of tables of contents
+
+The JSON format used for tables of contents is a direct translation of the [ToC
+serialization format](#section5), mapping Tcl dictionaries as JSON objects and
+Tcl lists as JSON arrays. For example, the Tcl serialization
+
+ doctools::toc {
+ items {
+ {reference {
+ desc {DocTools - Tables of Contents}
+ id introduction.man
+ label doctools::toc::introduction
+ }}
+ {division {
+ id processing.man
+ items {
+ {reference {
+ desc {doctoc serialization utilities}
+ id structure.man
+ label doctools::toc::structure
+ }}
+ {reference {
+ desc {Parsing text in doctoc format}
+ id parse.man
+ label doctools::toc::parse
+ }}
+ }
+ label Processing
+ }}
+ }
+ label {Table of Contents}
+ title TOC
+ }
+
+is equivalent to the JSON string
+
+ {
+ "doctools::toc" : {
+ "items" : [{
+ "reference" : {
+ "desc" : "DocTools - Tables of Contents",
+ "id" : "introduction.man",
+ "label" : "doctools::toc::introduction"
+ }
+ },{
+ "division" : {
+ "id" : "processing.man",
+ "items" : [{
+ "reference" : {
+ "desc" : "doctoc serialization utilities",
+ "id" : "structure.man",
+ "label" : "doctools::toc::structure"
+ }
+ },{
+ "reference" : {
+ "desc" : "Parsing text in doctoc format",
+ "id" : "parse.man",
+ "label" : "doctools::toc::parse"
+ }
+ }],
+ "label" : "Processing"
+ }
+ }],
+ "label" : "Table of Contents",
+ "title" : "TOC"
+ }
+ }
+
+# Configuration
+
+The JSON export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - boolean *indented*
+
+ If this flag is set the plugin will break the generated JSON code across
+ lines and indent it according to its inner structure, with each key of a
+ dictionary on a separate line.
+
+ If this flag is not set (the default), the whole JSON object will be written
+ on a single line, with minimum spacing between all elements.
+
+ - boolean *aligned*
+
+ If this flag is set the generator ensures that the values for the keys in a
+ dictionary are vertically aligned with each other, for a nice table effect.
+ To make this work this also implies that __indented__ is set.
+
+ If this flag is not set (the default), the output is formatted as per the
+ value of __indented__, without trying to align the values for dictionary
+ keys.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__format__, __file__, and __map__ and their values.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[JSON](../../../../index.md#json), [doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export_nroff.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export_nroff.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export_nroff.md
@@ -0,0 +1,236 @@
+
+[//000000001]: # (doctools::toc::export::nroff - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::nroff(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::nroff - nroff export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Configuration](#section3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::nroff ?0.2?
+package require doctools::text
+package require doctools::nroff::man_macros
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of nroff markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section4), and contained in
+ *serial*, the *configuration*, a dictionary, and generates nroff markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# Configuration
+
+The nroff export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - string *user*
+
+ This standard configuration variable contains the name of the user running
+ the process which invoked the export plugin. The plugin puts this
+ information into the provenance comment at the beginning of the generated
+ document.
+
+ - string *file*
+
+ This standard configuration variable contains the name of the file the table
+ of contents came from. This variable may not be set or contain the empty
+ string. The plugin puts this information, if defined, i.e. set and not the
+ empty string, into the provenance comment at the beginning of the generated
+ document.
+
+ - boolean *inline*
+
+ If this flag is set (default) the plugin will place the definitions of the
+ man macro set directly into the output.
+
+ If this flag is not set, the plugin will place a reference to the
+ definitions of the man macro set into the output, but not the macro
+ definitions themselves.
+
+*Note* that this plugin ignores the standard configuration variables __format__,
+and __map__, and their values.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [nroff](../../../../index.md#nroff),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export_text.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export_text.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export_text.md
@@ -0,0 +1,220 @@
+
+[//000000001]: # (doctools::toc::export::text - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::text(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::text - plain text export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Configuration](#section3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::text ?0.1?
+package require doctools::text
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of plain text markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section4), and contained in
+ *serial*, the *configuration*, a dictionary, and generates plain text markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# Configuration
+
+The text export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - dictionary *map*
+
+ This standard configuration variable contains a dictionary mapping from the
+ (symbolic) document ids in reference entries to the actual filenames and/or
+ urls to be used in the output.
+
+ Document ids without a mapping are used unchanged.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__file__, and __format__, and their values.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export), [plain
+text](../../../../index.md#plain_text),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_export_wiki.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_export_wiki.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_export_wiki.md
@@ -0,0 +1,229 @@
+
+[//000000001]: # (doctools::toc::export::wiki - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::export::wiki(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::export::wiki - wiki export plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Wiki markup](#section3)
+
+ - [Configuration](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::export::wiki ?0.1?
+package require doctools::text
+
+[__[export](../../../../index.md#export)__ *serial* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents export plugin for the
+generation of wiki markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::export](toc_export.md)__, the export manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::export](toc_export.md)__ and the export manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+export plugin API version 2.
+
+ - __[export](../../../../index.md#export)__ *serial* *configuration*
+
+ This command takes the canonical serialization of a table of contents, as
+ specified in section [ToC serialization format](#section5), and contained in
+ *serial*, the *configuration*, a dictionary, and generates wiki markup
+ encoding the table. The created string is then returned as the result of the
+ command.
+
+# Wiki markup
+
+The basic syntax of the wiki markup generated by this plugin are described at
+[http://wiki.tcl.tk/14](http://wiki.tcl.tk/14).
+
+The plugin goes beyond the classic markup to generate proper headers and
+indenting.
+
+# Configuration
+
+The wiki export plugin recognizes the following configuration variables and
+changes its behaviour as they specify.
+
+ - dictionary *map*
+
+ This standard configuration variable contains a dictionary mapping from the
+ (symbolic) document ids in reference entries to the actual filenames and/or
+ urls to be used in the output.
+
+ Document ids without a mapping are used unchanged.
+
+*Note* that this plugin ignores the standard configuration variables __user__,
+__file__ and __format__, and their values.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctools](../../../../index.md#doctools),
+[export](../../../../index.md#export),
+[serialization](../../../../index.md#serialization), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc), [wiki](../../../../index.md#wiki)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_import.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_import.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_import.md
@@ -0,0 +1,533 @@
+
+[//000000001]: # (doctools::toc::import - Documentation tools)
+[//000000002]: # (Generated from file 'toc_import.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::import(n) 0.2 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::import - Importing keyword indices
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Concepts](#section2)
+
+ - [API](#section3)
+
+ - [Package commands](#subsection1)
+
+ - [Object command](#subsection2)
+
+ - [Object methods](#subsection3)
+
+ - [Import plugin API v2 reference](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::toc::import ?0.2?
+package require Tcl 8.4
+package require doctools::config
+package require doctools::toc::structure
+package require snit
+package require pluginmgr
+
+[__::doctools::toc::import__ *objectName*](#1)
+[__objectName__ __method__ ?*arg arg ...*?](#2)
+[*objectName* __destroy__](#3)
+[*objectName* __import text__ *text* ?*format*?](#4)
+[*objectName* __import file__ *path* ?*format*?](#5)
+[*objectName* __import object text__ *object* *text* ?*format*?](#6)
+[*objectName* __import object file__ *object* *path* ?*format*?](#7)
+[*objectName* __config names__](#8)
+[*objectName* __config get__](#9)
+[*objectName* __config set__ *name* ?*value*?](#10)
+[*objectName* __config unset__ *pattern*...](#11)
+[*objectName* __includes__](#12)
+[*objectName* __include add__ *path*](#13)
+[*objectName* __include remove__ *path*](#14)
+[*objectName* __include clear__](#15)
+[__IncludeFile__ *currentfile* *path*](#16)
+[__[import](../../../../index.md#import)__ *text* *configuration*](#17)
+
+# DESCRIPTION
+
+This package provides a class to manage the plugins for the import of tables of
+contents from other formats, i.e. their conversion from, for example
+*[doctoc](../../../../index.md#doctoc)*, *[json](../../../../index.md#json)*,
+etc.
+
+This is one of the three public pillars the management of tables of contents
+resides on. The other two pillars are
+
+ 1. *[Exporting tables of contents](toc_export.md)*, and
+
+ 1. *[Holding tables of contents](toc_container.md)*
+
+For information about the [Concepts](#section2) of tables of contents, and their
+parts, see the same-named section. For information about the data structure
+which is the major output of the manager objects provided by this package see
+the section [ToC serialization format](#section5).
+
+The plugin system of our class is based on the package
+__[pluginmgr](../pluginmgr/pluginmgr.md)__, and configured to look for plugins
+using
+
+ 1. the environment variable __DOCTOOLS_TOC_IMPORT_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_TOC_PLUGINS__,
+
+ 1. the environment variable __DOCTOOLS_PLUGINS__,
+
+ 1. the path "~/.doctools/toc/import/plugin"
+
+ 1. the path "~/.doctools/toc/plugin"
+
+ 1. the path "~/.doctools/plugin"
+
+ 1. the path "~/.doctools/toc/import/plugins"
+
+ 1. the path "~/.doctools/toc/plugins"
+
+ 1. the path "~/.doctools/plugins"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\IMPORT\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\PLUGINS"
+
+ 1. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"
+
+The last three are used only when the package is run on a machine using
+Windows(tm) operating system.
+
+The whole system is delivered with two predefined import plugins, namely
+
+ - doctoc
+
+ See *[doctoc import plugin](import_doctoc.md)* for details.
+
+ - json
+
+ See *json import plugin* for details.
+
+Readers wishing to write their own import plugin for some format, i.e. *plugin
+writer*s reading and understanding the section containing the [Import plugin API
+v2 reference](#section4) is an absolute necessity, as it specifies the
+interaction between this package and its plugins in detail.
+
+# Concepts
+
+ 1. A *[table of contents](../../../../index.md#table_of_contents)* consists of
+ a (possibly empty) list of *elements*.
+
+ 1. Each element in the list is identified by its label.
+
+ 1. Each element is either a *[reference](../../../../index.md#reference)*, or
+ a *division*.
+
+ 1. Each reference has an associated document, identified by a symbolic id, and
+ a textual description.
+
+ 1. Each division may have an associated document, identified by a symbolic id.
+
+ 1. Each division consists consists of a (possibly empty) list of *elements*,
+ with each element following the rules as specified in item 2 and above.
+
+A few notes
+
+ 1. The above rules span up a tree of elements, with references as the leaf
+ nodes, and divisions as the inner nodes, and each element representing an
+ entry in the whole table of contents.
+
+ 1. The identifying labels of any element E are unique within their division
+ (or toc), and the full label of any element E is the list of labels for all
+ nodes on the unique path from the root of the tree to E, including E.
+
+# API
+
+## Package commands
+
+ - __::doctools::toc::import__ *objectName*
+
+ This command creates a new import manager object with an associated Tcl
+ command whose name is *objectName*. This
+ *[object](../../../../index.md#object)* command is explained in full detail
+ in the sections [Object command](#subsection2) and [Object
+ methods](#subsection3). The object command will be created under the current
+ namespace if the *objectName* is not fully qualified, and in the specified
+ namespace otherwise.
+
+## Object command
+
+All objects created by the __::doctools::toc::import__ command have the
+following general form:
+
+ - __objectName__ __method__ ?*arg arg ...*?
+
+ The method __method__ and its *arg*'uments determine the exact behavior of
+ the command. See section [Object methods](#subsection3) for the detailed
+ specifications.
+
+## Object methods
+
+ - *objectName* __destroy__
+
+ This method destroys the object it is invoked for.
+
+ - *objectName* __import text__ *text* ?*format*?
+
+ This method takes the *text* and converts it from the specified *format* to
+ the canonical serialization of a table of contents using the import plugin
+ for the format. An error is thrown if no plugin could be found for the
+ format. The serialization generated by the conversion process is returned as
+ the result of this method.
+
+ If no format is specified the method defaults to __doctoc__.
+
+ The specification of what a *canonical* serialization is can be found in the
+ section [ToC serialization format](#section5).
+
+ The plugin has to conform to the interface specified in section [Import
+ plugin API v2 reference](#section4).
+
+ - *objectName* __import file__ *path* ?*format*?
+
+ This method is a convenient wrapper around the __import text__ method
+ described by the previous item. It reads the contents of the specified file
+ into memory, feeds the result into __import text__ and returns the resulting
+ serialization as its own result.
+
+ - *objectName* __import object text__ *object* *text* ?*format*?
+
+ This method is a convenient wrapper around the __import text__ method
+ described by the previous item. It expects that *object* is an object
+ command supporting a __deserialize__ method expecting the canonical
+ serialization of a table of contents. It imports the text using __import
+ text__ and then feeds the resulting serialization into the *object* via
+ __deserialize__. This method returns the empty string as it result.
+
+ - *objectName* __import object file__ *object* *path* ?*format*?
+
+ This method behaves like __import object text__, except that it reads the
+ text to convert from the specified file instead of being given it as
+ argument.
+
+ - *objectName* __config names__
+
+ This method returns a list containing the names of all configuration
+ variables currently known to the object.
+
+ - *objectName* __config get__
+
+ This method returns a dictionary containing the names and values of all
+ configuration variables currently known to the object.
+
+ - *objectName* __config set__ *name* ?*value*?
+
+ This method sets the configuration variable *name* to the specified *value*
+ and returns the new value of the variable.
+
+ If no value is specified it simply returns the current value, without
+ changing it.
+
+ Note that while the user can set the predefined configuration variables
+ __user__ and __format__ doing so will have no effect, these values will be
+ internally overridden when invoking an import plugin.
+
+ - *objectName* __config unset__ *pattern*...
+
+ This method unsets all configuration variables matching the specified glob
+ *pattern*s. If no pattern is specified it will unset all currently defined
+ configuration variables.
+
+ - *objectName* __includes__
+
+ This method returns a list containing the currently specified paths to use
+ to search for include files when processing input. The order of paths in the
+ list corresponds to the order in which they are used, from first to last,
+ and also corresponds to the order in which they were added to the object.
+
+ - *objectName* __include add__ *path*
+
+ This methods adds the specified *path* to the list of paths to use to search
+ for include files when processing input. The path is added to the end of the
+ list, causing it to be searched after all previously added paths. The result
+ of the command is the empty string.
+
+ The method does nothing if the path is already known.
+
+ - *objectName* __include remove__ *path*
+
+ This methods removes the specified *path* from the list of paths to use to
+ search for include files when processing input. The result of the command is
+ the empty string.
+
+ The method does nothing if the path is not known.
+
+ - *objectName* __include clear__
+
+ This method clears the list of paths to use to search for include files when
+ processing input. The result of the command is the empty string.
+
+# Import plugin API v2 reference
+
+Plugins are what this package uses to manage the support for any input format
+beyond the [ToC serialization format](#section5). Here we specify the API the
+objects created by this package use to interact with their plugins.
+
+A plugin for this package has to follow the rules listed below:
+
+ 1. A plugin is a package.
+
+ 1. The name of a plugin package has the form doctools::toc::import::__FOO__,
+ where __FOO__ is the name of the format the plugin will generate output
+ for. This name is also the argument to provide to the various __import__
+ methods of import manager objects to get a string encoding a table of
+ contents in that format.
+
+ 1. The plugin can expect that the package __doctools::toc::export::plugin__ is
+ present, as indicator that it was invoked from a genuine plugin manager.
+
+ 1. The plugin can expect that a command named __IncludeFile__ is present, with
+ the signature
+
+ - __IncludeFile__ *currentfile* *path*
+
+ This command has to be invoked by the plugin when it has to process an
+ included file, if the format has the concept of such. An example of
+ such a format would be *[doctoc](../../../../index.md#doctoc)*.
+
+ The plugin has to supply the following arguments
+
+ * string *currentfile*
+
+ The path of the file it is currently processing. This may be the
+ empty string if no such is known.
+
+ * string *path*
+
+ The path of the include file as specified in the include directive
+ being processed.
+
+ The result of the command will be a 5-element list containing
+
+ A boolean flag indicating the success (__True__) or failure (__False__)
+ of the operation.
+
+ In case of success the contents of the included file, and the empty
+ string otherwise.
+
+ The resolved, i.e. absolute path of the included file, if possible, or
+ the unchanged *path* argument. This is for display in an error message,
+ or as the *currentfile* argument of another call to __IncludeFile__
+ should this file contain more files.
+
+ In case of success an empty string, and for failure a code indicating
+ the reason for it, one of
+
+ * notfound
+
+ The specified file could not be found.
+
+ * notread
+
+ The specified file was found, but not be read into memory.
+
+ An empty string in case of success of a __notfound__ failure, and an
+ additional error message describing the reason for a __notread__ error
+ in more detail.
+
+ 1. A plugin has to provide one command, with the signature shown below.
+
+ - __[import](../../../../index.md#import)__ *text* *configuration*
+
+ Whenever an import manager of
+ __[doctools::toc](../doctools/doctoc.md)__ has to parse input for a
+ table of contents it will invoke this command.
+
+ * string *text*
+
+ This argument will contain the text encoding the table of contents
+ per the format the plugin is for.
+
+ * dictionary *configuration*
+
+ This argument will contain the current configuration to apply to
+ the parsing, as a dictionary mapping from variable names to values.
+
+ The following configuration variables have a predefined meaning all
+ plugins have to obey, although they can ignore this information at
+ their discretion. Any other other configuration variables
+ recognized by a plugin will be described in the manpage for that
+ plugin.
+
+ + user
+
+ This variable is expected to contain the name of the user
+ owning the process invoking the plugin.
+
+ + format
+
+ This variable is expected to contain the name of the format
+ whose plugin is invoked.
+
+ 1. A single usage cycle of a plugin consists of the invokations of the command
+ __[import](../../../../index.md#import)__. This call has to leave the
+ plugin in a state where another usage cycle can be run without problems.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[conversion](../../../../index.md#conversion),
+[doctoc](../../../../index.md#doctoc),
+[documentation](../../../../index.md#documentation),
+[import](../../../../index.md#import), [json](../../../../index.md#json),
+[manpage](../../../../index.md#manpage), [markup](../../../../index.md#markup),
+[parsing](../../../../index.md#parsing), [plugin](../../../../index.md#plugin),
+[reference](../../../../index.md#reference),
+[table](../../../../index.md#table), [table of
+contents](../../../../index.md#table_of_contents),
+[url](../../../../index.md#url)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009-2018 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_import_json.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_import_json.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_import_json.md
@@ -0,0 +1,273 @@
+
+[//000000001]: # (doctools::toc::import::json - Documentation tools)
+[//000000002]: # (Generated from file 'plugin.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::import::json(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::import::json - JSON import plugin
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [JSON notation of tables of contents](#section3)
+
+ - [ToC serialization format](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require doctools::toc::import::json ?0.1?
+package require doctools::toc::structure
+package require json
+
+[__[import](../../../../index.md#import)__ *string* *configuration*](#1)
+
+# DESCRIPTION
+
+This package implements the doctools table of contents import plugin for the
+parsing of JSON markup.
+
+This is an internal package of doctools, for use by the higher level management
+packages handling tables of contents, especially
+__[doctools::toc::import](toc_import.md)__, the import manager.
+
+Using it from a regular interpreter is possible, however only with contortions,
+and is not recommended. The proper way to use this functionality is through the
+package __[doctools::toc::import](toc_import.md)__ and the import manager
+objects it provides.
+
+# API
+
+The API provided by this package satisfies the specification of the doctoc
+import plugin API version 2.
+
+ - __[import](../../../../index.md#import)__ *string* *configuration*
+
+ This command takes the *string* and parses it as JSON markup encoding a
+ table of contents, in the context of the specified *configuration* (a
+ dictionary). The result of the command is the canonical serialization of
+ that table of contents, in the form specified in section [ToC serialization
+ format](#section4).
+
+# JSON notation of tables of contents
+
+The JSON format used for tables of contents is a direct translation of the [ToC
+serialization format](#section4), mapping Tcl dictionaries as JSON objects and
+Tcl lists as JSON arrays. For example, the Tcl serialization
+
+ doctools::toc {
+ items {
+ {reference {
+ desc {DocTools - Tables of Contents}
+ id introduction.man
+ label doctools::toc::introduction
+ }}
+ {division {
+ id processing.man
+ items {
+ {reference {
+ desc {doctoc serialization utilities}
+ id structure.man
+ label doctools::toc::structure
+ }}
+ {reference {
+ desc {Parsing text in doctoc format}
+ id parse.man
+ label doctools::toc::parse
+ }}
+ }
+ label Processing
+ }}
+ }
+ label {Table of Contents}
+ title TOC
+ }
+
+is equivalent to the JSON string
+
+ {
+ "doctools::toc" : {
+ "items" : [{
+ "reference" : {
+ "desc" : "DocTools - Tables of Contents",
+ "id" : "introduction.man",
+ "label" : "doctools::toc::introduction"
+ }
+ },{
+ "division" : {
+ "id" : "processing.man",
+ "items" : [{
+ "reference" : {
+ "desc" : "doctoc serialization utilities",
+ "id" : "structure.man",
+ "label" : "doctools::toc::structure"
+ }
+ },{
+ "reference" : {
+ "desc" : "Parsing text in doctoc format",
+ "id" : "parse.man",
+ "label" : "doctools::toc::parse"
+ }
+ }],
+ "label" : "Processing"
+ }
+ }],
+ "label" : "Table of Contents",
+ "title" : "TOC"
+ }
+ }
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[JSON](../../../../index.md#json),
+[deserialization](../../../../index.md#deserialization),
+[doctools](../../../../index.md#doctools),
+[import](../../../../index.md#import), [table of
+contents](../../../../index.md#table_of_contents),
+[toc](../../../../index.md#toc)
+
+# CATEGORY
+
+Text formatter plugin
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_introduction.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_introduction.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_introduction.md
@@ -0,0 +1,194 @@
+
+[//000000001]: # (doctools2toc_introduction - Documentation tools)
+[//000000002]: # (Generated from file 'toc_introduction.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools2toc_introduction(n) 2.0 tcllib "Documentation tools")
+
+# NAME
+
+doctools2toc_introduction - DocTools - Tables of Contents
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Description](#section1)
+
+ - [Related formats](#section2)
+
+ - [Package Overview](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# DESCRIPTION
+
+*[doctoc](../../../../index.md#doctoc)* (short for *documentation tables of
+contents*) stands for a set of related, yet different, entities which are
+working together for the easy creation and transformation of tables and contents
+for documentation.
+
+These are
+
+ 1. A tcl based language for the semantic markup of a table of contents. Markup
+ is represented by Tcl commands. Beginners should start with the *[doctoc
+ language introduction](../doctools/doctoc_lang_intro.md)*. The formal
+ specification is split over two documents, one dealing with the *[doctoc
+ language syntax](../doctools/doctoc_lang_syntax.md)*, the other a *[doctoc
+ language command reference](../doctools/doctoc_lang_cmdref.md)*.
+
+ 1. A set of packages for the programmatic manipulation of tables of contents
+ in memory, and their conversion between various formats, reading and
+ writing. The aforementioned markup language is one of the formats which can
+ be both read from and written to.
+
+ 1. The system for the conversion of tables of contents is based on a plugin
+ mechanism, for this we have two APIs describing the interface between the
+ packages above and the import/export plugins.
+
+Which of the more detailed documents are relevant to the reader of this
+introduction depends on their role in the documentation process.
+
+ 1. A *writer* of documentation has to understand the markup language itself. A
+ beginner to doctoc should read the more informally written *[doctoc
+ language introduction](../doctools/doctoc_lang_intro.md)* first. Having
+ digested this the formal *[doctoc language
+ syntax](../doctools/doctoc_lang_syntax.md)* specification should become
+ understandable. A writer experienced with doctoc may only need the *[doctoc
+ language command reference](../doctools/doctoc_lang_cmdref.md)* from time
+ to time to refresh her memory.
+
+ While a document is written the __dtp__ application can be used to validate
+ it, and after completion it also performs the conversion into the chosen
+ system of visual markup, be it *roff, HTML, plain text, wiki, etc. The
+ simpler __[dtplite](../../apps/dtplite.md)__ application makes internal use
+ of doctoc when handling directories of documentation, automatically
+ generating a proper table of contents for them.
+
+ 1. A *processor* of documentation written in the
+ *[doctoc](../../../../index.md#doctoc)* markup language has to know which
+ tools are available for use.
+
+ The main tool is the aforementioned __dtp__ application provided by Tcllib.
+ The simpler __[dtplite](../../apps/dtplite.md)__ does not expose doctoc to
+ the user. At the bottom level, common to both applications, however we find
+ the three packages providing the basic facilities to handle tables of
+ contents, i.e. import from textual formats, programmatic manipulation in
+ memory, and export to textual formats. These are
+
+ - __doctoools::toc__
+
+ Programmatic manipulation of tables of contents in memory.
+
+ - __doctoools::toc::import__
+
+ Import of tables of contents from various textual formats. The set of
+ supported formats is extensible through plugin packages.
+
+ - __doctoools::toc::export__
+
+ Export of tables of contents to various textual formats. The set of
+ supported formats is extensible through plugin packages.
+
+ See also section [Package Overview](#section3) for an overview of the
+ dependencies between these and other, supporting packages.
+
+ 1. At last, but not least, *plugin writers* have to understand the interaction
+ between the import and export packages and their plugins. These APIs are
+ described in the documentation for the two relevant packages, i.e.
+
+ - __doctoools::toc::import__
+
+ - __doctoools::toc::export__
+
+# Related formats
+
+The doctoc format does not stand alone, it has two companion formats. These are
+called *[docidx](../../../../index.md#docidx)* and
+*[doctools](../../../../index.md#doctools)*, and they are intended for the
+markup of *keyword indices*, and of general documentation, respectively. They
+are described in their own sets of documents, starting at the *DocTools -
+Keyword Indices* and the *DocTools - General*, respectively.
+
+# Package Overview
+
+ ~~~~~~~~~~~ doctools::toc ~~~~~~~~~~~
+ ~~ | ~~
+ doctools::toc::export ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~ doctools::toc::import
+ | | |
+ +---------------+-------------------------+ | +------------------+---------------+-----------------------+---------------+
+ | | | | | | | | |
+ doctools::config = | | | = doctools::include doctools::config doctools::paths
+ | | | | |
+ doctools::toc::export::<*> | | | doctools::toc::import::<*>
+ doctoc | | | doctoc, json
+ json | | | | \\
+ html | | | doctools::toc::parse \\
+ nroff | | | | \\
+ wiki | | | +---------------+ json
+ text | | | | |
+ doctools::toc::structure |
+ |
+ +-------+---------------+
+ | |
+ doctools::html doctools::html::cssdefaults doctools::tcl::parse doctools::msgcat
+ | |
+ doctools::text doctools::nroff::man_macros =
+ |
+ doctools::msgcat::toc::<*>
+ c, en, de, fr
+ (fr == en for now)
+ ~~ Interoperable objects, without actual package dependencies
+ -- Package dependency, higher requires lower package
+ = Dynamic dependency through plugin system
+ <*> Multiple packages following the given form of naming.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[doctoc_intro](../doctools/doctoc_intro.md),
+[doctools](../doctools/doctools.md), doctools2doc_introduction,
+[doctools2idx_introduction](../doctools2idx/idx_introduction.md),
+[doctools_lang_cmdref](../doctools/doctools_lang_cmdref.md),
+[doctools_lang_faq](../doctools/doctools_lang_faq.md),
+[doctools_lang_intro](../doctools/doctools_lang_intro.md),
+[doctools_lang_syntax](../doctools/doctools_lang_syntax.md),
+[doctools_plugin_apiref](../doctools/doctools_plugin_apiref.md)
+
+# KEYWORDS
+
+[contents](../../../../index.md#contents),
+[conversion](../../../../index.md#conversion),
+[formatting](../../../../index.md#formatting),
+[markup](../../../../index.md#markup), [parsing](../../../../index.md#parsing),
+[plugin](../../../../index.md#plugin), [semantic
+markup](../../../../index.md#semantic_markup), [table of
+contents](../../../../index.md#table_of_contents)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_c.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_c.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_c.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::toc::c - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::toc::c(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::toc::c - Message catalog for the doctoc parser (C)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::toc::c ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::toc::c__ is a support module providing the C
+language message catalog for the doctoc parser in the doctools system version 2.
+As such it is an internal package a regular user (developer) should not be in
+direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](../doctools2idx/idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[C](../../../../index.md#c), [catalog
+package](../../../../index.md#catalog_package),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_de.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_de.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_de.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::toc::de - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::toc::de(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::toc::de - Message catalog for the doctoc parser (DE)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::toc::de ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::toc::de__ is a support module providing the DE
+(german) language message catalog for the doctoc parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](../doctools2idx/idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[DE](../../../../index.md#de), [catalog
+package](../../../../index.md#catalog_package),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_en.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_en.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_en.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::toc::en - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::toc::en(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::toc::en - Message catalog for the doctoc parser (EN)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::toc::en ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::toc::en__ is a support module providing the EN
+(english) language message catalog for the doctoc parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](../doctools2idx/idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[EN](../../../../index.md#en), [catalog
+package](../../../../index.md#catalog_package),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_fr.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_fr.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_msgcat_fr.md
@@ -0,0 +1,92 @@
+
+[//000000001]: # (doctools::msgcat::toc::fr - Documentation tools)
+[//000000002]: # (Generated from file 'msgcat.inc' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::msgcat::toc::fr(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::msgcat::toc::fr - Message catalog for the doctoc parser (FR)
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require msgcat
+package require doctools::msgcat::toc::fr ?0.1?
+
+# DESCRIPTION
+
+The package __doctools::msgcat::toc::fr__ is a support module providing the FR
+(french) language message catalog for the doctoc parser in the doctools system
+version 2. As such it is an internal package a regular user (developer) should
+not be in direct contact with.
+
+If you are such please go the documentation of either
+
+ 1. __doctools::doc__,
+
+ 1. __[doctools::toc](../doctools/doctoc.md)__, or
+
+ 1. __[doctools::idx](../doctools2idx/idx_container.md)__
+
+Within the system architecture this package resides under the package
+__[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__ providing the general
+message catalog management within the system. *Note* that there is *no* explicit
+dependency between the manager and catalog packages. The catalog is a plugin
+which is selected and loaded dynamically.
+
+# API
+
+This package has no exported API.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[FR](../../../../index.md#fr), [catalog
+package](../../../../index.md#catalog_package),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools), [i18n](../../../../index.md#i18n),
+[internationalization](../../../../index.md#internationalization),
+[l10n](../../../../index.md#l10n),
+[localization](../../../../index.md#localization), [message
+catalog](../../../../index.md#message_catalog), [message
+package](../../../../index.md#message_package)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_parse.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_parse.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_parse.md
@@ -0,0 +1,323 @@
+
+[//000000001]: # (doctools::toc::parse - Documentation tools)
+[//000000002]: # (Generated from file 'toc_parse.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::parse(n) 1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::parse - Parsing text in doctoc format
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Parse errors](#section3)
+
+ - [[doctoc] notation of tables of contents](#section4)
+
+ - [ToC serialization format](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::toc::parse ?0.1?
+package require Tcl 8.4
+package require doctools::toc::structure
+package require doctools::msgcat
+package require doctools::tcl::parse
+package require fileutil
+package require logger
+package require snit
+package require struct::list
+package require struct::stack
+
+[__::doctools::toc::parse__ __text__ *text*](#1)
+[__::doctools::toc::parse__ __file__ *path*](#2)
+[__::doctools::toc::parse__ __includes__](#3)
+[__::doctools::toc::parse__ __include add__ *path*](#4)
+[__::doctools::toc::parse__ __include remove__ *path*](#5)
+[__::doctools::toc::parse__ __include clear__](#6)
+[__::doctools::toc::parse__ __vars__](#7)
+[__::doctools::toc::parse__ __var set__ *name* *value*](#8)
+[__::doctools::toc::parse__ __var unset__ *name*](#9)
+[__::doctools::toc::parse__ __var clear__ ?*pattern*?](#10)
+
+# DESCRIPTION
+
+This package provides commands to parse text written in the
+*[doctoc](../../../../index.md#doctoc)* markup language and convert it into the
+canonical serialization of the table of contents encoded in the text. See the
+section [ToC serialization format](#section5) for specification of their format.
+
+This is an internal package of doctools, for use by the higher level packages
+handling *[doctoc](../../../../index.md#doctoc)* documents.
+
+# API
+
+ - __::doctools::toc::parse__ __text__ *text*
+
+ The command takes the string contained in *text* and parses it under the
+ assumption that it contains a document written using the
+ *[doctoc](../../../../index.md#doctoc)* markup language. An error is thrown
+ if this assumption is found to be false. The format of these errors is
+ described in section [Parse errors](#section3).
+
+ When successful the command returns the canonical serialization of the table
+ of contents which was encoded in the text. See the section [ToC
+ serialization format](#section5) for specification of that format.
+
+ - __::doctools::toc::parse__ __file__ *path*
+
+ The same as __text__, except that the text to parse is read from the file
+ specified by *path*.
+
+ - __::doctools::toc::parse__ __includes__
+
+ This method returns the current list of search paths used when looking for
+ include files.
+
+ - __::doctools::toc::parse__ __include add__ *path*
+
+ This method adds the *path* to the list of paths searched when looking for
+ an include file. The call is ignored if the path is already in the list of
+ paths. The method returns the empty string as its result.
+
+ - __::doctools::toc::parse__ __include remove__ *path*
+
+ This method removes the *path* from the list of paths searched when looking
+ for an include file. The call is ignored if the path is not contained in the
+ list of paths. The method returns the empty string as its result.
+
+ - __::doctools::toc::parse__ __include clear__
+
+ This method clears the list of search paths for include files.
+
+ - __::doctools::toc::parse__ __vars__
+
+ This method returns a dictionary containing the current set of predefined
+ variables known to the __vset__ markup command during processing.
+
+ - __::doctools::toc::parse__ __var set__ *name* *value*
+
+ This method adds the variable *name* to the set of predefined variables
+ known to the __vset__ markup command during processing, and gives it the
+ specified *value*. The method returns the empty string as its result.
+
+ - __::doctools::toc::parse__ __var unset__ *name*
+
+ This method removes the variable *name* from the set of predefined variables
+ known to the __vset__ markup command during processing. The method returns
+ the empty string as its result.
+
+ - __::doctools::toc::parse__ __var clear__ ?*pattern*?
+
+ This method removes all variables matching the *pattern* from the set of
+ predefined variables known to the __vset__ markup command during processing.
+ The method returns the empty string as its result.
+
+ The pattern matching is done with __string match__, and the default pattern
+ used when none is specified, is __*__.
+
+# Parse errors
+
+The format of the parse error messages thrown when encountering violations of
+the *[doctoc](../../../../index.md#doctoc)* markup syntax is human readable and
+not intended for processing by machines. As such it is not documented.
+
+*However*, the errorCode attached to the message is machine-readable and has the
+following format:
+
+ 1. The error code will be a list, each element describing a single error found
+ in the input. The list has at least one element, possibly more.
+
+ 1. Each error element will be a list containing six strings describing an
+ error in detail. The strings will be
+
+ 1) The path of the file the error occurred in. This may be empty.
+
+ 1) The range of the token the error was found at. This range is a
+ two-element list containing the offset of the first and last character
+ in the range, counted from the beginning of the input (file). Offsets
+ are counted from zero.
+
+ 1) The line the first character after the error is on. Lines are counted
+ from one.
+
+ 1) The column the first character after the error is at. Columns are
+ counted from zero.
+
+ 1) The message code of the error. This value can be used as argument to
+ __msgcat::mc__ to obtain a localized error message, assuming that the
+ application had a suitable call of __doctools::msgcat::init__ to
+ initialize the necessary message catalogs (See package
+ __[doctools::msgcat](../doctools2base/tcllib_msgcat.md)__).
+
+ 1) A list of details for the error, like the markup command involved. In
+ the case of message code __doctoc/include/syntax__ this value is the
+ set of errors found in the included file, using the format described
+ here.
+
+# [doctoc] notation of tables of contents
+
+The doctoc format for tables of contents, also called the *doctoc markup
+language*, is too large to be covered in single section. The interested reader
+should start with the document
+
+ 1. *[doctoc language introduction](../doctools/doctoc_lang_intro.md)*
+
+and then proceed from there to the formal specifications, i.e. the documents
+
+ 1. *[doctoc language syntax](../doctools/doctoc_lang_syntax.md)* and
+
+ 1. *[doctoc language command reference](../doctools/doctoc_lang_cmdref.md)*.
+
+to get a thorough understanding of the language.
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools), [lexer](../../../../index.md#lexer),
+[parser](../../../../index.md#parser)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/doctools2toc/toc_structure.md
Index: embedded/md/tcllib/files/modules/doctools2toc/toc_structure.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/doctools2toc/toc_structure.md
@@ -0,0 +1,271 @@
+
+[//000000001]: # (doctools::toc::structure - Documentation tools)
+[//000000002]: # (Generated from file 'toc_structure.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (doctools::toc::structure(n) 0.1 tcllib "Documentation tools")
+
+# NAME
+
+doctools::toc::structure - Doctoc serialization utilities
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [ToC serialization format](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require doctools::toc::structure ?0.1?
+package require Tcl 8.4
+package require logger
+package require snit
+
+[__::doctools::toc::structure__ __verify__ *serial* ?*canonvar*?](#1)
+[__::doctools::toc::structure__ __verify-as-canonical__ *serial*](#2)
+[__::doctools::toc::structure__ __canonicalize__ *serial*](#3)
+[__::doctools::toc::structure__ __print__ *serial*](#4)
+[__::doctools::toc::structure__ __merge__ *seriala* *serialb*](#5)
+
+# DESCRIPTION
+
+This package provides commands to work with the serializations of tables of
+contents as managed by the doctools system v2, and specified in section [ToC
+serialization format](#section3).
+
+This is an internal package of doctools, for use by the higher level packages
+handling tables of contents and their conversion into and out of various other
+formats, like documents written using *[doctoc](../../../../index.md#doctoc)*
+markup.
+
+# API
+
+ - __::doctools::toc::structure__ __verify__ *serial* ?*canonvar*?
+
+ This command verifies that the content of *serial* is a valid *regular*
+ serialization of a table of contents and will throw an error if that is not
+ the case. The result of the command is the empty string.
+
+ If the argument *canonvar* is specified it is interpreted as the name of a
+ variable in the calling context. This variable will be written to if and
+ only if *serial* is a valid regular serialization. Its value will be a
+ boolean, with __True__ indicating that the serialization is not only valid,
+ but also *canonical*. __False__ will be written for a valid, but
+ non-canonical serialization.
+
+ For the specification of regular and canonical serializations see the
+ section [ToC serialization format](#section3).
+
+ - __::doctools::toc::structure__ __verify-as-canonical__ *serial*
+
+ This command verifies that the content of *serial* is a valid *canonical*
+ serialization of a table of contents and will throw an error if that is not
+ the case. The result of the command is the empty string.
+
+ For the specification of canonical serializations see the section [ToC
+ serialization format](#section3).
+
+ - __::doctools::toc::structure__ __canonicalize__ *serial*
+
+ This command assumes that the content of *serial* is a valid *regular*
+ serialization of a table of contents and will throw an error if that is not
+ the case.
+
+ It will then convert the input into the *canonical* serialization of the
+ contained table of contents and return it as its result. If the input is
+ already canonical it will be returned unchanged.
+
+ For the specification of regular and canonical serializations see the
+ section [ToC serialization format](#section3).
+
+ - __::doctools::toc::structure__ __print__ *serial*
+
+ This command assumes that the argument *serial* contains a valid regular
+ serialization of a table of contents and returns a string containing that
+ table in a human readable form.
+
+ The exact format of this form is not specified and cannot be relied on for
+ parsing or other machine-based activities.
+
+ For the specification of regular serializations see the section [ToC
+ serialization format](#section3).
+
+ - __::doctools::toc::structure__ __merge__ *seriala* *serialb*
+
+ This command accepts the regular serializations of two tables of contents
+ and uses them to create their union. The result of the command is the
+ canonical serialization of this unified table of contents.
+
+ Title and label of the resulting table are taken from the table contained in
+ *serialb*.
+
+ The whole table and its divisions are merged recursively in the same manner:
+
+ All reference elements which occur in both divisions (identified by their
+ label) are unified with document id's and descriptions taken from the second
+ table.
+
+ All division elements which occur in both divisions (identified by their
+ label) are unified with the optional document id taken from the second
+ table, if any, or from the first if none is in the second. The elements in
+ the division are merged recursively using the same algorithm as described in
+ this list.
+
+ Type conflicts between elements, i.e. finding two elements with the same
+ label but different types result in a merge error.
+
+ All elements found in the second division but not in the first are added to
+ the end of the list of elements in the merge result.
+
+ For the specification of regular and canonical serializations see the
+ section [ToC serialization format](#section3).
+
+# ToC serialization format
+
+Here we specify the format used by the doctools v2 packages to serialize tables
+of contents as immutable values for transport, comparison, etc.
+
+We distinguish between *regular* and *canonical* serializations. While a table
+of contents may have more than one regular serialization only exactly one of
+them will be *canonical*.
+
+ - regular serialization
+
+ The serialization of any table of contents is a nested Tcl dictionary.
+
+ This dictionary holds a single key, __doctools::toc__, and its value. This
+ value holds the contents of the table of contents.
+
+ The contents of the table of contents are a Tcl dictionary holding the title
+ of the table of contents, a label, and its elements. The relevant keys and
+ their values are
+
+ * __title__
+
+ The value is a string containing the title of the table of
+ contents.
+
+ * __label__
+
+ The value is a string containing a label for the table of contents.
+
+ * __items__
+
+ The value is a Tcl list holding the elements of the table, in the
+ order they are to be shown.
+
+ Each element is a Tcl list holding the type of the item, and its
+ description, in this order. An alternative description would be
+ that it is a Tcl dictionary holding a single key, the item type,
+ mapped to the item description.
+
+ The two legal item types and their descriptions are
+
+ + __reference__
+
+ This item describes a single entry in the table of contents,
+ referencing a single document. To this end its value is a Tcl
+ dictionary containing an id for the referenced document, a
+ label, and a longer textual description which can be associated
+ with the entry. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the entry.
+
+ - __label__
+
+ The value is a string containing a label for this entry.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __desc__
+
+ The value is a string containing a longer description for
+ this entry.
+
+ + __division__
+
+ This item describes a group of entries in the table of
+ contents, inducing a hierarchy of entries. To this end its
+ value is a Tcl dictionary containing a label for the group, an
+ optional id to a document for the whole group, and the list of
+ entries in the group. The relevant keys and their values are
+
+ - __id__
+
+ The value is a string containing the id of the document
+ associated with the whole group. This key is optional.
+
+ - __label__
+
+ The value is a string containing a label for the group.
+ This string also identifies the entry, and no two entries
+ (references and divisions) in the containing list are
+ allowed to have the same label.
+
+ - __items__
+
+ The value is a Tcl list holding the elements of the group,
+ in the order they are to be shown. This list has the same
+ structure as the value for the keyword __items__ used to
+ describe the whole table of contents, see above. This
+ closes the recusrive definition of the structure, with
+ divisions holding the same type of elements as the whole
+ table of contents, including other divisions.
+
+ - canonical serialization
+
+ The canonical serialization of a table of contents has the format as
+ specified in the previous item, and then additionally satisfies the
+ constraints below, which make it unique among all the possible
+ serializations of this table of contents.
+
+ The keys found in all the nested Tcl dictionaries are sorted in ascending
+ dictionary order, as generated by Tcl's builtin command __lsort -increasing
+ -dict__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[deserialization](../../../../index.md#deserialization),
+[doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools),
+[serialization](../../../../index.md#serialization)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/dtplite/pkg_dtplite.md
Index: embedded/md/tcllib/files/modules/dtplite/pkg_dtplite.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/dtplite/pkg_dtplite.md
@@ -0,0 +1,401 @@
+
+[//000000001]: # (dtplite - Documentation toolbox)
+[//000000002]: # (Generated from file 'pkg_dtplite.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (dtplite(n) 1.3.1 tcllib "Documentation toolbox")
+
+# NAME
+
+dtplite - Lightweight DocTools Markup Processor
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [USE CASES](#subsection1)
+
+ - [COMMAND LINE](#subsection2)
+
+ - [OPTIONS](#subsection3)
+
+ - [FORMATS](#subsection4)
+
+ - [DIRECTORY STRUCTURES](#subsection5)
+
+ - [Bugs, Ideas, Feedback](#section2)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require dtplite ?1.3.1?
+
+[__[dtplite](../../apps/dtplite.md)__ __-o__ *output* ?options? *format* *inputfile*](#1)
+[__[dtplite](../../apps/dtplite.md)__ __validate__ *inputfile*](#2)
+[__[dtplite](../../apps/dtplite.md)__ __-o__ *output* ?options? *format* *inputdirectory*](#3)
+[__[dtplite](../../apps/dtplite.md)__ __-merge__ __-o__ *output* ?options? *format* *inputdirectory*](#4)
+
+# DESCRIPTION
+
+The application described by this document,
+__[dtplite](../../apps/dtplite.md)__, is the successor to the extremely simple
+__[mpexpand](../doctools/mpexpand.md)__. Influenced in its functionality by the
+__dtp__ doctools processor it is much more powerful than
+__[mpexpand](../doctools/mpexpand.md)__, yet still as easy to use; definitely
+easier than __dtp__ with its myriad of subcommands and options.
+
+__[dtplite](../../apps/dtplite.md)__ is based upon the package
+__[doctools](../doctools/doctools.md)__, like the other two processors.
+
+## USE CASES
+
+__[dtplite](../../apps/dtplite.md)__ was written with the following three use
+cases in mind.
+
+ 1. Validation of a single document, i.e. checking that it was written in valid
+ doctools format. This mode can also be used to get a preliminary version of
+ the formatted output for a single document, for display in a browser,
+ nroff, etc., allowing proofreading of the formatting.
+
+ 1. Generation of the formatted documentation for a single package, i.e. all
+ the manpages, plus a table of contents and an index of keywords.
+
+ 1. An extension of the previous mode of operation, a method for the easy
+ generation of one documentation tree for several packages, and especially
+ of a unified table of contents and keyword index.
+
+Beyond the above we also want to make use of the customization features provided
+by the HTML formatter. It is not the only format the application should be able
+to generate, but we anticipiate it to be the most commonly used, and it is one
+of the few which do provide customization hooks.
+
+We allow the caller to specify a header string, footer string, a stylesheet, and
+data for a bar of navigation links at the top of the generated document. While
+all can be set as long as the formatting engine provides an appropriate engine
+parameter (See section [OPTIONS](#subsection3)) the last two have internal
+processing which make them specific to HTML.
+
+## COMMAND LINE
+
+ - __[dtplite](../../apps/dtplite.md)__ __-o__ *output* ?options? *format* *inputfile*
+
+ This is the form for use case [1]. The *options* will be explained later, in
+ section [OPTIONS](#subsection3).
+
+ * path *output* (in)
+
+ This argument specifies where to write the generated document. It can be
+ the path to a file or directory, or __-__. The last value causes the
+ application to write the generated documented to __stdout__.
+
+ If the *output* does not exist then [file dirname $output] has to exist
+ and must be a writable directory. The generated document will be written
+ to a file in that directory, and the name of that file will be derived
+ from the *inputfile*, the *format*, and the value given to option
+ __-ext__ (if present).
+
+ * (path|handle) *format* (in)
+
+ This argument specifies the formatting engine to use when processing the
+ input, and thus the format of the generated document. See section
+ [FORMATS](#subsection4) for the possibilities recognized by the
+ application.
+
+ * path *inputfile* (in)
+
+ This argument specifies the path to the file to process. It has to
+ exist, must be readable, and written in
+ *[doctools](../../../../index.md#doctools)* format.
+
+ - __[dtplite](../../apps/dtplite.md)__ __validate__ *inputfile*
+
+ This is a simpler form for use case [1]. The "validate" format generates no
+ output at all, only syntax checks are performed. As such the specification
+ of an output file or other options is not necessary and left out.
+
+ - __[dtplite](../../apps/dtplite.md)__ __-o__ *output* ?options? *format* *inputdirectory*
+
+ This is the form for use case [2]. It differs from the form for use case [1]
+ by having the input documents specified through a directory instead of a
+ file. The other arguments are identical, except for *output*, which now has
+ to be the path to an existing and writable directory.
+
+ The input documents are all files in *inputdirectory* or any of its
+ subdirectories which were recognized by __fileutil::fileType__ as containing
+ text in *[doctools](../../../../index.md#doctools)* format.
+
+ - __[dtplite](../../apps/dtplite.md)__ __-merge__ __-o__ *output* ?options? *format* *inputdirectory*
+
+ This is the form for use case [3]. The only difference to the form for use
+ case [2] is the additional option __-merge__.
+
+ Each such call will merge the generated documents coming from processing the
+ input documents under *inputdirectory* or any of its subdirectories to the
+ files under *output*. In this manner it is possible to incrementally build
+ the unified documentation for any number of packages. Note that it is
+ necessary to run through all the packages twice to get fully correct
+ cross-references (for formats supporting them).
+
+## OPTIONS
+
+This section describes all the options available to the user of the application,
+with the exception of the options __-o__ and __-merge__. These two were
+described already, in section [COMMAND LINE](#subsection2).
+
+ - __-exclude__ string
+
+ This option specifies an exclude (glob) pattern. Any files identified as
+ manpages to process which match the exclude pattern are ignored. The option
+ can be provided multiple times, each usage adding an additional pattern to
+ the list of exclusions.
+
+ - __-ext__ string
+
+ If the name of an output file has to be derived from the name of an input
+ file it will use the name of the *format* as the extension by default. This
+ option here will override this however, forcing it to use *string* as the
+ file extension. This option is ignored if the name of the output file is
+ fully specified through option __-o__.
+
+ When used multiple times only the last definition is relevant.
+
+ - __-header__ file
+
+ This option can be used if and only if the selected *format* provides an
+ engine parameter named "header". It takes the contents of the specified file
+ and assign them to that parameter, for whatever use by the engine. The HTML
+ engine will insert the text just after the tag ____. If navigation
+ buttons are present (see option __-nav__ below), then the HTML generated for
+ them is appended to the header data originating here before the final
+ assignment to the parameter.
+
+ When used multiple times only the last definition is relevant.
+
+ - __-footer__ file
+
+ Like __-header__, except that: Any navigation buttons are ignored, the
+ corresponding required engine parameter is named "footer", and the data is
+ inserted just before the tag ____.
+
+ When used multiple times only the last definition is relevant.
+
+ - __-style__ file
+
+ This option can be used if and only if the selected *format* provides an
+ engine parameter named "meta". When specified it will generate a piece of
+ HTML code declaring the *file* as the stylesheet for the generated document
+ and assign that to the parameter. The HTML engine will insert this inot the
+ document, just after the tag ____.
+
+ When processing an input directory the stylesheet file is copied into the
+ output directory and the generated HTML will refer to the copy, to make the
+ result more self-contained. When processing an input file we have no
+ location to copy the stylesheet to and so just reference it as specified.
+
+ When used multiple times only the last definition is relevant.
+
+ - __-toc__ path|text
+
+ This option specifies a doctoc file (or text) to use for the table of
+ contents instead of generating our own.
+
+ When used multiple times only the last definition is relevant.
+
+ - __-pre+toc__ label path|text
+
+ - __-post+toc__ label path|text
+
+ This option specifies additional doctoc files (or texts) to use in the
+ navigation bar.
+
+ Positioning and handling of multiple uses is like for options __-prenav__
+ and __-postnav__, see below.
+
+ - __-nav__ label url
+
+ - __-prenav__ label url
+
+ Use this option to specify a navigation button with *label* to display and
+ the *url* to link to. This option can be used if and only if the selected
+ *format* provides an engine parameter named "header". The HTML generated for
+ this is appended to whatever data we got from option __-header__ before it
+ is inserted into the generated documents.
+
+ When used multiple times all definitions are collected and a navigation bar
+ is created, with the first definition shown at the left edge and the last
+ definition to the right.
+
+ The url can be relative. In that case it is assumed to be relative to the
+ main files (TOC and Keyword index), and will be transformed for all others
+ to still link properly.
+
+ - __-postnav__ label url
+
+ Use this option to specify a navigation button with *label* to display and
+ the *url* to link to. This option can be used if and only if the selected
+ *format* provides an engine parameter named "header". The HTML generated for
+ this is appended to whatever data we got from option __-header__ before it
+ is inserted into the generated documents.
+
+ When used multiple times all definitions are collected and a navigation bar
+ is created, with the last definition shown at the right edge and the first
+ definition to the left.
+
+ The url can be relative. In that case it is assumed to be relative to the
+ main files (TOC and Keyword index), and will be transformed for all others
+ to still link properly.
+
+## FORMATS
+
+At first the *format* argument will be treated as a path to a tcl file
+containing the code for the requested formatting engine. The argument will be
+treated as the name of one of the predefined formats listed below if and only if
+the path does not exist.
+
+*Note a limitation*: If treating the format as path to the tcl script
+implementing the engine was sucessful, then this script has to implement not
+only the engine API for doctools, i.e. *doctools_api*, but for *doctoc_api* and
+*docidx_api* as well. Otherwise the generation of a table of contents and of a
+keyword index will fail.
+
+List of predefined formats, i.e. as provided by the package
+__[doctools](../doctools/doctools.md)__:
+
+ - __nroff__
+
+ The processor generates *roff output, the standard format for unix manpages.
+
+ - __html__
+
+ The processor generates HTML output, for usage in and display by web
+ browsers. This engine is currently the only one providing the various engine
+ parameters required for the additional customaization of the output.
+
+ - __tmml__
+
+ The processor generates TMML output, the Tcl Manpage Markup Language, a
+ derivative of XML.
+
+ - __latex__
+
+ The processor generates LaTeX output.
+
+ - __wiki__
+
+ The processor generates Wiki markup as understood by __wikit__.
+
+ - __list__
+
+ The processor extracts the information provided by __manpage_begin__. This
+ format is used internally to extract the meta data from which both table of
+ contents and keyword index are derived from.
+
+ - __null__
+
+ The processor does not generate any output. This is equivalent to
+ __validate__.
+
+## DIRECTORY STRUCTURES
+
+In this section we describe the directory structures generated by the
+application under *output* when processing all documents in an *inputdirectory*.
+In other words, this is only relevant to the use cases [2] and [3].
+
+ - [2]
+
+ The following directory structure is created when processing a single set of
+ input documents. The file extension used is for output in HTML, but that is
+ not relevant to the structure and was just used to have proper file names.
+
+ output/
+ toc.html
+ index.html
+ files/
+ path/to/FOO.html
+
+ The last line in the example shows the document generated for a file FOO
+ located at
+
+ inputdirectory/path/to/FOO
+
+ - [3]
+
+ When merging many packages into a unified set of documents the generated
+ directory structure is a bit deeper:
+
+ output
+ .toc
+ .idx
+ .tocdoc
+ .idxdoc
+ .xrf
+ toc.html
+ index.html
+ FOO1/
+ ...
+ FOO2/
+ toc.html
+ files/
+ path/to/BAR.html
+
+ Each of the directories FOO1, ... contains the documents generated for the
+ package FOO1, ... and follows the structure shown for use case [2]. The only
+ exception is that there is no per-package index.
+
+ The files ".toc", ".idx", and ".xrf" contain the internal status of the
+ whole output and will be read and updated by the next invokation. Their
+ contents will not be documented. Remove these files when all packages wanted
+ for the output have been processed, i.e. when the output is complete.
+
+ The files ".tocdoc", and ".idxdoc", are intermediate files in doctoc and
+ docidx markup, respectively, containing the main table of contents and
+ keyword index for the set of documents before their conversion to the chosen
+ output format. They are left in place, i.e. not deleted, to serve as
+ demonstrations of doctoc and docidx markup.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *doctools* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[docidx introduction](../doctools/docidx_intro.md), [doctoc
+introduction](../doctools/doctoc_intro.md), [doctools
+introduction](../doctools/doctools_intro.md)
+
+# KEYWORDS
+
+[HTML](../../../../index.md#html), [TMML](../../../../index.md#tmml),
+[conversion](../../../../index.md#conversion),
+[docidx](../../../../index.md#docidx), [doctoc](../../../../index.md#doctoc),
+[doctools](../../../../index.md#doctools),
+[manpage](../../../../index.md#manpage), [markup](../../../../index.md#markup),
+[nroff](../../../../index.md#nroff)
+
+# CATEGORY
+
+Documentation tools
+
+# COPYRIGHT
+
+Copyright © 2004-2013 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/fileutil/fileutil.md
Index: embedded/md/tcllib/files/modules/fileutil/fileutil.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fileutil/fileutil.md
@@ -0,0 +1,528 @@
+
+[//000000001]: # (fileutil - file utilities)
+[//000000002]: # (Generated from file 'fileutil.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil(n) 1.16 tcllib "file utilities")
+
+# NAME
+
+fileutil - Procedures implementing some file utilities
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Warnings and Incompatibilities](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8
+package require fileutil ?1.16?
+
+[__::fileutil::lexnormalize__ *path*](#1)
+[__::fileutil::fullnormalize__ *path*](#2)
+[__::fileutil::test__ *path* *codes* ?*msgvar*? ?*label*?](#3)
+[__::fileutil::cat__ (?*options*? *file*)...](#4)
+[__::fileutil::writeFile__ ?*options*? *file* *data*](#5)
+[__::fileutil::appendToFile__ ?*options*? *file* *data*](#6)
+[__::fileutil::insertIntoFile__ ?*options*? *file* *at* *data*](#7)
+[__::fileutil::removeFromFile__ ?*options*? *file* *at* *n*](#8)
+[__::fileutil::replaceInFile__ ?*options*? *file* *at* *n* *data*](#9)
+[__::fileutil::updateInPlace__ ?*options*? *file* *cmd*](#10)
+[__::fileutil::fileType__ *filename*](#11)
+[__::fileutil::find__ ?*basedir* ?*filtercmd*??](#12)
+[__::fileutil::findByPattern__ *basedir* ?__-regexp__|__-glob__? ?__--__? *patterns*](#13)
+[__::fileutil::foreachLine__ *var filename cmd*](#14)
+[__::fileutil::grep__ *pattern* ?*files*?](#15)
+[__::fileutil::install__ ?__-m__ *mode*? *source* *destination*](#16)
+[__::fileutil::stripN__ *path* *n*](#17)
+[__::fileutil::stripPwd__ *path*](#18)
+[__::fileutil::stripPath__ *prefix* *path*](#19)
+[__::fileutil::jail__ *jail* *path*](#20)
+[__::fileutil::touch__ ?__-a__? ?__-c__? ?__-m__? ?__-r__ *ref_file*? ?__-t__ *time*? *filename* ?*...*?](#21)
+[__::fileutil::tempdir__](#22)
+[__::fileutil::tempdir__ *path*](#23)
+[__::fileutil::tempdirReset__](#24)
+[__::fileutil::tempfile__ ?*prefix*?](#25)
+[__::fileutil::maketempdir__ ?__-prefix__ *str*? ?__-suffix__ *str*? ?__-dir__ *str*?](#26)
+[__::fileutil::relative__ *base* *dst*](#27)
+[__::fileutil::relativeUrl__ *base* *dst*](#28)
+
+# DESCRIPTION
+
+This package provides implementations of standard unix utilities.
+
+ - __::fileutil::lexnormalize__ *path*
+
+ This command performs purely lexical normalization on the *path* and returns
+ the changed path as its result. Symbolic links in the path are *not*
+ resolved.
+
+ Examples:
+
+ fileutil::lexnormalize /foo/./bar
+ => /foo/bar
+
+ fileutil::lexnormalize /foo/../bar
+ => /bar
+
+ - __::fileutil::fullnormalize__ *path*
+
+ This command resolves all symbolic links in the *path* and returns the
+ changed path as its result. In contrast to the builtin __file normalize__
+ this command resolves a symbolic link in the last element of the path as
+ well.
+
+ - __::fileutil::test__ *path* *codes* ?*msgvar*? ?*label*?
+
+ A command for the testing of several properties of a *path*. The properties
+ to test for are specified in *codes*, either as a list of keywords
+ describing the properties, or as a string where each letter is a shorthand
+ for a property to test. The recognized keywords, shorthands, and associated
+ properties are shown in the list below. The tests are executed in the order
+ given to the command.
+
+ The result of the command is a boolean value. It will be true if and only if
+ the *path* passes all the specified tests. In the case of the *path* not
+ passing one or more test the first failing test will leave a message in the
+ variable referenced by *msgvar*, if such is specified. The message will be
+ prefixed with *label*, if it is specified. *Note* that the variabled
+ referenced by *msgvar* is not touched at all if all the tests pass.
+
+ * *r*ead
+
+ __file readable__
+
+ * *w*rite
+
+ __file writable__
+
+ * *e*xists
+
+ __file exists__
+
+ * e*x*ec
+
+ __file executable__
+
+ * *f*ile
+
+ __file isfile__
+
+ * *d*ir
+
+ __file isdirectory__
+
+ - __::fileutil::cat__ (?*options*? *file*)...
+
+ A tcl implementation of the UNIX __[cat](../../../../index.md#cat)__
+ command. Returns the contents of the specified file(s). The arguments are
+ files to read, with interspersed options configuring the process. If there
+ are problems reading any of the files, an error will occur, and no data will
+ be returned.
+
+ The options accepted are __-encoding__, __-translation__, __-eofchar__, and
+ __--__. With the exception of the last all options take a single value as
+ argument, as specified by the tcl builtin command __fconfigure__. The __--__
+ has to be used to terminate option processing before a file if that file's
+ name begins with a dash.
+
+ Each file can have its own set of options coming before it, and for anything
+ not specified directly the defaults are inherited from the options of the
+ previous file. The first file inherits the system default for unspecified
+ options.
+
+ - __::fileutil::writeFile__ ?*options*? *file* *data*
+
+ The command replaces the current contents of the specified *file* with
+ *data*, with the process configured by the options. The command accepts the
+ same options as __::fileutil::cat__. The specification of a non-existent
+ file is legal and causes the command to create the file (and all required
+ but missing directories).
+
+ - __::fileutil::appendToFile__ ?*options*? *file* *data*
+
+ This command is like __::fileutil::writeFile__, except that the previous
+ contents of *file* are not replaced, but appended to. The command accepts
+ the same options as __::fileutil::cat__
+
+ - __::fileutil::insertIntoFile__ ?*options*? *file* *at* *data*
+
+ This comment is similar to __::fileutil::appendToFile__, except that the new
+ data is not appended at the end, but inserted at a specified location within
+ the file. In further contrast this command has to be given the path to an
+ existing file. It will not create a missing file, but throw an error
+ instead.
+
+ The specified location *at* has to be an integer number in the range __0__
+ ... [file size *file*]. __0__ will cause insertion of the new data before
+ the first character of the existing content, whereas [file size *file*]
+ causes insertion after the last character of the existing content, i.e.
+ appending.
+
+ The command accepts the same options as __::fileutil::cat__.
+
+ - __::fileutil::removeFromFile__ ?*options*? *file* *at* *n*
+
+ This command is the complement to __::fileutil::insertIntoFile__, removing
+ *n* characters from the *file*, starting at location *at*. The specified
+ location *at* has to be an integer number in the range __0__ ... [file size
+ *file*] - *n*. __0__ will cause the removal of the new data to start with
+ the first character of the existing content, whereas [file size *file*] -
+ *n* causes the removal of the tail of the existing content, i.e. the
+ truncation of the file.
+
+ The command accepts the same options as __::fileutil::cat__.
+
+ - __::fileutil::replaceInFile__ ?*options*? *file* *at* *n* *data*
+
+ This command is a combination of __::fileutil::removeFromFile__ and
+ __::fileutil::insertIntoFile__. It first removes the part of the contents
+ specified by the arguments *at* and *n*, and then inserts *data* at the
+ given location, effectively replacing the removed by content with *data*.
+ All constraints imposed on *at* and *n* by __::fileutil::removeFromFile__
+ and __::fileutil::insertIntoFile__ are obeyed.
+
+ The command accepts the same options as __::fileutil::cat__.
+
+ - __::fileutil::updateInPlace__ ?*options*? *file* *cmd*
+
+ This command can be seen as the generic core functionality of
+ __::fileutil::replaceInFile__. It first reads the contents of the specified
+ *file*, then runs the command prefix *cmd* with that data appended to it,
+ and at last writes the result of that invokation back as the new contents of
+ the file.
+
+ If the executed command throws an error the *file* is not changed.
+
+ The command accepts the same options as __::fileutil::cat__.
+
+ - __::fileutil::fileType__ *filename*
+
+ An implementation of the UNIX __[file](../../../../index.md#file)__ command,
+ which uses various heuristics to guess the type of a file. Returns a list
+ specifying as much type information as can be determined about the file,
+ from most general (eg, "binary" or "text") to most specific (eg, "gif"). For
+ example, the return value for a GIF file would be "binary graphic gif". The
+ command will detect the following types of files: directory, empty, binary,
+ text, script (with interpreter), executable elf, executable dos, executable
+ ne, executable pe, graphic gif, graphic jpeg, graphic png, graphic tiff,
+ graphic bitmap, html, xml (with doctype if available), message pgp, binary
+ pdf, text ps, text eps, binary gravity_wave_data_frame, compressed bzip,
+ compressed gzip, compressed zip, compressed tar, audio wave, audio mpeg, and
+ link. It further detects doctools, doctoc, and docidx documentation files,
+ and tklib diagrams.
+
+ - __::fileutil::find__ ?*basedir* ?*filtercmd*??
+
+ An implementation of the unix command __[find](../../../../index.md#find)__.
+ Adapted from the Tcler's Wiki. Takes at most two arguments, the path to the
+ directory to start searching from and a command to use to evaluate interest
+ in each file. The path defaults to ".", i.e. the current directory. The
+ command defaults to the empty string, which means that all files are of
+ interest. The command takes care *not* to lose itself in infinite loops upon
+ encountering circular link structures. The result of the command is a list
+ containing the paths to the interesting files.
+
+ The *filtercmd*, if specified, is interpreted as a command prefix and one
+ argument is added to it, the name of the file or directory find is currently
+ looking at. Note that this name is *not* fully qualified. It has to be
+ joined it with the result of __pwd__ to get an absolute filename.
+
+ The result of *filtercmd* is a boolean value that indicates if the current
+ file should be included in the list of interesting files.
+
+ Example:
+
+ # find .tcl files
+ package require fileutil
+ proc is_tcl {name} {return [string match *.tcl $name]}
+ set tcl_files [fileutil::find . is_tcl]
+
+ - __::fileutil::findByPattern__ *basedir* ?__-regexp__|__-glob__? ?__--__? *patterns*
+
+ This command is based upon the __TclX__ command __recursive_glob__, except
+ that it doesn't allow recursion over more than one directory at a time. It
+ uses __::fileutil::find__ internally and is thus able to and does follow
+ symbolic links, something the __TclX__ command does not do. First argument
+ is the directory to start the search in, second argument is a list of
+ *patterns*. The command returns a list of all files reachable through
+ *basedir* whose names match at least one of the patterns. The options before
+ the pattern-list determine the style of matching, either regexp or glob.
+ glob-style matching is the default if no options are given. Usage of the
+ option __--__ stops option processing. This allows the use of a leading '-'
+ in the patterns.
+
+ - __::fileutil::foreachLine__ *var filename cmd*
+
+ The command reads the file *filename* and executes the script *cmd* for
+ every line in the file. During the execution of the script the variable
+ *var* is set to the contents of the current line. The return value of this
+ command is the result of the last invocation of the script *cmd* or the
+ empty string if the file was empty.
+
+ - __::fileutil::grep__ *pattern* ?*files*?
+
+ Implementation of __[grep](../../../../index.md#grep)__. Adapted from the
+ Tcler's Wiki. The first argument defines the *pattern* to search for. This
+ is followed by a list of *files* to search through. The list is optional and
+ __stdin__ will be used if it is missing. The result of the procedures is a
+ list containing the matches. Each match is a single element of the list and
+ contains filename, number and contents of the matching line, separated by a
+ colons.
+
+ - __::fileutil::install__ ?__-m__ *mode*? *source* *destination*
+
+ The __install__ command is similar in functionality to the __install__
+ command found on many unix systems, or the shell script distributed with
+ many source distributions (unix/install-sh in the Tcl sources, for example).
+ It copies *source*, which can be either a file or directory to
+ *destination*, which should be a directory, unless *source* is also a single
+ file. The ?-m? option lets the user specify a unix-style mode (either octal
+ or symbolic - see __file attributes__.
+
+ - __::fileutil::stripN__ *path* *n*
+
+ Removes the first *n* elements from the specified *path* and returns the
+ modified path. If *n* is greater than the number of components in *path* an
+ empty string is returned. The number of components in a given path may be
+ determined by performing __llength__ on the list returned by __file split__.
+
+ - __::fileutil::stripPwd__ *path*
+
+ If, and only if the *path* is inside of the directory returned by [__pwd__]
+ (or the current working directory itself) it is made relative to that
+ directory. In other words, the current working directory is stripped from
+ the *path*. The possibly modified path is returned as the result of the
+ command. If the current working directory itself was specified for *path*
+ the result is the string "__.__".
+
+ - __::fileutil::stripPath__ *prefix* *path*
+
+ If, and only of the *path* is inside of the directory "prefix" (or the
+ prefix directory itself) it is made relative to that directory. In other
+ words, the prefix directory is stripped from the *path*. The possibly
+ modified path is returned as the result of the command. If the prefix
+ directory itself was specified for *path* the result is the string "__.__".
+
+ - __::fileutil::jail__ *jail* *path*
+
+ This command ensures that the *path* is not escaping the directory *jail*.
+ It always returns an absolute path derived from *path* which is within
+ *jail*.
+
+ If *path* is an absolute path and already within *jail* it is returned
+ unmodified.
+
+ An absolute path outside of *jail* is stripped of its root element and then
+ put into the *jail* by prefixing it with it. The same happens if *path* is
+ relative, except that nothing is stripped of it. Before adding the *jail*
+ prefix the *path* is lexically normalized to prevent the caller from using
+ __..__ segments in *path* to escape the jail.
+
+ - __::fileutil::touch__ ?__-a__? ?__-c__? ?__-m__? ?__-r__ *ref_file*? ?__-t__ *time*? *filename* ?*...*?
+
+ Implementation of __[touch](../../../../index.md#touch)__. Alter the atime
+ and mtime of the specified files. If __-c__, do not create files if they do
+ not already exist. If __-r__, use the atime and mtime from *ref_file*. If
+ __-t__, use the integer clock value *time*. It is illegal to specify both
+ __-r__ and __-t__. If __-a__, only change the atime. If __-m__, only change
+ the mtime.
+
+ *This command is not available for Tcl versions less than 8.3.*
+
+ - __::fileutil::tempdir__
+
+ The command returns the path of a directory where the caller can place
+ temporary files, such as "/tmp" on Unix systems. The algorithm we use to
+ find the correct directory is as follows:
+
+ The directory set by an invokation of __::fileutil::tempdir__ with an
+ argument. If this is present it is tried exclusively and none of the
+ following item are tried.
+
+ The directory named in the TMPDIR environment variable.
+
+ The directory named in the TEMP environment variable.
+
+ The directory named in the TMP environment variable.
+
+ A platform specific location:
+
+ * Windows
+
+ "C:\TEMP", "C:\TMP", "\TEMP", and "\TMP" are tried in that order.
+
+ * (classic) Macintosh
+
+ The TRASH_FOLDER environment variable is used. This is most likely
+ not correct.
+
+ * Unix
+
+ The directories "/tmp", "/var/tmp", and "/usr/tmp" are tried in
+ that order.
+
+ The algorithm utilized is mainly that used in the Python standard library.
+ The exception is the first item, the ability to have the search overridden
+ by a user-specified directory.
+
+ - __::fileutil::tempdir__ *path*
+
+ In this mode the command sets the *path* as the first and only directory to
+ try as a temp. directory. See the previous item for the use of the set
+ directory. The command returns the empty string.
+
+ - __::fileutil::tempdirReset__
+
+ Invoking this command clears the information set by the last call of
+ [__::fileutil::tempdir__ *path*]. See the last item too.
+
+ - __::fileutil::tempfile__ ?*prefix*?
+
+ The command generates a temporary file name suitable for writing to, and the
+ associated file. The file name will be unique, and the file will be writable
+ and contained in the appropriate system specific temp directory. The name of
+ the file will be returned as the result of the command.
+
+ The code was taken from [http://wiki.tcl.tk/772](http://wiki.tcl.tk/772),
+ attributed to Igor Volobouev and anon.
+
+ - __::fileutil::maketempdir__ ?__-prefix__ *str*? ?__-suffix__ *str*? ?__-dir__ *str*?
+
+ The command generates a temporary directory suitable for writing to. The
+ directory name will be unique, and the directory will be writable and
+ contained in the appropriate system specific temp directory. The name of the
+ directory will be returned as the result of the command.
+
+ The three options can used to tweak the behaviour of the command:
+
+ * __-prefix__ str
+
+ The initial, fixed part of the directory name. Defaults to __tmp__ if
+ not specified.
+
+ * __-suffix__ str
+
+ The fixed tail of the directory. Defaults to the empty string if not
+ specified.
+
+ * __-dir__ str
+
+ The directory to place the new directory into. Defaults to the result of
+ __fileutil::tempdir__ if not specified.
+
+ The initial code for this was supplied by [Miguel Martinez
+ Lopez](mailto:aplicacionamedida@gmail.com).
+
+ - __::fileutil::relative__ *base* *dst*
+
+ This command takes two directory paths, both either absolute or relative and
+ computes the path of *dst* relative to *base*. This relative path is
+ returned as the result of the command. As implied in the previous sentence,
+ the command is not able to compute this relationship between the arguments
+ if one of the paths is absolute and the other relative.
+
+ *Note:* The processing done by this command is purely lexical. Symbolic
+ links are *not* taken into account.
+
+ - __::fileutil::relativeUrl__ *base* *dst*
+
+ This command takes two file paths, both either absolute or relative and
+ computes the path of *dst* relative to *base*, as seen from inside of the
+ *base*. This is the algorithm how a browser resolves a relative link found
+ in the currently shown file.
+
+ The computed relative path is returned as the result of the command. As
+ implied in the previous sentence, the command is not able to compute this
+ relationship between the arguments if one of the paths is absolute and the
+ other relative.
+
+ *Note:* The processing done by this command is purely lexical. Symbolic
+ links are *not* taken into account.
+
+# Warnings and Incompatibilities
+
+ - __1.14.9__
+
+ In this version __fileutil::find__'s broken system for handling symlinks was
+ replaced with one working correctly and properly enumerating all the legal
+ non-cyclic paths under a base directory.
+
+ While correct this means that certain pathological directory hierarchies
+ with cross-linked sym-links will now take about O(n**2) time to enumerate
+ whereas the original broken code managed O(n) due to its brokenness.
+
+ A concrete example and extreme case is the "/sys" hierarchy under Linux
+ where some hundred devices exist under both "/sys/devices" and "/sys/class"
+ with the two sub-hierarchies linking to the other, generating millions of
+ legal paths to enumerate. The structure, reduced to three devices, roughly
+ looks like
+
+ /sys/class/tty/tty0 --> ../../dev/tty0
+ /sys/class/tty/tty1 --> ../../dev/tty1
+ /sys/class/tty/tty2 --> ../../dev/tty1
+
+ /sys/dev/tty0/bus
+ /sys/dev/tty0/subsystem --> ../../class/tty
+ /sys/dev/tty1/bus
+ /sys/dev/tty1/subsystem --> ../../class/tty
+ /sys/dev/tty2/bus
+ /sys/dev/tty2/subsystem --> ../../class/tty
+
+ The command __fileutil::find__ currently has no way to escape this. When
+ having to handle such a pathological hierarchy It is recommended to switch
+ to package __fileutil::traverse__ and the same-named command it provides,
+ and then use the __-prefilter__ option to prevent the traverser from
+ following symbolic links, like so:
+
+ package require fileutil::traverse
+
+ proc NoLinks {fileName} {
+ if {[string equal [file type $fileName] link]} {
+ return 0
+ }
+ return 1
+ }
+
+ fileutil::traverse T /sys/devices -prefilter NoLinks
+ T foreach p {
+ puts $p
+ }
+ T destroy
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[cat](../../../../index.md#cat), [file
+utilities](../../../../index.md#file_utilities),
+[grep](../../../../index.md#grep), [temp file](../../../../index.md#temp_file),
+[test](../../../../index.md#test), [touch](../../../../index.md#touch),
+[type](../../../../index.md#type)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fileutil/multi.md
Index: embedded/md/tcllib/files/modules/fileutil/multi.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fileutil/multi.md
@@ -0,0 +1,87 @@
+
+[//000000001]: # (fileutil::multi - file utilities)
+[//000000002]: # (Generated from file 'multi.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::multi(n) 0.1 tcllib "file utilities")
+
+# NAME
+
+fileutil::multi - Multi-file operation, scatter/gather, standard object
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [PUBLIC API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require fileutil::multi ?0.1?
+package require fileutil::multi::op ?0.1?
+package require wip ?1.0?
+
+[__::fileutil::multi__ ?*word*...?](#1)
+
+# DESCRIPTION
+
+This package provides a single command to perform actions on multiple files
+selected by glob patterns. It is a thin layer over the package
+__[fileutil::multi::op](multiop.md)__ which provides objects for the same. This
+package simply creates a single such object and directs all file commands to it.
+
+At the core is a domain specific language allowing the easy specification of
+multi-file copy and/or move and/or deletion operations. Alternate names would be
+scatter/gather processor, or maybe even assembler. For the detailed
+specification of this language, and examples, please see the documention for the
+package __[fileutil::multi::op](multiop.md)__.
+
+# PUBLIC API
+
+The main command of the package is:
+
+ - __::fileutil::multi__ ?*word*...?
+
+ This command interprets the specified words as file commands to execute. See
+ the section __FILE API__ of the documentation for the package
+ __[fileutil::multi::op](multiop.md)__ for the set of acceptable commands,
+ their syntax, and semantics.
+
+ The result of the command is the result generated by the last file command
+ it executed.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[copy](../../../../index.md#copy), [file
+utilities](../../../../index.md#file_utilities),
+[move](../../../../index.md#move),
+[multi-file](../../../../index.md#multi_file),
+[remove](../../../../index.md#remove)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fileutil/multiop.md
Index: embedded/md/tcllib/files/modules/fileutil/multiop.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fileutil/multiop.md
@@ -0,0 +1,474 @@
+
+[//000000001]: # (fileutil::multi::op - file utilities)
+[//000000002]: # (Generated from file 'multiop.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::multi::op(n) 0.5.3 tcllib "file utilities")
+
+# NAME
+
+fileutil::multi::op - Multi-file operation, scatter/gather
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [CLASS API](#section2)
+
+ - [OBJECT API](#section3)
+
+ - [FILE API](#section4)
+
+ - [EXAMPLES](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require fileutil::multi::op ?0.5.3?
+package require wip ?1.0?
+
+[__::fileutil::multi::op__ ?*opName*? ?*word*...?](#1)
+[__opName__ *option* ?*arg arg ...*?](#2)
+[__$opName__ __do__ ?*word*...?](#3)
+[__into__ *directory*](#4)
+[__in__ *directory*](#5)
+[__to__ *directory*](#6)
+[__from__ *directory*](#7)
+[__not__ *pattern*](#8)
+[__for__ *pattern*](#9)
+[__exclude__ *pattern*](#10)
+[__but__](#11)
+[__except__](#12)
+[__as__ *name*](#13)
+[__recursive__](#14)
+[__recursively__](#15)
+[__[copy](../../../../index.md#copy)__](#16)
+[__[move](../../../../index.md#move)__](#17)
+[__[remove](../../../../index.md#remove)__](#18)
+[__expand__](#19)
+[__invoke__ *cmdprefix*](#20)
+[__reset__](#21)
+[__(__](#22)
+[__)__](#23)
+[__cd__ *directory*](#24)
+[__up__](#25)
+[__for-windows__](#26)
+[__for-win__](#27)
+[__for-unix__](#28)
+[__the__ *pattern*](#29)
+[__the-set__ *varname*](#30)
+[__->__ *varname*](#31)
+[__strict__](#32)
+[__!strict__](#33)
+[__files__](#34)
+[__links__](#35)
+[__directories__](#36)
+[__dirs__](#37)
+[__all__](#38)
+[__state?__](#39)
+[__as?__](#40)
+[__excluded?__](#41)
+[__from?__](#42)
+[__into?__](#43)
+[__operation?__](#44)
+[__recursive?__](#45)
+[__strict?__](#46)
+[__type?__](#47)
+
+# DESCRIPTION
+
+This package provides objects which are able to perform actions on multiple
+files selected by glob patterns.
+
+At the core is a domain specific language allowing the easy specification of
+multi-file copy and/or move and/or deletion operations. Alternate names would be
+scatter/gather processor, or maybe even assembler.
+
+# CLASS API
+
+The main command of the package is:
+
+ - __::fileutil::multi::op__ ?*opName*? ?*word*...?
+
+ The command creates a new multi-file operation object with an associated
+ global Tcl command whose name is *opName*. This command can be used to
+ invoke the various possible file operations. It has the following general
+ form:
+
+ * __opName__ *option* ?*arg arg ...*?
+
+ *Option* and the *arg*s determine the exact behavior of the command.
+
+ If the string __%AUTO%__ is used as the *opName* then the package will
+ generate a unique name on its own.
+
+ If one or more *word*s are specified they are interpreted as an initial set
+ of file commands to execute. I.e. the method __do__ of the newly constructed
+ object is implicitly invoked using the words as its arguments.
+
+# OBJECT API
+
+The following methods are possible for multi-file operation objects:
+
+ - __$opName__ __do__ ?*word*...?
+
+ This method interprets the specified words as file commands to execute. See
+ the section [FILE API](#section4) for the set of acceptable commands, their
+ syntax, and semantics.
+
+ The result of the method is the result generated by the last file command it
+ executed.
+
+# FILE API
+
+Both object constructor and method __do__ take a list of words and interpret
+them as file commands to execute. The names were chosen to allow the
+construction of operations as sentences in near-natural language. Most of the
+commands influence just the state of the object, i.e. are simply providing the
+configuration used by the command triggering the actual action.
+
+ - __into__ *directory*
+
+ Specifies the destination directory for operations.
+
+ - __in__ *directory*
+
+ Alias for __into__.
+
+ - __to__ *directory*
+
+ Alias for __into__.
+
+ - __from__ *directory*
+
+ Specifies the source directory for operations.
+
+ - __not__ *pattern*
+
+ Specifies a glob pattern for paths to be excluded from the operation.
+
+ - __for__ *pattern*
+
+ Alias for __not__.
+
+ - __exclude__ *pattern*
+
+ Alias for __not__.
+
+ - __but__
+
+ Has no arguments of its own, but looks ahead in the list of words and
+ executes all __not__ commands immediately following it. This allows the
+ construction of "but not" and "but exclude" clauses for a more natural
+ sounding specification of excluded paths.
+
+ - __except__
+
+ A semi-alias for __but__. Has no arguments of its own, but looks ahead in
+ the list of words and executes all __for__ commands immediately following
+ it. This allows the construction of "except for" clauses for a more natural
+ sounding specification of excluded paths.
+
+ - __as__ *name*
+
+ Specifies a new name for the first file handled by the current operation.
+ I.e. for the renaming of a single file during the operation.
+
+ - __recursive__
+
+ Signals that file expansion should happen in the whole directory hierarchy
+ and not just the directory itself.
+
+ - __recursively__
+
+ An alias for __recursive__.
+
+ - __[copy](../../../../index.md#copy)__
+
+ Signals that the operation is the copying of files from source to
+ destination directory per the specified inclusion and exclusion patterns.
+
+ - __[move](../../../../index.md#move)__
+
+ Signals that the operation is the moving of files from source to destination
+ directory per the specified inclusion and exclusion patterns.
+
+ - __[remove](../../../../index.md#remove)__
+
+ Signals that the operation is the removal of files in the destination
+ directory per the specified inclusion and exclusion patterns.
+
+ - __expand__
+
+ Signals that there is no operation but the calculation of the set of files
+ from the include and exclude patterns. This operation is not available if
+ __the-set__ is used.
+
+ - __invoke__ *cmdprefix*
+
+ Signals that the user-specified command prefix *cmdprefix* is the operation
+ to perform. The command prefix is executed at the global level and given the
+ source directory, destination directory, and set of files (as dictionary
+ mapping from source to destination files), in this order.
+
+ - __reset__
+
+ Forces the object into the ground state where all parts of the configuration
+ have default values.
+
+ - __(__
+
+ Saves a copy of the current object state on a stack.
+
+ - __)__
+
+ Takes the state at the top of the state stack and restores it, i.e. makes it
+ the new current object state.
+
+ - __cd__ *directory*
+
+ Changes the destination directory to the sub-directory *directory* of the
+ current destination.
+
+ - __up__
+
+ Changes the destination directory to the parent directory of the current
+ destination.
+
+ - __for-windows__
+
+ Checks that Windows is the current platform. Aborts processing if not.
+
+ - __for-win__
+
+ An alias for __for-windows__.
+
+ - __for-unix__
+
+ Checks that Unix is the current platform. Aborts processing if not.
+
+ - __the__ *pattern*
+
+ This command specifies the files to operate on per a glob pattern, and is
+ also the active element, i.e. the command which actually performs the
+ specified operation. All the other commands only modified the object state
+ to set the operation up, but di nothing else.
+
+ To allow for a more natural sounding syntax this command also looks ahead in
+ the list of words looks and executes several commands immediately following
+ it before performing its own actions. These commands are __as__, __but__,
+ __exclude__, __except__, __from__, and __into__ (and aliases). That way
+ these commands act like qualifiers, and still take effect as if they had
+ been written before this command.
+
+ After the operation has been performed the object state the exclude patterns
+ and the alias name, if specified, are reset to their default values (i.e.
+ empty), but nothing else.
+
+ - __the-set__ *varname*
+
+ Like __the__, however the set of files to use is not specified implicitly
+ per a glob pattern, but contained and loaded from the specified variable.
+ The operation __expand__ is not available if this command is used.
+
+ - __->__ *varname*
+
+ Saves the set of files from the last expansion into the specified variable.
+
+ - __strict__
+
+ Make file expansion and definition of destination directory (__in__ and
+ aliases) strict, i.e. report errors for missing directories, and empty
+ expansion.
+
+ - __!strict__
+
+ Complement of __strict__. A missing destination directory or empty expansion
+ are not reported as errors.
+
+ - __files__
+
+ Limit the search to files. Default is to accept every type of path.
+
+ - __links__
+
+ Limit the search to symbolic links. Default is to accept every type of path.
+
+ - __directories__
+
+ Limit the search to directories. Default is to accept every type of path.
+
+ - __dirs__
+
+ An alias for __directories__.
+
+ - __all__
+
+ Accept all types of paths (default).
+
+ - __state?__
+
+ Returns the current state of the object as dictionary. The dictionary keys
+ and their meanings are:
+
+ * __as__
+
+ Last setting made by __as__.
+
+ * __excluded__
+
+ List of currently known exclusion patterns.
+
+ * __from__
+
+ Current source directory, set by __from__.
+
+ * __into__
+
+ Current destination directory, set by __into__ (and aliases).
+
+ * __operation__
+
+ Current operation to perform, set by
+ __[copy](../../../../index.md#copy)__,
+ __[move](../../../../index.md#move)__,
+ __[remove](../../../../index.md#remove)__, __expand__, or __invoke__.
+
+ * __recursive__
+
+ Current recursion status. Set/unset by __recursive__ and __!recursive__.
+
+ * __strict__
+
+ Current strictness. Set/unset by __strict__ and __!strict__.
+
+ * __type__
+
+ Current path type limiter. Set by either __files__, __directories__,
+ __links__, or __all__.
+
+ - __as?__
+
+ Returns the current alias name.
+
+ - __excluded?__
+
+ Returns the current set of exclusion patterns.
+
+ - __from?__
+
+ Returns the current source directory.
+
+ - __into?__
+
+ Returns the current destination directory.
+
+ - __operation?__
+
+ Returns the current operation to perform.
+
+ - __recursive?__
+
+ Returns the current recursion status.
+
+ - __strict?__
+
+ Returns the current strictness.
+
+ - __type?__
+
+ Returns the current path type limiter.
+
+# EXAMPLES
+
+The following examples assume that the variable __F__ contains a reference to a
+multi-file operation object.
+
+ $F do copy \\
+ the *.dll \\
+ from c:/TDK/PrivateOpenSSL/bin \\
+ to [installdir_of tls]
+
+ $F do move \\
+ the * \\
+ from /sources \\
+ into /scratch \\
+ but not *.html
+
+ # Alternatively use 'except for *.html'.
+
+ $F do \\
+ move \\
+ the index \\
+ from /sources \\
+ into /scratch \\
+ as pkgIndex.tcl
+
+ $F do \\
+ remove \\
+ the *.txt \\
+ in /scratch
+
+Note that the fact that most commands just modify the object state allows us to
+use more off forms as specifications instead of just nearly-natural language
+sentences. For example the second example in this section can re-arranged into:
+
+ $F do \\
+ from /sources \\
+ into /scratch \\
+ but not *.html \\
+ move \\
+ the *
+
+and the result is not only still a valid specification, but even stays
+relatively readable.
+
+Further note that the information collected by the commands __but__, __except__,
+and __as__ is automatically reset after the associated __the__ was executed.
+However no other state is reset in that manner, allowing the user to avoid
+repetitions of unchanging information. For example the second and third examples
+of this section can be merged and rewritten into the equivalent:
+
+ $F do \\
+ move \\
+ the * \\
+ from /sources \\
+ into /scratch \\
+ but not *.html not index \\
+ the index \\
+ as pkgIndex.tcl
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[copy](../../../../index.md#copy), [file
+utilities](../../../../index.md#file_utilities),
+[move](../../../../index.md#move),
+[multi-file](../../../../index.md#multi_file),
+[remove](../../../../index.md#remove)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fileutil/traverse.md
Index: embedded/md/tcllib/files/modules/fileutil/traverse.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fileutil/traverse.md
@@ -0,0 +1,200 @@
+
+[//000000001]: # (fileutil_traverse - file utilities)
+[//000000002]: # (Generated from file 'traverse.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil_traverse(n) 0.6 tcllib "file utilities")
+
+# NAME
+
+fileutil_traverse - Iterative directory traversal
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [OPTIONS](#section2)
+
+ - [Warnings and Incompatibilities](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.3
+package require fileutil::traverse ?0.6?
+package require fileutil
+package require control
+
+[__::fileutil::traverse__ ?*objectName*? *path* ?*option* *value*...?](#1)
+[__$traverser__ __command__ ?*arg arg ...*?](#2)
+[__$traverser__ __files__](#3)
+[__$traverser__ __foreach__ *filevar* *script*](#4)
+[__$traverser__ __next__ *filevar*](#5)
+
+# DESCRIPTION
+
+This package provides objects for the programmable traversal of directory
+hierarchies. The main command exported by the package is:
+
+ - __::fileutil::traverse__ ?*objectName*? *path* ?*option* *value*...?
+
+ The command creates a new traversal object with an associated global Tcl
+ command whose name is *objectName*. This command may be used to invoke
+ various operations on the traverser. If the string __%AUTO%__ is used as the
+ *objectName* then a unique name will be generated by the package itself.
+
+ Regarding the recognized options see section [OPTIONS](#section2). Note that
+ all these options can be set only during the creation of the traversal
+ object. Changing them later is not possible and causes errors to be thrown
+ if attempted.
+
+ The object command has the following general form:
+
+ * __$traverser__ __command__ ?*arg arg ...*?
+
+ *Command* and its *arg*uments determine the exact behavior of the
+ object.
+
+The following commands are possible for traversal objects:
+
+ - __$traverser__ __files__
+
+ This method is the most highlevel one provided by traversal objects. When
+ invoked it returns a list containing the names of all files and directories
+ matching the current configuration of the traverser.
+
+ - __$traverser__ __foreach__ *filevar* *script*
+
+ The highlevel __files__ method (see above) is based on this mid-level
+ method. When invoked it finds all files and directories matching per the
+ current configuration and executes the *script* for each path. The current
+ path under consideration is stored in the variable named by *filevar*. Both
+ variable and script live / are executed in the context of the caller of the
+ method. In the method __files__ the script simply saves the found paths into
+ the list to return.
+
+ - __$traverser__ __next__ *filevar*
+
+ This is the lowest possible interface to the traverser, the core all higher
+ methods are built on. When invoked it returns a boolean value indicating
+ whether it found a path matching the current configuration (__True__), or
+ not (__False__). If a path was found it is stored into the variable named by
+ *filevar*, in the context of the caller.
+
+ The __foreach__ method simply calls this method in a loop until it returned
+ __False__. This method is exposed so that we are also able to incrementally
+ traverse a directory hierarchy in an event-based manner.
+
+ Note that the traverser does follow symbolic links, except when doing so
+ would cause it to enter a link-cycle. In other words, the command takes care
+ to *not* lose itself in infinite loops upon encountering circular link
+ structures. Note that even links which are not followed will still appear in
+ the result.
+
+# OPTIONS
+
+ - __-prefilter__ command_prefix
+
+ This callback is executed for directories. Its result determines if the
+ traverser recurses into the directory or not. The default is to always
+ recurse into all directories. The callback is invoked with a single
+ argument, the *absolute* path of the directory, and has to return a boolean
+ value, __True__ when the directory passes the filter, and __False__ if not.
+
+ - __-filter__ command_prefix
+
+ This callback is executed for all paths. Its result determines if the
+ current path is a valid result, and returned by __next__. The default is to
+ accept all paths as valid. The callback is invoked with a single argument,
+ the *absolute* path to check, and has to return a boolean value, __True__
+ when the path passes the filter, and __False__ if not.
+
+ - __-errorcmd__ command_prefix
+
+ This callback is executed for all paths the traverser has trouble with. Like
+ being unable to change into them, get their status, etc. The default is to
+ ignore any such problems. The callback is invoked with a two arguments, the
+ *absolute* path for which the error occured, and the error message. Errors
+ thrown by the filter callbacks are handled through this callback too. Errors
+ thrown by the error callback itself are not caught and ignored, but allowed
+ to pass to the caller, i.e. however invoked the __next__. Any other results
+ from the callback are ignored.
+
+# Warnings and Incompatibilities
+
+ - __0.4.4__
+
+ In this version the traverser's broken system for handling symlinks was
+ replaced with one working correctly and properly enumerating all the legal
+ non-cyclic paths under a base directory.
+
+ While correct this means that certain pathological directory hierarchies
+ with cross-linked sym-links will now take about O(n**2) time to enumerate
+ whereas the original broken code managed O(n) due to its brokenness.
+
+ A concrete example and extreme case is the "/sys" hierarchy under Linux
+ where some hundred devices exist under both "/sys/devices" and "/sys/class"
+ with the two sub-hierarchies linking to the other, generating millions of
+ legal paths to enumerate. The structure, reduced to three devices, roughly
+ looks like
+
+ /sys/class/tty/tty0 --> ../../dev/tty0
+ /sys/class/tty/tty1 --> ../../dev/tty1
+ /sys/class/tty/tty2 --> ../../dev/tty1
+
+ /sys/dev/tty0/bus
+ /sys/dev/tty0/subsystem --> ../../class/tty
+ /sys/dev/tty1/bus
+ /sys/dev/tty1/subsystem --> ../../class/tty
+ /sys/dev/tty2/bus
+ /sys/dev/tty2/subsystem --> ../../class/tty
+
+ When having to handle such a pathological hierarchy it is recommended to use
+ the __-prefilter__ option to prevent the traverser from following symbolic
+ links, like so:
+
+ package require fileutil::traverse
+
+ proc NoLinks {fileName} {
+ if {[string equal [file type $fileName] link]} {
+ return 0
+ }
+ return 1
+ }
+
+ fileutil::traverse T /sys/devices -prefilter NoLinks
+ T foreach p {
+ puts $p
+ }
+ T destroy
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[directory traversal](../../../../index.md#directory_traversal),
+[traversal](../../../../index.md#traversal)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/ftp/ftp.md
Index: embedded/md/tcllib/files/modules/ftp/ftp.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/ftp/ftp.md
@@ -0,0 +1,413 @@
+
+[//000000001]: # (ftp - ftp client)
+[//000000002]: # (Generated from file 'ftp.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (ftp(n) 2.4.13 tcllib "ftp client")
+
+# NAME
+
+ftp - Client-side tcl implementation of the ftp protocol
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [BUGS](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.2
+package require ftp ?2.4.13?
+
+[__::ftp::Open__ *server* *user* *passwd* ?*options*?](#1)
+[__::ftp::Close__ *handle*](#2)
+[__::ftp::Cd__ *handle* *directory*](#3)
+[__::ftp::Pwd__ *handle*](#4)
+[__::ftp::Type__ *handle* ?__ascii|binary|tenex__?](#5)
+[__::ftp::List__ *handle* ?*pattern*?](#6)
+[__::ftp::NList__ *handle* ?*directory*?](#7)
+[__::ftp::FileSize__ *handle* *file*](#8)
+[__::ftp::ModTime__ *handle* *file*](#9)
+[__::ftp::Delete__ *handle* *file*](#10)
+[__::ftp::Rename__ *handle* *from* *to*](#11)
+[__::ftp::Put__ *handle* (*local* | -data *data* | -channel *chan*) ?*remote*?](#12)
+[__::ftp::Append__ *handle* (*local* | -data *data* | -channel *chan*) ?*remote*?](#13)
+[__::ftp::Get__ *handle* *remote* ?(*local* | -variable *varname* | -channel *chan*)?](#14)
+[__::ftp::Reget__ *handle* *remote* ?*local*? ?*from*? ?*to*?](#15)
+[__::ftp::Newer__ *handle* *remote* ?*local*?](#16)
+[__::ftp::MkDir__ *handle* *directory*](#17)
+[__::ftp::RmDir__ *handle* *directory*](#18)
+[__::ftp::Quote__ *handle* *arg1* *arg2* *...*](#19)
+[__::ftp::DisplayMsg__ *handle* *msg* ?*state*?](#20)
+
+# DESCRIPTION
+
+The ftp package provides the client side of the ftp protocol as specified in RFC
+959
+([http://www.rfc-editor.org/rfc/rfc959.txt](http://www.rfc-editor.org/rfc/rfc959.txt)).
+The package implements both active (default) and passive ftp sessions.
+
+A new ftp session is started with the __::ftp::Open__ command. To shutdown an
+existing ftp session use __::ftp::Close__. All other commands are restricted to
+usage in an an open ftp session. They will generate errors if they are used out
+of context. The ftp package includes file and directory manipulating commands
+for remote sites. To perform the same operations on the local site use commands
+built into the core, like __cd__ or __[file](../../../../index.md#file)__.
+
+The output of the package is controlled by two state variables,
+__::ftp::VERBOSE__ and __::ftp::DEBUG__. Setting __::ftp::VERBOSE__ to "1"
+forces the package to show all responses from a remote server. The default value
+is "0". Setting __::ftp::DEBUG__ to "1" enables debugging and forces the package
+to show all return codes, states, state changes and "real" ftp commands. The
+default value is "0".
+
+The command __::ftp::DisplayMsg__ is used to show the different messages from
+the ftp session. The setting of __::ftp::VERBOSE__ determines if this command is
+called or not. The current implementation of the command uses the
+__[log](../log/log.md)__ package of tcllib to write the messages to their final
+destination. This means that the behaviour of __::ftp::DisplayMsg__ can be
+customized without changing its implementation. For more radical changes
+overwriting its implementation by the application is of course still possible.
+Note that the default implementation honors the option __-output__ to
+__::ftp::Open__ for a session specific log command.
+
+*Caution*: The default implementation logs error messages like all other
+messages. If this behaviour is changed to throwing an error instead all commands
+in the API will change their behaviour too. In such a case they will not return
+a failure code as described below but pass the thrown error to their caller.
+
+# API
+
+ - __::ftp::Open__ *server* *user* *passwd* ?*options*?
+
+ This command is used to start a FTP session by establishing a control
+ connection to the FTP server. The defaults are used for any option not
+ specified by the caller.
+
+ The command takes a host name *server*, a user name *user* and a password
+ *password* as its parameters and returns a session handle that is an integer
+ number greater than or equal to "0", if the connection is successfully
+ established. Otherwise it returns "-1". The *server* parameter must be the
+ name or internet address (in dotted decimal notation) of the ftp server to
+ connect to. The *user* and *passwd* parameters must contain a valid user
+ name and password to complete the login process.
+
+ The options overwrite some default values or set special abilities:
+
+ * __-blocksize__ *size*
+
+ The blocksize is used during data transfer. At most *size* bytes are
+ transfered at once. The default value for this option is 4096. The
+ package will evaluate the __-progress callback__ for the session after
+ the transfer of each block.
+
+ * __-timeout__ *seconds*
+
+ If *seconds* is non-zero, then __::ftp::Open__ sets up a timeout which
+ will occur after the specified number of seconds. The default value is
+ 600.
+
+ * __-port__ *number*
+
+ The port *number* specifies an alternative remote port on the ftp server
+ on which the ftp service resides. Most ftp services listen for
+ connection requests on the default port 21. Sometimes, usually for
+ security reasons, port numbers other than 21 are used for ftp
+ connections.
+
+ * __-mode__ *mode*
+
+ The transfer *mode* option determines if a file transfer occurs in
+ __active__ or __passive__ mode. In passive mode the client will ask the
+ ftp server to listen on a data port and wait for the connection rather
+ than to initiate the process by itself when a data transfer request
+ comes in. Passive mode is normally a requirement when accessing sites
+ via a firewall. The default mode is __active__.
+
+ * __-progress__ *callback*
+
+ This *callback* is evaluated whenever a block of data was transfered.
+ See the option __-blocksize__ for how to specify the size of the
+ transfered blocks.
+
+ When evaluating the *callback* one argument is appended to the callback
+ script, the current accumulated number of bytes transferred so far.
+
+ * __-command__ *callback*
+
+ Specifying this option places the connection into asynchronous mode. The
+ *callback* is evaluated after the completion of any operation. When an
+ operation is running no further operations must be started until a
+ callback has been received for the currently executing operation.
+
+ When evaluating the *callback* several arguments are appended to the
+ callback script, namely the keyword of the operation that has completed
+ and any additional arguments specific to the operation. If an error
+ occurred during the execution of the operation the callback is given the
+ keyword __error__.
+
+ * __-output__ *callback*
+
+ This option has no default. If it is set the default implementation of
+ __::ftp::DisplayMsg__ will use its value as command prefix to log all
+ internal messages. The callback will have three arguments appended to it
+ before evaluation, the id of the session, the message itself, and the
+ connection state, in this order.
+
+ - __::ftp::Close__ *handle*
+
+ This command terminates the specified ftp session. If no file transfer is in
+ progress, the server will close the control connection immediately. If a
+ file transfer is in progress however, the control connection will remain
+ open until the transfers completes. When that happens the server will write
+ the result response for the transfer to it and close the connection
+ afterward.
+
+ - __::ftp::Cd__ *handle* *directory*
+
+ This command changes the current working directory on the ftp server to a
+ specified target *directory*. The command returns 1 if the current working
+ directory was successfully changed to the specified directory or 0 if it
+ fails. The target directory can be
+
+ a subdirectory of the current directory,
+
+ Two dots, __..__ (as an indicator for the parent directory of the current
+ directory)
+
+ or a fully qualified path to a new working directory.
+
+ - __::ftp::Pwd__ *handle*
+
+ This command returns the complete path of the current working directory on
+ the ftp server, or an empty string in case of an error.
+
+ - __::ftp::Type__ *handle* ?__ascii|binary|tenex__?
+
+ This command sets the ftp file transfer type to either __ascii__,
+ __binary__, or __tenex__. The command always returns the currently set type.
+ If called without type no change is made.
+
+ Currently only __ascii__ and __binary__ types are supported. There is some
+ early (alpha) support for Tenex mode. The type __ascii__ is normally used to
+ convert text files into a format suitable for text editors on the platform
+ of the destination machine. This mainly affects end-of-line markers. The
+ type __binary__ on the other hand allows the undisturbed transfer of
+ non-text files, such as compressed files, images and executables.
+
+ - __::ftp::List__ *handle* ?*pattern*?
+
+ This command returns a human-readable list of files. Wildcard expressions
+ such as "*.tcl" are allowed. If *pattern* refers to a specific directory,
+ then the contents of that directory are returned. If the *pattern* is not a
+ fully-qualified path name, the command lists entries relative to the current
+ remote directory. If no *pattern* is specified, the contents of the current
+ remote directory is returned.
+
+ The listing includes any system-dependent information that the server
+ chooses to include. For example most UNIX systems produce output from the
+ command __ls -l__. The command returns the retrieved information as a tcl
+ list with one item per entry. Empty lines and UNIX's "total" lines are
+ ignored and not included in the result as reported by this command.
+
+ If the command fails an empty list is returned.
+
+ - __::ftp::NList__ *handle* ?*directory*?
+
+ This command has the same behavior as the __::ftp::List__ command, except
+ that it only retrieves an abbreviated listing. This means only file names
+ are returned in a sorted list.
+
+ - __::ftp::FileSize__ *handle* *file*
+
+ This command returns the size of the specified *file* on the ftp server. If
+ the command fails an empty string is returned.
+
+ *ATTENTION!* It will not work properly when in ascii mode and is not
+ supported by all ftp server implementations.
+
+ - __::ftp::ModTime__ *handle* *file*
+
+ This command retrieves the time of the last modification of the *file* on
+ the ftp server as a system dependent integer value in seconds or an empty
+ string if an error occurred. Use the built-in command __clock__ to convert
+ the retrieves value into other formats.
+
+ - __::ftp::Delete__ *handle* *file*
+
+ This command deletes the specified *file* on the ftp server. The command
+ returns 1 if the specified file was successfully deleted or 0 if it failed.
+
+ - __::ftp::Rename__ *handle* *from* *to*
+
+ This command renames the file *from* in the current directory of the ftp
+ server to the specified new file name *to*. This new file name must not be
+ the same as any existing subdirectory or file name. The command returns 1 if
+ the specified file was successfully renamed or 0 if it failed.
+
+ - __::ftp::Put__ *handle* (*local* | -data *data* | -channel *chan*) ?*remote*?
+
+ This command transfers a local file *local* to a remote file *remote* on the
+ ftp server. If the file parameters passed to the command do not fully
+ qualified path names the command will use the current directory on local and
+ remote host. If the remote file name is unspecified, the server will use the
+ name of the local file as the name of the remote file. The command returns 1
+ to indicate a successful transfer and 0 in the case of a failure.
+
+ If __-data__ *data* is specified instead of a local file, the system will
+ not transfer a file, but the *data* passed into it. In this case the name of
+ the remote file has to be specified.
+
+ If __-channel__ *chan* is specified instead of a local file, the system will
+ not transfer a file, but read the contents of the channel *chan* and write
+ this to the remote file. In this case the name of the remote file has to be
+ specified. After the transfer *chan* will be closed.
+
+ - __::ftp::Append__ *handle* (*local* | -data *data* | -channel *chan*) ?*remote*?
+
+ This command behaves like __::ftp::Puts__, but appends the transfered
+ information to the remote file. If the file did not exist on the server it
+ will be created.
+
+ - __::ftp::Get__ *handle* *remote* ?(*local* | -variable *varname* | -channel *chan*)?
+
+ This command retrieves a remote file *remote* on the ftp server and stores
+ its contents into the local file *local*. If the file parameters passed to
+ the command are not fully qualified path names the command will use the
+ current directory on local and remote host. If the local file name is
+ unspecified, the server will use the name of the remote file as the name of
+ the local file. The command returns 1 to indicate a successful transfer and
+ 0 in the case of a failure. The command will throw an error if the directory
+ the file *local* is to be placed in does not exist.
+
+ If __-variable__ *varname* is specified, the system will store the retrieved
+ data into the variable *varname* instead of a file.
+
+ If __-channel__ *chan* is specified, the system will write the retrieved
+ data into the channel *chan* instead of a file. The system will *not* close
+ *chan* after the transfer, this is the responsibility of the caller to
+ __::ftp::Get__.
+
+ - __::ftp::Reget__ *handle* *remote* ?*local*? ?*from*? ?*to*?
+
+ This command behaves like __::ftp::Get__, except that if local file *local*
+ exists and is smaller than remote file *remote*, the local file is presumed
+ to be a partially transferred copy of the remote file and the transfer is
+ continued from the apparent point of failure. The command will throw an
+ error if the directory the file *local* is to be placed in does not exist.
+ This command is useful when transferring very large files over networks that
+ tend to drop connections.
+
+ Specifying the additional byte offsets *from* and *to* will cause the
+ command to change its behaviour and to download exactly the specified slice
+ of the remote file. This mode is possible only if a local destination is
+ explicitly provided. Omission of *to* leads to downloading till the end of
+ the file.
+
+ - __::ftp::Newer__ *handle* *remote* ?*local*?
+
+ This command behaves like __::ftp::Get__, except that it retrieves the
+ remote file only if the modification time of the remote file is more recent
+ than the file on the local system. If the file does not exist on the local
+ system, the remote file is considered newer. The command will throw an error
+ if the directory the file *local* is to be placed in does not exist.
+
+ - __::ftp::MkDir__ *handle* *directory*
+
+ This command creates the specified *directory* on the ftp server. If the
+ specified path is relative the new directory will be created as a
+ subdirectory of the current working directory. Else the created directory
+ will have the specified path name. The command returns 1 to indicate a
+ successful creation of the directory and 0 in the case of a failure.
+
+ - __::ftp::RmDir__ *handle* *directory*
+
+ This command removes the specified directory on the ftp server. The remote
+ directory has to be empty or the command will fail. The command returns 1 to
+ indicate a successful removal of the directory and 0 in the case of a
+ failure.
+
+ - __::ftp::Quote__ *handle* *arg1* *arg2* *...*
+
+ This command is used to send an arbitrary ftp command to the server. It
+ cannot be used to obtain a directory listing or for transferring files. It
+ is included to allow an application to execute commands on the ftp server
+ which are not provided by this package. The arguments are sent verbatim,
+ i.e. as is, with no changes.
+
+ In contrast to the other commands in this package this command will not
+ parse the response it got from the ftp server but return it verbatim to the
+ caller.
+
+ - __::ftp::DisplayMsg__ *handle* *msg* ?*state*?
+
+ This command is used by the package itself to show the different messages
+ from the ftp sessions. The package itself declares this command very simple,
+ writing the messages to __stdout__ (if __::ftp::VERBOSE__ was set, see
+ below) and throwing tcl errors for error messages. It is the responsibility
+ of the application to overwrite it as needed. A state variable for different
+ states assigned to different colors is recommended by the author. The
+ package __[log](../log/log.md)__ is useful for this.
+
+ - __::ftp::VERBOSE__
+
+ A state variable controlling the output of the package. Setting
+ __::ftp::VERBOSE__ to "1" forces the package to show all responses from a
+ remote server. The default value is "0".
+
+ - __::ftp::DEBUG__
+
+ A state variable controlling the output of ftp. Setting __::ftp::DEBUG__ to
+ "1" enables debugging and forces the package to show all return codes,
+ states, state changes and "real" ftp commands. The default value is "0".
+
+# BUGS
+
+The correct execution of many commands depends upon the proper behavior by the
+remote server, network and router configuration.
+
+An update command placed in the procedure __::ftp::DisplayMsg__ may run into
+persistent errors or infinite loops. The solution to this problem is to use
+__update idletasks__ instead of __[update](../../../../index.md#update)__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *ftp* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[ftpd](../ftpd/ftpd.md), [mime](../mime/mime.md), [pop3](../pop3/pop3.md),
+[smtp](../mime/smtp.md)
+
+# KEYWORDS
+
+[ftp](../../../../index.md#ftp), [internet](../../../../index.md#internet),
+[net](../../../../index.md#net), [rfc 959](../../../../index.md#rfc_959)
+
+# CATEGORY
+
+Networking
ADDED embedded/md/tcllib/files/modules/ftp/ftp_geturl.md
Index: embedded/md/tcllib/files/modules/ftp/ftp_geturl.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/ftp/ftp_geturl.md
@@ -0,0 +1,94 @@
+
+[//000000001]: # (ftp::geturl - ftp client)
+[//000000002]: # (Generated from file 'ftp_geturl.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (ftp::geturl(n) 0.2.2 tcllib "ftp client")
+
+# NAME
+
+ftp::geturl - Uri handler for ftp urls
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.2
+package require ftp::geturl ?0.2.2?
+
+[__::ftp::geturl__ *url*](#1)
+
+# DESCRIPTION
+
+This package provides a command which wraps around the client side of the
+*[ftp](../../../../index.md#ftp)* protocol provided by package __[ftp](ftp.md)__
+to allow the retrieval of urls using the *[ftp](../../../../index.md#ftp)*
+schema.
+
+# API
+
+ - __::ftp::geturl__ *url*
+
+ This command can be used by the generic command __::uri::geturl__ (See
+ package __[uri](../uri/uri.md)__) to retrieve the contents of ftp urls.
+ Internally it uses the commands of the package __[ftp](ftp.md)__ to fulfill
+ the request.
+
+ The contents of a *[ftp](../../../../index.md#ftp)* url are defined as
+ follows:
+
+ * *[file](../../../../index.md#file)*
+
+ The contents of the specified file itself.
+
+ * *directory*
+
+ A listing of the contents of the directory in key value notation where
+ the file name is the key and its attributes the associated value.
+
+ * *link*
+
+ The attributes of the link, including the path it refers to.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *ftp* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[ftpd](../ftpd/ftpd.md), [mime](../mime/mime.md), [pop3](../pop3/pop3.md),
+[smtp](../mime/smtp.md)
+
+# KEYWORDS
+
+[ftp](../../../../index.md#ftp), [internet](../../../../index.md#internet),
+[net](../../../../index.md#net), [rfc 959](../../../../index.md#rfc_959)
+
+# CATEGORY
+
+Networking
ADDED embedded/md/tcllib/files/modules/ftpd/ftpd.md
Index: embedded/md/tcllib/files/modules/ftpd/ftpd.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/ftpd/ftpd.md
@@ -0,0 +1,304 @@
+
+[//000000001]: # (ftpd - Tcl FTP Server Package)
+[//000000002]: # (Generated from file 'ftpd.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (ftpd(n) 1.3 tcllib "Tcl FTP Server Package")
+
+# NAME
+
+ftpd - Tcl FTP server implementation
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [CALLBACKS](#section3)
+
+ - [VARIABLES](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.3
+package require ftpd ?1.3?
+
+[__::ftpd::server__ ?*myaddr*?](#1)
+[__::ftpd::config__ ?*option value*? ?*option value ...*?](#2)
+[*fsCmd* __append__ *path*](#3)
+[*fsCmd* __delete__ *path* *channel*](#4)
+[*fsCmd* __dlist__ *path* *style* *channel*](#5)
+[*fsCmd* __exists__ *path*](#6)
+[*fsCmd* __mkdir__ *path* *channel*](#7)
+[*fsCmd* __mtime__ *path* *channel*](#8)
+[*fsCmd* __permissions__ *path*](#9)
+[*fsCmd* __rename__ *path* *newpath* *channel*](#10)
+[*fsCmd* __retr__ *path*](#11)
+[*fsCmd* __rmdir__ *path* *channel*](#12)
+[*fsCmd* __size__ *path* *channel*](#13)
+[*fsCmd* __store__ *path*](#14)
+
+# DESCRIPTION
+
+The __ftpd__ package provides a simple Tcl-only server library for the FTP
+protocol as specified in RFC 959
+([http://www.rfc-editor.org/rfc/rfc959.txt](http://www.rfc-editor.org/rfc/rfc959.txt)).
+It works by listening on the standard FTP socket. Most server errors are
+returned as error messages with the appropriate code attached to them. Since the
+server code for the ftp daemon is executed in the event loop, it is possible
+that a __bgerror__ will be thrown on the server if there are problems with the
+code in the module.
+
+# COMMANDS
+
+ - __::ftpd::server__ ?*myaddr*?
+
+ Open a listening socket to listen to and accept ftp connections. myaddr is
+ an optional argument. *myaddr* is the domain-style name or numerical IP
+ address of the client-side network interface to use for the connection.
+
+ - __::ftpd::config__ ?*option value*? ?*option value ...*?
+
+ The value is always the name of the command to call as the callback. The
+ option specifies which callback should be configured. See section
+ [CALLBACKS](#section3) for descriptions of the arguments and return values
+ for each of the callbacks.
+
+ * -authIpCmd *proc*
+
+ Callback to authenticate new connections based on the ip-address of the
+ peer.
+
+ * -authUsrCmd *proc*
+
+ Callback to authenticate new connections based on the user logging in
+ (and the users password).
+
+ * -authFileCmd *proc*
+
+ Callback to accept or deny a users access to read and write to a
+ specific path or file.
+
+ * -logCmd *proc*
+
+ Callback for log information generated by the FTP engine.
+
+ * -fsCmd *proc*
+
+ Callback to connect the engine to the filesystem it operates on.
+
+ * -closeCmd *proc*
+
+ Callback to be called when a connection is closed. This allows the
+ embedding application to perform its own cleanup operations.
+
+ * -xferDoneCmd *proc*
+
+ Callback for transfer completion notification. In other words, it is
+ called whenever a transfer of data to or from the client has completed.
+
+# CALLBACKS
+
+ - __authIpCmd__ callback
+
+ The authIpCmd receives the ip-address of the peer attempting to connect to
+ the ftp server as its argument. It returns a 1 to allow users from the
+ specified IP to attempt to login and a 0 to reject the login attempt from
+ the specified IP.
+
+ - __authUsrCmd__ callback
+
+ The authUsrCmd receives the username and password as its two arguments. It
+ returns a 1 to accept the attempted login to the ftpd and a 0 to reject the
+ attempted login.
+
+ - __authFileCmd__ callback
+
+ The authFileCmd receives the user (that is currently logged in), the path or
+ filename that is about to be read or written, and __read__ or __write__ as
+ its three arguments. It returns a 1 to allow the path or filename to be read
+ or written, and a 0 to reject the attempted read or write with a permissions
+ error code.
+
+ - __logCmd__ callback
+
+ The logCmd receives a severity and a message as its two arguments. The
+ severities used within the ftpd package are __note__, __debug__, and
+ __error__. The logCmd doesn't return anything.
+
+ - __fsCmd__ callback
+
+ The fsCmd receives a subcommand, a filename or path, and optional additional
+ arguments (depending on the subcommand).
+
+ The subcommands supported by the fsCmd are:
+
+ * *fsCmd* __append__ *path*
+
+ The append subcommand receives the filename to append to as its
+ argument. It returns a writable tcl channel as its return value.
+
+ * *fsCmd* __delete__ *path* *channel*
+
+ The delete subcommand receives the filename to delete, and a channel to
+ write to as its two arguments. The file specified is deleted and the
+ appropriate ftp message is written to the channel that is passed as the
+ second argument. The delete subcommand returns nothing.
+
+ * *fsCmd* __dlist__ *path* *style* *channel*
+
+ The dlist subcommand receives the path that it should list the files
+ that are in, the style in which the files should be listed which is
+ either __nlst__ or __list__, and a channel to write to as its three
+ arguments. The files in the specified path are printed to the specified
+ channel one per line. If the style is __nlst__ only the name of the file
+ is printed to the channel. If the style is __list__ then the file
+ permissions, number of links to the file, the name of the user that owns
+ the file, the name of the group that owns the file, the size (in bytes)
+ of the file, the modify time of the file, and the filename are printed
+ out to the channel in a formatted space separated format. The __dlist__
+ subcommand returns nothing.
+
+ * *fsCmd* __exists__ *path*
+
+ The exists subcommand receives the name of a file to check the existence
+ of as its only argument. The exists subcommand returns a 1 if the path
+ specified exists and the path is not a directory.
+
+ * *fsCmd* __mkdir__ *path* *channel*
+
+ The mkdir subcommand receives the path of a directory to create and a
+ channel to write to as its two arguments. The mkdir subcommand creates
+ the specified directory if necessary and possible. The mkdir subcommand
+ then prints the appropriate success or failure message to the channel.
+ The mkdir subcommand returns nothing.
+
+ * *fsCmd* __mtime__ *path* *channel*
+
+ The mtime subcommand receives the path of a file to check the modify
+ time on and a channel as its two arguments. If the file exists the mtime
+ is printed to the channel in the proper FTP format, otherwise an
+ appropriate error message and code are printed to the channel. The mtime
+ subcommand returns nothing.
+
+ * *fsCmd* __permissions__ *path*
+
+ The permissions subcommand receives the path of a file to retrieve the
+ permissions of. The permissions subcommand returns the octal file
+ permissions of the specified file. The file is expected to exist.
+
+ * *fsCmd* __rename__ *path* *newpath* *channel*
+
+ The rename subcommand receives the path of the current file, the new
+ file path, and a channel to write to as its three arguments. The rename
+ subcommand renames the current file to the new file path if the path to
+ the new file exists, and then prints out the appropriate message to the
+ channel. If the new file path doesn't exist the appropriate error
+ message is printed to the channel. The rename subcommand returns
+ nothing.
+
+ * *fsCmd* __retr__ *path*
+
+ The retr subcommand receives the path of a file to read as its only
+ argument. The retr subcommand returns a readable channel that the
+ specified file can be read from.
+
+ * *fsCmd* __rmdir__ *path* *channel*
+
+ The rmdir subcommand receives the path of a directory to remove and a
+ channel to write to as its two arguments. The rmdir subcommand removes
+ the specified directory (if possible) and prints the appropriate message
+ to the channel (which may be an error if the specified directory does
+ not exist or is not empty). The rmdir subcommand returns nothing.
+
+ * *fsCmd* __size__ *path* *channel*
+
+ The size subcommand receives the path of a file to get the size (in
+ bytes) of and a channel to write to as its two arguments. The size
+ subcommand prints the appropriate code and the size of the file if the
+ specified path is a file, otherwise an appropriate error code and
+ message are printed to the channel. The size subcommand returns nothing.
+
+ * *fsCmd* __store__ *path*
+
+ The store subcommand receives the path of a file to write as its only
+ argument. The store subcommand returns a writable channel.
+
+ - __closeCmd__
+
+ The __closeCmd__ receives no arguments when it is invoked, and any return
+ value it may generate is discarded.
+
+ - __xferDoneCmd__ sock sock2 file bytes filename err
+
+ The __xferDoneCmd__ receives six arguments when invoked. These are, in this
+ order, the channel handle of the control socket for the connection, the
+ channel handle of the data socket used for the transfer (already closed),
+ the handle of the channel containing the transfered file, the number of
+ bytes transfered, the path of the file which was transfered, and a (possibly
+ empty) error message. Any return value it may generate is discarded.
+
+# VARIABLES
+
+ - __::ftpd::cwd__
+
+ The current working directory for a session when someone first connects to
+ the FTPD or when the __REIN__ ftp command is received.
+
+ - __::ftpd::contact__
+
+ The e-mail address of the person that is the contact for the ftp server.
+ This address is printed out as part of the response to the __FTP HELP__
+ command.
+
+ - __::ftpd::port__
+
+ The port that the ftp server should listen on. If port is specified as zero,
+ the operating system will allocate an unused port for use as a server
+ socket; afterwards, the variable will contain the port number that was
+ allocated.
+
+ - __::ftpd::welcome__
+
+ The message that is printed out when the user first connects to the ftp
+ server.
+
+ - __::ftpd::CurrentSocket__
+
+ Accessible to all callbacks and all filesystem commands (which are a special
+ form of callback) and contains the handle of the socket channel which was
+ active when the callback was invoked.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *ftpd* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[ftp](../../../../index.md#ftp), [ftpd](../../../../index.md#ftpd),
+[ftpserver](../../../../index.md#ftpserver), [rfc
+959](../../../../index.md#rfc_959), [services](../../../../index.md#services)
+
+# CATEGORY
+
+Networking
ADDED embedded/md/tcllib/files/modules/fumagic/cfront.md
Index: embedded/md/tcllib/files/modules/fumagic/cfront.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fumagic/cfront.md
@@ -0,0 +1,106 @@
+
+[//000000001]: # (fileutil::magic::cfront - file utilities)
+[//000000002]: # (Generated from file 'cfront.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::magic::cfront(n) 1.2.0 tcllib "file utilities")
+
+# NAME
+
+fileutil::magic::cfront - Generator core for compiler of magic(5) files
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require fileutil::magic::cfront ?1.2.0?
+package require fileutil::magic::cgen ?1.2.0?
+package require fileutil::magic::rt ?1.2.0?
+package require struct::list
+package require fileutil
+
+[__::fileutil::magic::cfront::compile__ *path*...](#1)
+[__::fileutil::magic::cfront::procdef__ *procname* *path*...](#2)
+[__::fileutil::magic::cfront::install__ *path*...](#3)
+
+# DESCRIPTION
+
+This package provides the frontend of a compiler of magic(5) files into
+recognizers based on the __[fileutil::magic::rt](rtcore.md)__ recognizer runtime
+package. For the generator backed used by this compiler see the package
+__[fileutil::magic::cgen](cgen.md)__.
+
+# COMMANDS
+
+ - __::fileutil::magic::cfront::compile__ *path*...
+
+ This command takes the paths of one or more files and directories and
+ compiles all the files, and the files in all the directories into a single
+ recognizer for all the file types specified in these files.
+
+ All the files have to be in the format specified by magic(5).
+
+ The result of the command is a Tcl script containing the generated
+ recognizer.
+
+ - __::fileutil::magic::cfront::procdef__ *procname* *path*...
+
+ This command behaves like __::fileutil::magic::cfront::compile__ with regard
+ to the specified path arguments, then wraps the resulting recognizer script
+ into a procedure named *procname*, puts code setting up the namespace of
+ *procname* in front, and returns the resulting script.
+
+ - __::fileutil::magic::cfront::install__ *path*...
+
+ This command uses __::fileutil::magic::cfront::procdef__ to compile each of
+ the paths into a recognizer procedure and installs the result in the current
+ interpreter.
+
+ The name of each new procedure is derived from the name of the
+ file/directory used in its creation, with file/directory "FOO" causing the
+ creation of procedure __::fileutil::magic::/FOO::run__.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil :: magic* of the
+[Tcllib Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any
+ideas for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+file(1), [fileutil](../fileutil/fileutil.md), magic(5)
+
+# KEYWORDS
+
+[file recognition](../../../../index.md#file_recognition), [file
+type](../../../../index.md#file_type), [file
+utilities](../../../../index.md#file_utilities),
+[mime](../../../../index.md#mime), [type](../../../../index.md#type)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fumagic/cgen.md
Index: embedded/md/tcllib/files/modules/fumagic/cgen.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fumagic/cgen.md
@@ -0,0 +1,100 @@
+
+[//000000001]: # (fileutil::magic::cgen - file utilities)
+[//000000002]: # (Generated from file 'cgen.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::magic::cgen(n) 1.2.0 tcllib "file utilities")
+
+# NAME
+
+fileutil::magic::cgen - Generator core for compiler of magic(5) files
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require fileutil::magic::cgen ?1.2.0?
+package require fileutil::magic::rt ?1.2.0?
+package require struct::tree
+package require struct::list
+
+[__::fileutil::magic::cgen::2tree__ *script*](#1)
+[__::fileutil::magic::cgen::treedump__ *tree*](#2)
+[__::fileutil::magic::cgen::treegen__ *tree* *node*](#3)
+
+# DESCRIPTION
+
+This package provides the generator backend for a compiler of magic(5) files
+into recognizers based on the __[fileutil::magic::rt](rtcore.md)__ recognizer
+runtime package. For the compiler frontend using this generator see the package
+__[fileutil::magic::cfront](cfront.md)__.
+
+# COMMANDS
+
+ - __::fileutil::magic::cgen::2tree__ *script*
+
+ This command converts the recognizer specified by the *script* into a tree
+ and returns the object command of that tree as its result. It uses the
+ package __[struct::tree](../struct/struct_tree.md)__ for the tree.
+
+ The *script* is in the format specified by magic(5).
+
+ - __::fileutil::magic::cgen::treedump__ *tree*
+
+ This command takes a *tree* as generated by
+ __::fileutil::magic::cgen::2tree__ and returns a string encoding the tree
+ for human consumption, to aid in debugging.
+
+ - __::fileutil::magic::cgen::treegen__ *tree* *node*
+
+ This command takes a *tree* as generated by
+ __::fileutil::magic::cgen::2tree__ and returns a Tcl script, the recognizer
+ for the file types represented by the sub-tree rooted at the *node*. The
+ generated script makes extensive use of the commands provided by the
+ recognizer runtime package __[fileutil::magic::rt](rtcore.md)__ to perform
+ its duties.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil :: magic* of the
+[Tcllib Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any
+ideas for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+file(1), [fileutil](../fileutil/fileutil.md), magic(5)
+
+# KEYWORDS
+
+[file recognition](../../../../index.md#file_recognition), [file
+type](../../../../index.md#file_type), [file
+utilities](../../../../index.md#file_utilities),
+[mime](../../../../index.md#mime), [type](../../../../index.md#type)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fumagic/filetypes.md
Index: embedded/md/tcllib/files/modules/fumagic/filetypes.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fumagic/filetypes.md
@@ -0,0 +1,86 @@
+
+[//000000001]: # (fileutil::magic::filetype - file utilities)
+[//000000002]: # (Generated from file 'filetypes.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::magic::filetype(n) 2.0 tcllib "file utilities")
+
+# NAME
+
+fileutil::magic::filetype - Procedures implementing file-type recognition
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [REFERENCES](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.6
+package require fileutil::magic::filetype ?2.0?
+
+[__::fileutil::magic::filetype__ *filename*](#1)
+
+# DESCRIPTION
+
+This package provides a command for the recognition of file types in pure Tcl.
+
+The core part of the recognizer was generated from a "magic(5)" file containing
+the checks to perform to recognize files, and associated file-types.
+
+*Beware!* This recognizer is large, about 752 Kilobyte of generated Tcl code.
+
+ - __::fileutil::magic::filetype__ *filename*
+
+ This command is similar to the command __fileutil::fileType__.
+
+ Returns a list containing a list of descriptions, a list of mimetype
+ components, and a list file extensions. Returns an empty string if the file
+ content is not recognized.
+
+# REFERENCES
+
+ 1. [File(1) sources](ftp://ftp.astron.com/pub/file/) This site contains the
+ current sources for the file command, including the magic definitions used
+ by it. The latter were used by us to generate this recognizer.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil :: magic* of the
+[Tcllib Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any
+ideas for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+file(1), [fileutil](../fileutil/fileutil.md), magic(5)
+
+# KEYWORDS
+
+[file recognition](../../../../index.md#file_recognition), [file
+type](../../../../index.md#file_type), [file
+utilities](../../../../index.md#file_utilities),
+[type](../../../../index.md#type)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/fumagic/rtcore.md
Index: embedded/md/tcllib/files/modules/fumagic/rtcore.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/fumagic/rtcore.md
@@ -0,0 +1,310 @@
+
+[//000000001]: # (fileutil::magic::rt - file utilities)
+[//000000002]: # (Generated from file 'rtcore.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (fileutil::magic::rt(n) 2.0 tcllib "file utilities")
+
+# NAME
+
+fileutil::magic::rt - Runtime core for file type recognition engines written in
+pure Tcl
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [NUMERIC TYPES](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require fileutil::magic::rt ?2.0?
+
+[__::fileutil::magic::rt::>__](#1)
+[__::fileutil::magic::rt::<__](#2)
+[__::fileutil::magic::rt::open__ *filename*](#3)
+[__::fileutil::magic::rt::close__](#4)
+[__::fileutil::magic::rt::file_start__ *name*](#5)
+[__::fileutil::magic::rt::result__ ?*msg*?](#6)
+[__::fileutil::magic::rt::resultv__ ?*msg*?](#7)
+[__::fileutil::magic::rt::emit__ *msg*](#8)
+[__::fileutil::magic::rt::offset__ *where*](#9)
+[__::fileutil::magic::rt::Nv__ *type* *offset* ?*qual*?](#10)
+[__::fileutil::magic::rt::N__ *type* *offset* *comp* *val* ?*qual*?](#11)
+[__::fileutil::magic::rt::Nvx__ *type* *offset* ?*qual*?](#12)
+[__::fileutil::magic::rt::Nx__ *type* *offset* *comp* *val* ?*qual*?](#13)
+[__::fileutil::magic::rt::S__ *offset* *comp* *val* ?*qual*?](#14)
+[__::fileutil::magic::rt::Sx__ *offset* *comp* *val* ?*qual*?](#15)
+[__::fileutil::magic::rt::L__ *newlevel*](#16)
+[__::fileutil::magic::rt::I__ *base* *type* *delta*](#17)
+[__::fileutil::magic::rt::R__ *offset*](#18)
+[__::fileutil::magic::rt::U__ *fileindex* *name*](#19)
+
+# DESCRIPTION
+
+This package provides the runtime core for file type recognition engines written
+in pure Tcl and is thus used by all other packages in this module, i.e. the two
+frontend packages __fileutil::magic::mimetypes__ and
+__fileutil::magic::filetypes__, and the two engine compiler packages
+__[fileutil::magic::cgen](cgen.md)__ and
+__[fileutil::magic::cfront](cfront.md)__.
+
+# COMMANDS
+
+ - __::fileutil::magic::rt::>__
+
+ Shorthand for __incr level__.
+
+ - __::fileutil::magic::rt::<__
+
+ Shorthand for __incr level -1__.
+
+ - __::fileutil::magic::rt::open__ *filename*
+
+ This command initializes the runtime and prepares the file *filename* for
+ use by the system. This command has to be invoked first, before any other
+ command of this package.
+
+ The command returns the channel handle of the opened file as its result.
+
+ - __::fileutil::magic::rt::close__
+
+ This command closes the last file opened via __::fileutil::magic::rt::open__
+ and shuts the runtime down. This command has to be invoked last, after the
+ file has been dealt with completely. Afterward another invokation of
+ __::fileutil::magic::rt::open__ is required to process another file.
+
+ This command returns the empty string as its result.
+
+ - __::fileutil::magic::rt::file_start__ *name*
+
+ This command marks the start of a magic file when debugging. It returns the
+ empty string as its result.
+
+ - __::fileutil::magic::rt::result__ ?*msg*?
+
+ This command returns the current result and stops processing.
+
+ If *msg* is specified its text is added to the result before it is returned.
+ See __::fileutil::magic::rt::emit__ for the allowed special character
+ sequences.
+
+ - __::fileutil::magic::rt::resultv__ ?*msg*?
+
+ This command returns the current result. In contrast to
+ __::fileutil::magic::rt::result__ processing continues.
+
+ If *msg* is specified its text is added to the result before it is returned.
+ See __::fileutil::magic::rt::emit__ for the allowed special character
+ sequences.
+
+ - __::fileutil::magic::rt::emit__ *msg*
+
+ This command adds the text *msg* to the result buffer. The message may
+ contain the following special character sequences. They will be replaced
+ with buffered values before the message is added to the result. The command
+ returns the empty string as its result.
+
+ * __\b__
+
+ This sequence is removed
+
+ * __%s__
+
+ Replaced with the last buffered string value.
+
+ * __%ld__
+
+ Replaced with the last buffered numeric value.
+
+ * __%d__
+
+ See above.
+
+ - __::fileutil::magic::rt::offset__ *where*
+
+ - __::fileutil::magic::rt::Nv__ *type* *offset* ?*qual*?
+
+ This command fetches the numeric value with *type* from the absolute
+ location *offset* and returns it as its result. The fetched value is further
+ stored in the numeric buffer.
+
+ If *qual* is specified it is considered to be a mask and applied to the
+ fetched value before it is stored and returned. It has to have the form of a
+ partial Tcl bit-wise expression, i.e.
+
+ & number
+
+ For example:
+
+ Nv lelong 0 &0x8080ffff
+
+ For the possible types see section [NUMERIC TYPES](#section3).
+
+ - __::fileutil::magic::rt::N__ *type* *offset* *comp* *val* ?*qual*?
+
+ This command behaves mostly like __::fileutil::magic::rt::Nv__, except that
+ it compares the fetched and masked value against *val* as specified with
+ *comp* and returns the result of that comparison.
+
+ The argument *comp* has to contain one of Tcl's comparison operators, and
+ the comparison made will be
+
+
+
+ The special comparison operator __x__ signals that no comparison should be
+ done, or, in other words, that the fetched value will always match *val*.
+
+ - __::fileutil::magic::rt::Nvx__ *type* *offset* ?*qual*?
+
+ This command behaves like __::fileutil::magic::rt::Nv__, except that it
+ additionally remembers the location in the file after the fetch in the
+ calling context, for the current level, for later use by
+ __::fileutil::magic::rt::R__.
+
+ - __::fileutil::magic::rt::Nx__ *type* *offset* *comp* *val* ?*qual*?
+
+ This command behaves like __::fileutil::magic::rt::N__, except that it
+ additionally remembers the location in the file after the fetch in the
+ calling context, for the current, for later use by
+ __::fileutil::magic::rt::R__.
+
+ - __::fileutil::magic::rt::S__ *offset* *comp* *val* ?*qual*?
+
+ This command behaves like __::fileutil::magic::rt::N__, except that it
+ fetches and compares strings, not numeric data. The fetched value is also
+ stored in the internal string buffer instead of the numeric buffer.
+
+ - __::fileutil::magic::rt::Sx__ *offset* *comp* *val* ?*qual*?
+
+ This command behaves like __::fileutil::magic::rt::S__, except that it
+ additionally remembers the location in the file after the fetch in the
+ calling context, for the current level, for later use by
+ __::fileutil::magic::rt::R__.
+
+ - __::fileutil::magic::rt::L__ *newlevel*
+
+ This command sets the current level in the calling context to *newlevel*.
+ The command returns the empty string as its result.
+
+ - __::fileutil::magic::rt::I__ *base* *type* *delta*
+
+ This command handles base locations specified indirectly through the
+ contents of the inspected file. It returns the sum of *delta* and the value
+ of numeric *type* fetched from the absolute location *base*.
+
+ For the possible types see section [NUMERIC TYPES](#section3).
+
+ - __::fileutil::magic::rt::R__ *offset*
+
+ This command handles base locations specified relative to the end of the
+ last field one level above.
+
+ In other words, the command computes an absolute location in the file based
+ on the relative *offset* and returns it as its result. The base the offset
+ is added to is the last location remembered for the level in the calling
+ context.
+
+ - __::fileutil::magic::rt::U__ *fileindex* *name*
+
+ Use a named test script at the current level.
+
+# NUMERIC TYPES
+
+ - __byte__
+
+ 8-bit integer
+
+ - __short__
+
+ 16-bit integer, stored in native endianess
+
+ - __beshort__
+
+ see above, stored in big endian
+
+ - __leshort__
+
+ see above, stored in small/little endian
+
+ - __long__
+
+ 32-bit integer, stored in native endianess
+
+ - __belong__
+
+ see above, stored in big endian
+
+ - __lelong__
+
+ see above, stored in small/little endian
+
+All of the types above exit in an unsigned form as well. The type names are the
+same, with the character "u" added as prefix.
+
+ - __date__
+
+ 32-bit integer timestamp, stored in native endianess
+
+ - __bedate__
+
+ see above, stored in big endian
+
+ - __ledate__
+
+ see above, stored in small/little endian
+
+ - __ldate__
+
+ 32-bit integer timestamp, stored in native endianess
+
+ - __beldate__
+
+ see above, stored in big endian
+
+ - __leldate__
+
+ see above, stored in small/little endian
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *fileutil :: magic* of the
+[Tcllib Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any
+ideas for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+file(1), [fileutil](../fileutil/fileutil.md), magic(5)
+
+# KEYWORDS
+
+[file recognition](../../../../index.md#file_recognition), [file
+type](../../../../index.md#file_type), [file
+utilities](../../../../index.md#file_utilities),
+[mime](../../../../index.md#mime), [type](../../../../index.md#type)
+
+# CATEGORY
+
+Programming tools
ADDED embedded/md/tcllib/files/modules/generator/generator.md
Index: embedded/md/tcllib/files/modules/generator/generator.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/generator/generator.md
@@ -0,0 +1,495 @@
+
+[//000000001]: # (generator - Tcl Generator Commands)
+[//000000002]: # (Generated from file 'generator.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (generator(n) 0.1 tcllib "Tcl Generator Commands")
+
+# NAME
+
+generator - Procedures for creating and using generators.
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [PRELUDE](#section3)
+
+ - [BUGS, IDEAS, FEEDBACK](#section4)
+
+ - [Keywords](#keywords)
+
+# SYNOPSIS
+
+package require Tcl 8.6
+package require generator ?0.1?
+
+[__generator__ __define__ *name* *params* *body*](#1)
+[__generator__ __yield__ *arg* ?*args..*?](#2)
+[__generator__ __foreach__ *varList* *generator* *varList* *generator* ?...? *body*](#3)
+[__generator__ __next__ *generator* ?*varName..*?](#4)
+[__generator__ __exists__ *generator*](#5)
+[__generator__ __names__](#6)
+[__generator__ __destroy__ ?*generator..*?](#7)
+[__generator__ __finally__ *cmd* ?*arg..*?](#8)
+[__generator__ __from__ *format* *value*](#9)
+[__generator__ __to__ *format* *generator*](#10)
+[__generator__ __map__ *function* *generator*](#11)
+[__generator__ __filter__ *predicate* *generator*](#12)
+[__generator__ __reduce__ *function* *zero* *generator*](#13)
+[__generator__ __foldl__ *function* *zero* *generator*](#14)
+[__generator__ __foldr__ *function* *zero* *generator*](#15)
+[__generator__ __all__ *predicate* *generator*](#16)
+[__generator__ __and__ *generator*](#17)
+[__generator__ __any__ *generator*](#18)
+[__generator__ __concat__ *generator* ?*generator..*?](#19)
+[__generator__ __concatMap__ *function* *generator*](#20)
+[__generator__ __drop__ *n* *generator*](#21)
+[__generator__ __dropWhile__ *predicate* *generator*](#22)
+[__generator__ __contains__ *element* *generator*](#23)
+[__generator__ __foldl1__ *function* *generator*](#24)
+[__generator__ __foldli__ *function* *zero* *generator*](#25)
+[__generator__ __foldri__ *function* *zero* *generator*](#26)
+[__generator__ __head__ *generator*](#27)
+[__generator__ __tail__ *generator*](#28)
+[__generator__ __init__ *generator*](#29)
+[__generator__ __takeList__ *n* *generator*](#30)
+[__generator__ __take__ *n* *generator*](#31)
+[__generator__ __iterate__ *function* *init*](#32)
+[__generator__ __last__ *generator*](#33)
+[__generator__ __length__ *generator*](#34)
+[__generator__ __or__ *predicate* *generator*](#35)
+[__generator__ __product__ *generator*](#36)
+[__generator__ __repeat__ *n* *value..*](#37)
+[__generator__ __sum__ *generator*](#38)
+[__generator__ __takeWhile__ *predicate* *generator*](#39)
+[__generator__ __splitWhen__ *predicate* *generator*](#40)
+[__generator__ __scanl__ *function* *zero* *generator*](#41)
+
+# DESCRIPTION
+
+The __generator__ package provides commands to define and iterate over generator
+expressions. A *generator* is a command that returns a sequence of values.
+However, unlike an ordinary command that returns a list, a generator *yields*
+each value and then suspends, allowing subsequent values to be fetched
+on-demand. As such, generators can be used to efficiently iterate over a set of
+values, without having to generate all answers in-memory. Generators can be used
+to iterate over elements of a data structure, or rows in the result set of a
+database query, or to decouple producer/consumer software designs such as
+parsers and tokenizers, or to implement sophisticated custom control strategies
+such as backtracking search. Generators reduce the need to implement custom
+control structures, as many such structures can be recast as generators, leading
+to both a simpler implementation and a more standardised interface. The
+generator mechanism is built on top of the Tcl 8.6 coroutine mechanism.
+
+The package exports a single ensemble command, __generator__. All functionality
+is provided as subcommands of this command. The core subcommands of the package
+are __define__, __yield__, and __foreach__. The __define__ command works like
+Tcl's __[proc](../../../../index.md#proc)__ command, but creates a generator
+procedure; that is, a procedure that returns a generator when called. The
+generator itself is a command that can be called multiple times: each time it
+returns the next value in the generated series. When the series has been
+exhausted, the generator command returns an empty list and then destroys itself.
+Rather than manually call a generator, however, the package also provides a
+flexible __foreach__ command that loops through the values of one or more
+generators. This loop construct mimicks the functionality of the built-in Tcl
+__[foreach](../../../../index.md#foreach)__ command, including handling multiple
+return values and looping over multiple generators at once. Writing a generator
+is also a simple task, much like writing a normal procedure: simply use the
+__define__ command to define the generator, and then call __yield__ instead of
+__[return](../../../../index.md#return)__. For example, we can define a
+generator for looping through the integers in a particular range:
+
+ generator define range {n m} {
+ for {set i $n} {$i <= $m} {incr i} { generator yield $i }
+ }
+ generator foreach x [range 1 10] {
+ puts "x = $x"
+ }
+
+The above example will print the numbers from 1 to 10 in sequence, as you would
+expect. The difference from a normal loop over a list is that the numbers are
+only generated as they are needed. If we insert a break into the loop then any
+remaining numbers in the sequence would never be generated. To illustrate, we
+can define a generator that produces the sequence of natural numbers: an
+infinite series. A normal procedure would never return trying to produce this
+series as a list. By using a generator we only have to generate those values
+which are actually used:
+
+ generator define nats {} {
+ while 1 { generator yield [incr nat] }
+ }
+ generator foreach n [nats] {
+ if {$n > 100} { break }
+ }
+
+# COMMANDS
+
+ - __generator__ __define__ *name* *params* *body*
+
+ Creates a new generator procedure. The arguments to the command are
+ identical to those for __[proc](../../../../index.md#proc)__: a *name*, a
+ list of parameters, and a body. The parameter list format is identical to a
+ procedure. In particular, default values and the ?args? syntax can be used
+ as usual. Each time the resulting generator procedure is called it creates a
+ new generator command (coroutine) that will yield a list of values on each
+ call. Each result from a generator is guaranteed to be a non-empty list of
+ values. When a generator is exhausted it returns an empty list and then
+ destroys itself to free up resources. It is an error to attempt to call an
+ exhausted generator as the command no longer exists.
+
+ - __generator__ __yield__ *arg* ?*args..*?
+
+ Used in the definition of a generator, this command returns the next set of
+ values to the consumer. Once the __yield__ command has been called the
+ generator will suspend to allow the consumer to process that value. When the
+ next value is requested, the generator will resume as if the yield command
+ had just returned, and can continue processing to yield the next result. The
+ __yield__ command must be called with at least one argument, but can be
+ called with multiple arguments, in which case this is equivalent to calling
+ __yield__ once for each argument.
+
+ - __generator__ __foreach__ *varList* *generator* *varList* *generator* ?...? *body*
+
+ Loops through one or more generators, assigning the next values to variables
+ and then executing the loop body. Works much like the built-in
+ __[foreach](../../../../index.md#foreach)__ command, but working with
+ generators rather than lists. Multiple generators can be iterated over in
+ parallel, and multiple results can be retrieved from a single generator at
+ once. Like the built-in __[foreach](../../../../index.md#foreach)__, the
+ loop will continue until all of the generators have been exhausted:
+ variables for generators that are exhausted early will be set to the empty
+ string.
+
+ The __foreach__ command will automatically clean-up all of the generators at
+ the end of the loop, regardless of whether the loop terminated early or not.
+ This behaviour is provided as a convenience to avoid having to explicitly
+ clean up a generator in the usual cases. Generators can however be destroyed
+ before the end of the loop, in which case the loop will continue as normal
+ until all the other generators have been destroyed or exhausted.
+
+ The __foreach__ command does not take a snapshot of the generator. Any
+ changes in the state of the generator made inside the loop or by other code
+ will affect the state of the loop. In particular, if the code in the loop
+ invokes the generator to manually retrieve the next element, this element
+ will then be excluded from the loop, and the next iteration will continue
+ from the element after that one. Care should be taken to avoid concurrent
+ updates to generators unless this behaviour is required (e.g., in argument
+ processing).
+
+ - __generator__ __next__ *generator* ?*varName..*?
+
+ Manually retrieves the next values from a generator. One value is retrieved
+ for each variable supplied and assigned to the corresponding variable. If
+ the generator becomes exhausted at any time then any remaining variables are
+ set to the empty string.
+
+ - __generator__ __exists__ *generator*
+
+ Returns 1 if the generator (still) exists, or 0 otherwise.
+
+ - __generator__ __names__
+
+ Returns a list of all currently existing generator commands.
+
+ - __generator__ __destroy__ ?*generator..*?
+
+ Destroys one or more generators, freeing any associated resources.
+
+ - __generator__ __finally__ *cmd* ?*arg..*?
+
+ Used in the definition of a generator procedure, this command arranges for a
+ resource to be cleaned up whenever the generator is destroyed, either
+ explicitly or implicitly when the generator is exhausted. This command can
+ be used like a __finally__ block in the __[try](../try/tcllib_try.md)__
+ command, except that it is tied to the life-cycle of the generator rather
+ than to a particular scope. For example, if we create a generator to iterate
+ over the lines in a text file, we can use __finally__ to ensure that the
+ file is closed whenever the generator is destroyed:
+
+ generator define lines file {
+ set in [open $file]
+ # Ensure file is always closed
+ generator finally close $in
+ while {[gets $in line] >= 0} {
+ generator yield $line
+ }
+ }
+ generator foreach line [lines /etc/passwd] {
+ puts "[incr count]: $line"
+ if {$count > 10} { break }
+ }
+ # File will be closed even on early exit
+
+ If you create a generator that consumes another generator (such as the
+ standard __map__ and __filter__ generators defined later), then you should
+ use a __finally__ command to ensure that this generator is destroyed when
+ its parent is. For example, the __map__ generator is defined as follows:
+
+ generator define map {f xs} {
+ generator finally generator destroy $xs
+ generator foreach x $xs { generator yield [{*}$f $x] }
+ }
+
+ - __generator__ __from__ *format* *value*
+
+ Creates a generator from a data structure. Currently, supported formats are
+ __list__, __dict__, or __string__. The list format yields each element in
+ turn. For dictionaries, each key and value are yielded separately. Finally,
+ strings are yielded a character at a time.
+
+ - __generator__ __to__ *format* *generator*
+
+ Converts a generator into a data structure. This is the reverse operation of
+ the __from__ command, and supports the same data structures. The two
+ operations obey the following identity laws (where __=__ is interpreted
+ appropriately):
+
+ [generator to $fmt [generator from $fmt $value]] = $value
+ [generator from $fmt [generator to $fmt $gen]] = $gen
+
+# PRELUDE
+
+The following commands are provided as a standard library of generator
+combinators and functions that perform convenience operations on generators. The
+functions in this section are loosely modelled on the equivalent functions from
+the Haskell Prelude. *Warning:* most of the functions in this prelude destroy
+any generator arguments they are passed as a side-effect. If you want to have
+persistent generators, see the streams library.
+
+ - __generator__ __map__ *function* *generator*
+
+ Apply a function to every element of a generator, returning a new generator
+ of the results. This is the classic map function from functional
+ programming, applied to generators. For example, we can generate all the
+ square numbers using the following code (where __nats__ is defined as
+ earlier):
+
+ proc square x { expr {$x * $x} }
+ generator foreach n [generator map square [nats]] {
+ puts "n = $n"
+ if {$n > 1000} { break }
+ }
+
+ - __generator__ __filter__ *predicate* *generator*
+
+ Another classic functional programming gem. This command returns a generator
+ that yields only those items from the argument generator that satisfy the
+ predicate (boolean function). For example, if we had a generator
+ __employees__ that returned a stream of dictionaries representing people, we
+ could filter all those whose salaries are above 100,000 dollars (or
+ whichever currency you prefer) using a simple filter:
+
+ proc salary> {amount person} { expr {[dict get $person salary] > $amount} }
+ set fat-cats [generator filter {salary> 100000} $employees]
+
+ - __generator__ __reduce__ *function* *zero* *generator*
+
+ This is the classic left-fold operation. This command takes a function, an
+ initial value, and a generator of values. For each element in the generator
+ it applies the function to the current accumulator value (the *zero*
+ argument initially) and that element, and then uses the result as the new
+ accumulator value. This process is repeated through the entire generator
+ (eagerly) and the final accumulator value is then returned. If we consider
+ the function to be a binary operator, and the zero argument to be the left
+ identity element of that operation, then we can consider the __reduce__
+ command as *folding* the operator between each successive pair of values in
+ the generator in a left-associative fashion. For example, the sum of a
+ sequence of numbers can be calculated by folding a __+__ operator between
+ them, with 0 as the identity:
+
+ # sum xs = reduce + 0 xs
+ # sum [range 1 5] = reduce + 0 [range 1 5]
+ # = reduce + [+ 0 1] [range 2 5]
+ # = reduce + [+ 1 2] [range 3 5]
+ # = ...
+ # = reduce + [+ 10 5]
+ # = ((((0+1)+2)+3)+4)+5
+ # = 15
+ proc + {a b} { expr {$a + $b} }
+ proc sum gen { generator reduce + 0 $gen }
+ puts [sum [range 1 10]]
+
+ The __reduce__ operation is an extremely useful one, and a great variety of
+ different operations can be defined using it. For example, we can define a
+ factorial function as the product of a range using generators. This
+ definition is both very clear and also quite efficient (in both memory and
+ running time):
+
+ proc * {x y} { expr {$x * $y} }
+ proc prod gen { generator reduce * 0 $gen }
+ proc fac n { prod [range 1 $n] }
+
+ However, while the __reduce__ operation is efficient for finite generators,
+ care should be taken not to apply it to an infinite generator, as this will
+ result in an infinite loop:
+
+ sum [nats]; # Never returns
+
+ - __generator__ __foldl__ *function* *zero* *generator*
+
+ This is an alias for the __reduce__ command.
+
+ - __generator__ __foldr__ *function* *zero* *generator*
+
+ This is the right-associative version of __reduce__. This operation is
+ generally inefficient, as the entire generator needs to be evaluated into
+ memory (as a list) before the reduction can commence. In an eagerly
+ evaluated language like Tcl, this operation has limited use, and should be
+ avoided if possible.
+
+ - __generator__ __all__ *predicate* *generator*
+
+ Returns true if all elements of the generator satisfy the given predicate.
+
+ - __generator__ __and__ *generator*
+
+ Returns true if all elements of the generator are true (i.e., takes the
+ logical conjunction of the elements).
+
+ - __generator__ __any__ *generator*
+
+ Returns true if any of the elements of the generator are true (i.e., logical
+ disjunction).
+
+ - __generator__ __concat__ *generator* ?*generator..*?
+
+ Returns a generator which is the concatenation of each of the argument
+ generators.
+
+ - __generator__ __concatMap__ *function* *generator*
+
+ Given a function which maps a value to a series of values, and a generator
+ of values of that type, returns a generator of all of the results in one
+ flat series. Equivalent to __concat__ applied to the result of __map__.
+
+ - __generator__ __drop__ *n* *generator*
+
+ Removes the given number of elements from the front of the generator and
+ returns the resulting generator with those elements removed.
+
+ - __generator__ __dropWhile__ *predicate* *generator*
+
+ Removes all elements from the front of the generator that satisfy the
+ predicate.
+
+ - __generator__ __contains__ *element* *generator*
+
+ Returns true if the generator contains the given element. Note that this
+ will destroy the generator!
+
+ - __generator__ __foldl1__ *function* *generator*
+
+ A version of __foldl__ that takes the *zero* argument from the first element
+ of the generator. Therefore this function is only valid on non-empty
+ generators.
+
+ - __generator__ __foldli__ *function* *zero* *generator*
+
+ A version of __foldl__ that supplies the integer index of each element as
+ the first argument to the function. The first element in the generator at
+ this point is given index 0.
+
+ - __generator__ __foldri__ *function* *zero* *generator*
+
+ Right-associative version of __foldli__.
+
+ - __generator__ __head__ *generator*
+
+ Returns the first element of the generator.
+
+ - __generator__ __tail__ *generator*
+
+ Removes the first element of the generator, returning the rest.
+
+ - __generator__ __init__ *generator*
+
+ Returns a new generator consisting of all elements except the last of the
+ argument generator.
+
+ - __generator__ __takeList__ *n* *generator*
+
+ Returns the next *n* elements of the generator as a list. If not enough
+ elements are left in the generator, then just the remaining elements are
+ returned.
+
+ - __generator__ __take__ *n* *generator*
+
+ Returns the next *n* elements of the generator as a new generator. The old
+ generator is destroyed.
+
+ - __generator__ __iterate__ *function* *init*
+
+ Returns an infinite generator formed by repeatedly applying the function to
+ the initial argument. For example, the Fibonacci numbers can be defined as
+ follows:
+
+ proc fst pair { lindex $pair 0 }
+ proc snd pair { lindex $pair 1 }
+ proc nextFib ab { list [snd $ab] [expr {[fst $ab] + [snd $ab]}] }
+ proc fibs {} { generator map fst [generator iterate nextFib {0 1}] }
+
+ - __generator__ __last__ *generator*
+
+ Returns the last element of the generator (if it exists).
+
+ - __generator__ __length__ *generator*
+
+ Returns the length of the generator, destroying it in the process.
+
+ - __generator__ __or__ *predicate* *generator*
+
+ Returns 1 if any of the elements of the generator satisfy the predicate.
+
+ - __generator__ __product__ *generator*
+
+ Returns the product of the numbers in a generator.
+
+ - __generator__ __repeat__ *n* *value..*
+
+ Returns a generator that consists of *n* copies of the given elements. The
+ special value *Inf* can be used to generate an infinite sequence.
+
+ - __generator__ __sum__ *generator*
+
+ Returns the sum of the values in the generator.
+
+ - __generator__ __takeWhile__ *predicate* *generator*
+
+ Returns a generator of the first elements in the argument generator that
+ satisfy the predicate.
+
+ - __generator__ __splitWhen__ *predicate* *generator*
+
+ Splits the generator into lists of elements using the predicate to identify
+ delimiters. The resulting lists are returned as a generator. Elements
+ matching the delimiter predicate are discarded. For example, to split up a
+ generator using the string "|" as a delimiter:
+
+ set xs [generator from list {a | b | c}]
+ generator split {string equal "|"} $xs ;# returns a then b then c
+
+ - __generator__ __scanl__ *function* *zero* *generator*
+
+ Similar to __foldl__, but returns a generator of all of the intermediate
+ values for the accumulator argument. The final element of this generator is
+ equivalent to __foldl__ called on the same arguments.
+
+# BUGS, IDEAS, FEEDBACK
+
+Please report any errors in this document, or in the package it describes, to
+[Neil Madden](mailto:nem@cs.nott.ac.uk).
+
+# KEYWORDS
+
+[control structure](../../../../index.md#control_structure),
+[coroutine](../../../../index.md#coroutine),
+[filter](../../../../index.md#filter), [foldl](../../../../index.md#foldl),
+[foldr](../../../../index.md#foldr), [foreach](../../../../index.md#foreach),
+[generator](../../../../index.md#generator),
+[iterator](../../../../index.md#iterator), [map](../../../../index.md#map),
+[reduce](../../../../index.md#reduce), [scanl](../../../../index.md#scanl)
ADDED embedded/md/tcllib/files/modules/gpx/gpx.md
Index: embedded/md/tcllib/files/modules/gpx/gpx.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/gpx/gpx.md
@@ -0,0 +1,197 @@
+
+[//000000001]: # (gpx - GPS eXchange Format (GPX))
+[//000000002]: # (Generated from file 'gpx.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (gpx(n) 0.9 tcllib "GPS eXchange Format (GPX)")
+
+# NAME
+
+gpx - Extracts waypoints, tracks and routes from GPX files
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [COMMANDS](#section2)
+
+ - [DATA STRUCTURES](#section3)
+
+ - [EXAMPLE](#section4)
+
+ - [REFERENCES](#section5)
+
+ - [AUTHOR](#section6)
+
+ - [Bugs, Ideas, Feedback](#section7)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require gpx ?0.9?
+
+[__::gpx::Create__ *gpxFilename* ?*rawXML*?](#1)
+[__::gpx::Cleanup__ *token*](#2)
+[__::gpx::GetGPXMetadata__ *token*](#3)
+[__::gpx::GetWaypointCount__ *token*](#4)
+[__::gpx::GetAllWaypoints__ *token*](#5)
+[__::gpx::GetTrackCount__ *token*](#6)
+[__::gpx::GetTrackMetadata__ *token* *whichTrack*](#7)
+[__::gpx::GetTrackPoints__ *token* *whichTrack*](#8)
+[__::gpx::GetRouteCount__ *token*](#9)
+[__::gpx::GetRouteMetadata__ *token* *whichRoute*](#10)
+[__::gpx::GetRoutePoints__ *token* *whichRoute*](#11)
+
+# DESCRIPTION
+
+This module parses and extracts waypoints, tracks, routes and metadata from a
+GPX (GPS eXchange) file. Both GPX version 1.0 and 1.1 are supported.
+
+# COMMANDS
+
+ - __::gpx::Create__ *gpxFilename* ?*rawXML*?
+
+ The __::gpx::Create__ is the first command called to process GPX data. It
+ takes the GPX data from either the *rawXML* parameter if present or from the
+ contents of *gpxFilename*, and parses it using *tdom*. It returns a token
+ value that is used by all the other commands.
+
+ - __::gpx::Cleanup__ *token*
+
+ This procedure cleans up resources associated with *token*. It is *strongly*
+ recommended that you call this function after you are done with a given GPX
+ file. Not doing so will result in memory not being freed, and if your app
+ calls __::gpx::Create__ enough times, the memory leak could cause a
+ performance hit...or worse.
+
+ - __::gpx::GetGPXMetadata__ *token*
+
+ This procedure returns a dictionary of the metadata associated with the GPX
+ data identified by *token*. The format of the metadata dictionary is
+ described below, but keys *version* and *creator* will always be present.
+
+ - __::gpx::GetWaypointCount__ *token*
+
+ This procedure returns the number of waypoints defined in the GPX data
+ identified by *token*.
+
+ - __::gpx::GetAllWaypoints__ *token*
+
+ This procedure returns the a list of waypoints defined in the GPX data
+ identified by *token*. The format of each waypoint item is described below.
+
+ - __::gpx::GetTrackCount__ *token*
+
+ This procedure returns the number of tracks defined in the GPX data
+ identified by *token*.
+
+ - __::gpx::GetTrackMetadata__ *token* *whichTrack*
+
+ This procedure returns a dictionary of the metadata associated track number
+ *whichTrack* (1 based) in the GPX data identified by *token*. The format of
+ the metadata dictionary is described below.
+
+ - __::gpx::GetTrackPoints__ *token* *whichTrack*
+
+ The procedure returns a list of track points comprising track number
+ *whichTrack* (1 based) in the GPX data identified by *token*. The format of
+ the metadata dictionary is described below.
+
+ - __::gpx::GetRouteCount__ *token*
+
+ This procedure returns the number of routes defined in the GPX data
+ identified by *token*.
+
+ - __::gpx::GetRouteMetadata__ *token* *whichRoute*
+
+ This procedure returns a dictionary of the metadata associated route number
+ *whichRoute* (1 based) in the GPX data identified by *token*. The format of
+ the metadata dictionary is described below.
+
+ - __::gpx::GetRoutePoints__ *token* *whichRoute*
+
+ The procedure returns a list of route points comprising route number
+ *whichRoute* (1 based) in the GPX data identified by *token*. The format of
+ the metadata dictionary is described below.
+
+# DATA STRUCTURES
+
+ - metadata dictionary
+
+ The metadata associated with either the GPX document, a track, a route, a
+ waypoint, a track point or route point is returned in a dictionary. The keys
+ of that dictionary will be whatever optional GPX elements are present. The
+ value for each key depends on the GPX schema for that element. For example,
+ the value for a version key will be a string, while for a link key will be a
+ sub-dictionary with keys *href* and optionally *text* and *type*.
+
+ - point item
+
+ Each item in a track or route list of points consists of a list of three
+ elements: *latitude*, *longitude* and *metadata dictionary*. *Latitude* and
+ *longitude* are decimal numbers. The *metadata dictionary* format is
+ described above. For points in a track, typically there will always be ele
+ (elevation) and time metadata keys.
+
+# EXAMPLE
+
+ % set token [::gpx::Create myGpxFile.gpx]
+ % set version [dict get [::gpx::GetGPXMetadata $token] version]
+ % set trackCnt [::gpx::GetTrackCount $token]
+ % set firstPoint [lindex [::gpx::GetTrackPoints $token 1] 0]
+ % lassign $firstPoint lat lon ptMetadata
+ % puts "first point in the first track is at $lat, $lon"
+ % if {[dict exists $ptMetadata ele]} {
+ puts "at elevation [dict get $ptMetadata ele] meters"
+ }
+ % ::gpx::Cleanup $token
+
+# REFERENCES
+
+ 1. GPX: the GPS Exchange Format
+ ([http://www.topografix.com/gpx.asp](http://www.topografix.com/gpx.asp))
+
+ 1. GPX 1.1 Schema Documentation
+ ([http://www.topografix.com/GPX/1/1/](http://www.topografix.com/GPX/1/1/))
+
+ 1. GPX 1.0 Developer's Manual
+ ([http://www.topografix.com/gpx_manual.asp](http://www.topografix.com/gpx_manual.asp))
+
+# AUTHOR
+
+Keith Vetter
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *gpx* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[gps](../../../../index.md#gps), [gpx](../../../../index.md#gpx)
+
+# CATEGORY
+
+File formats
+
+# COPYRIGHT
+
+Copyright © 2010, Keith Vetter
ADDED embedded/md/tcllib/files/modules/grammar_aycock/aycock.md
Index: embedded/md/tcllib/files/modules/grammar_aycock/aycock.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_aycock/aycock.md
@@ -0,0 +1,164 @@
+
+[//000000001]: # (grammar::aycock - Aycock-Horspool-Earley parser generator for Tcl)
+[//000000002]: # (Generated from file 'aycock.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::aycock(n) 1.0 tcllib "Aycock-Horspool-Earley parser generator for Tcl")
+
+# NAME
+
+grammar::aycock - Aycock-Horspool-Earley parser generator for Tcl
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [PROCEDURES](#section2)
+
+ - [OBJECT COMMAND](#section3)
+
+ - [DESCRIPTION](#section4)
+
+ - [EXAMPLE](#section5)
+
+ - [KEYWORDS](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require grammar::aycock ?1.0?
+
+[__::aycock::parser__ *grammar* ?__-verbose__?](#1)
+[*parserName* __parse__ *symList* *valList* ?*clientData*?](#2)
+[*parserName* __destroy__](#3)
+[*parserName* __terminals__](#4)
+[*parserName* __nonterminals__](#5)
+[*parserName* __save__](#6)
+
+# DESCRIPTION
+
+The __grammar::aycock__ package implements a parser generator for the class of
+parsers described in John Aycock and R. Nigel Horspool. Practical Earley
+Parsing. *The Computer Journal,* *45*(6):620-630, 2002.
+[http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.12.4254](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.12.4254)
+
+# PROCEDURES
+
+The __grammar::aycock__ package exports the single procedure:
+
+ - __::aycock::parser__ *grammar* ?__-verbose__?
+
+ Generates a parser for the given *grammar*, and returns its name. If the
+ optional __-verbose__ flag is given, dumps verbose information relating to
+ the generated parser to the standard output. The returned parser is an
+ object that accepts commands as shown in [OBJECT COMMAND](#section3) below.
+
+# OBJECT COMMAND
+
+ - *parserName* __parse__ *symList* *valList* ?*clientData*?
+
+ Invokes a parser returned from __::aycock::parser__. *symList* is a list of
+ grammar symbols representing the terminals in an input string, and *valList*
+ is a list of their semantic values. The result is the semantic value of the
+ entire string when parsed.
+
+ - *parserName* __destroy__
+
+ Destroys a parser constructed by __::aycock::parser__.
+
+ - *parserName* __terminals__
+
+ Returns a list of terminal symbols that may be presented in the *symList*
+ argument to the __parse__ object command.
+
+ - *parserName* __nonterminals__
+
+ Returns a list of nonterminal symbols that were defined in the parser's
+ grammar.
+
+ - *parserName* __save__
+
+ Returns a Tcl script that will reconstruct the parser without needing all
+ the mechanism of the parser generator at run time. The reconstructed parser
+ depends on a set of commands in the package __grammar::aycock::runtime__,
+ which is also automatically loaded when the __grammar::aycock__ package is
+ loaded.
+
+# DESCRIPTION
+
+The __grammar::aycock::parser__ command accepts a grammar expressed as a Tcl
+list. The list must be structured as the concatenation of a set of *rule*s. Each
+*rule* comprises a variable number of elements in the list:
+
+ - The name of the nonterminal symbol that the rule reduces.
+
+ - The literal string, __::=__
+
+ - Zero or more names of terminal or nonterminal symbols that comprise the
+ right-hand-side of the rule.
+
+ - Finally, a Tcl script to execute when the rule is reduced. Within the given
+ script, a variable called _____ contains a list of the semantic values of
+ the symbols on the right-hand side. The value returned by the script is
+ expected to be the semantic value of the left-hand side. If the *clientData*
+ parameter was passed to the __parse__ method, it is available in a variable
+ called __clientData__. It is permissible for the script to be the empty
+ string. In this case, the semantic value of the rule will be the same as the
+ semantic value of the first symbol on the right-hand side. If the right-hand
+ side is also empty, the semantic value will be the empty string.
+
+Parsing is done with an Earley parser, which is not terribly efficient in speed
+or memory consumption, but which deals effectively with ambiguous grammars. For
+this reason, the __grammar::aycock__ package is perhaps best adapted to
+natural-language processing or the parsing of extraordinarily complex languages
+in which ambiguity can be tolerated.
+
+# EXAMPLE
+
+The following code demonstrates a trivial desk calculator, admitting only __+__,
+__*__ and parentheses as its operators. It also shows the format in which the
+lexical analyzer is expected to present terminal symbols to the parser.
+
+ set p [aycock::parser {
+ start ::= E {}
+ E ::= E + T {expr {[lindex $_ 0] + [lindex $_ 2]}}
+ E ::= T {}
+ T ::= T * F {expr {[lindex $_ 0] * [lindex $_ 2]}}
+ T ::= F {}
+ F ::= NUMBER {}
+ F ::= ( E ) {lindex $_ 1}
+ }]
+ puts [$p parse {( NUMBER + NUMBER ) * ( NUMBER + NUMBER ) } {{} 2 {} 3 {} {} {} 7 {} 1 {}}]
+ $p destroy
+
+The example, when run, prints __40__.
+
+# KEYWORDS
+
+Aycock, Earley, Horspool, parser, compiler
+
+# KEYWORDS
+
+[ambiguous](../../../../index.md#ambiguous),
+[aycock](../../../../index.md#aycock), [earley](../../../../index.md#earley),
+[grammar](../../../../index.md#grammar),
+[horspool](../../../../index.md#horspool),
+[parser](../../../../index.md#parser), [parsing](../../../../index.md#parsing),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2006 by Kevin B. Kenny
+Redistribution permitted under the terms of the Open Publication License
ADDED embedded/md/tcllib/files/modules/grammar_fa/dacceptor.md
Index: embedded/md/tcllib/files/modules/grammar_fa/dacceptor.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_fa/dacceptor.md
@@ -0,0 +1,132 @@
+
+[//000000001]: # (grammar::fa::dacceptor - Finite automaton operations and usage)
+[//000000002]: # (Generated from file 'dacceptor.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::fa::dacceptor(n) 0.1.1 tcllib "Finite automaton operations and usage")
+
+# NAME
+
+grammar::fa::dacceptor - Create and use deterministic acceptors
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [ACCEPTOR METHODS](#section3)
+
+ - [EXAMPLES](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require snit
+package require struct::set
+package require grammar::fa::dacceptor ?0.1.1?
+
+[__::grammar::fa::dacceptor__ *daName* *fa* ?__-any__ *any*?](#1)
+[__daName__ *option* ?*arg arg ...*?](#2)
+[*daName* __destroy__](#3)
+[*daName* __accept?__ *symbols*](#4)
+
+# DESCRIPTION
+
+This package provides a class for acceptors constructed from deterministic
+*finite automatons* (DFA). Acceptors are objects which can be given a string of
+symbols and tell if the DFA they are constructed from would *accept* that
+string. For the actual creation of the DFAs the acceptors are based on we have
+the packages __[grammar::fa](fa.md)__ and __[grammar::fa::op](faop.md)__.
+
+# API
+
+The package exports the API described here.
+
+ - __::grammar::fa::dacceptor__ *daName* *fa* ?__-any__ *any*?
+
+ Creates a new deterministic acceptor with an associated global Tcl command
+ whose name is *daName*. This command may be used to invoke various
+ operations on the acceptor. It has the following general form:
+
+ * __daName__ *option* ?*arg arg ...*?
+
+ *Option* and the *arg*s determine the exact behavior of the command. See
+ section [ACCEPTOR METHODS](#section3) for more explanations.
+
+ The acceptor will be based on the deterministic finite automaton stored
+ in the object *fa*. It will keep a copy of the relevant data of the FA
+ in its own storage, in a form easy to use for its purposes. This also
+ means that changes made to the *fa* after the construction of the
+ acceptor *will not* influence the acceptor.
+
+ If *any* has been specified, then the acceptor will convert all symbols
+ in the input which are unknown to the base FA to that symbol before
+ proceeding with the processing.
+
+# ACCEPTOR METHODS
+
+All acceptors provide the following methods for their manipulation:
+
+ - *daName* __destroy__
+
+ Destroys the automaton, including its storage space and associated command.
+
+ - *daName* __accept?__ *symbols*
+
+ Takes the list of *symbols* and checks if the FA the acceptor is based on
+ would accept it. The result is a boolean value. __True__ is returned if the
+ symbols are accepted, and __False__ otherwise. Note that bogus symbols in
+ the input are either translated to the *any* symbol (if specified), or cause
+ the acceptance test to simply fail. No errors will be thrown. The method
+ will process only just that prefix of the input which is enough to fully
+ determine (non-)acceptance.
+
+# EXAMPLES
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_fa* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[acceptance](../../../../index.md#acceptance),
+[acceptor](../../../../index.md#acceptor),
+[automaton](../../../../index.md#automaton), [finite
+automaton](../../../../index.md#finite_automaton),
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [regular
+expression](../../../../index.md#regular_expression), [regular
+grammar](../../../../index.md#regular_grammar), [regular
+languages](../../../../index.md#regular_languages),
+[state](../../../../index.md#state),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2004 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_fa/dexec.md
Index: embedded/md/tcllib/files/modules/grammar_fa/dexec.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_fa/dexec.md
@@ -0,0 +1,200 @@
+
+[//000000001]: # (grammar::fa::dexec - Finite automaton operations and usage)
+[//000000002]: # (Generated from file 'dexec.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::fa::dexec(n) 0.2 tcllib "Finite automaton operations and usage")
+
+# NAME
+
+grammar::fa::dexec - Execute deterministic finite automatons
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [EXECUTOR METHODS](#section3)
+
+ - [EXECUTOR CALLBACK](#section4)
+
+ - [EXAMPLES](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require snit
+package require grammar::fa::dexec ?0.2?
+
+[__::grammar::fa::dexec__ *daName* *fa* ?__-any__ *any*? ?__-command__ *cmdprefix*?](#1)
+[__daName__ *option* ?*arg arg ...*?](#2)
+[*daName* __destroy__](#3)
+[*daName* __put__ *symbol*](#4)
+[*daName* __reset__](#5)
+[*daName* __state__](#6)
+[*cmdprefix* __error__ *code* *message*](#7)
+[*cmdprefix* __final__ *stateid*](#8)
+[*cmdprefix* __reset__](#9)
+[*cmdprefix* __state__ *stateid*](#10)
+
+# DESCRIPTION
+
+This package provides a class for executors constructed from deterministic
+*finite automatons* (DFA). Executors are objects which are given a string of
+symbols in a piecemal fashion, perform state transitions and report back when
+they enter a final state, or find an error in the input. For the actual creation
+of the DFAs the executors are based on we have the packages
+__[grammar::fa](fa.md)__ and __[grammar::fa::op](faop.md)__.
+
+The objects follow a push model. Symbols are pushed into the executor, and when
+something important happens, i.e. error occurs, a state transition, or a final
+state is entered this will be reported via the callback specified via the option
+__-command__. Note that conversion of this into a pull model where the
+environment retrieves messages from the object and the object uses a callback to
+ask for more symbols is a trivial thing.
+
+*Side note*: The acceptor objects provided by
+__[grammar::fa::dacceptor](dacceptor.md)__ could have been implemented on top of
+the executors provided here, but were not, to get a bit more performance (we
+avoid a number of method calls and the time required for their dispatch).
+
+# API
+
+The package exports the API described here.
+
+ - __::grammar::fa::dexec__ *daName* *fa* ?__-any__ *any*? ?__-command__ *cmdprefix*?
+
+ Creates a new deterministic executor with an associated global Tcl command
+ whose name is *daName*. This command may be used to invoke various
+ operations on the executor. It has the following general form:
+
+ * __daName__ *option* ?*arg arg ...*?
+
+ *Option* and the *arg*s determine the exact behavior of the command. See
+ section [EXECUTOR METHODS](#section3) for more explanations.
+
+ The executor will be based on the deterministic finite automaton stored
+ in the object *fa*. It will keep a copy of the relevant data of the FA
+ in its own storage, in a form easy to use for its purposes. This also
+ means that changes made to the *fa* after the construction of the
+ executor *will not* influence the executor.
+
+ If *any* has been specified, then the executor will convert all symbols
+ in the input which are unknown to the base FA to that symbol before
+ proceeding with the processing.
+
+# EXECUTOR METHODS
+
+All executors provide the following methods for their manipulation:
+
+ - *daName* __destroy__
+
+ Destroys the automaton, including its storage space and associated command.
+
+ - *daName* __put__ *symbol*
+
+ Takes the current state of the executor and the *symbol* and performs the
+ appropriate state transition. Reports any errors encountered via the command
+ callback, as well as entering a final state of the underlying FA.
+
+ When an error is reported all further invokations of __put__ will do
+ nothing, until the error condition has been cleared via an invokation of
+ method __reset__.
+
+ - *daName* __reset__
+
+ Unconditionally sets the executor into the start state of the underlying FA.
+ This also clears any error condition __put__ may have encountered.
+
+ - *daName* __state__
+
+ Returns the current state of the underlying FA. This allow for introspection
+ without the need to pass data from the callback command.
+
+# EXECUTOR CALLBACK
+
+The callback command *cmdprefix* given to an executor via the option
+__-command__ will be executed by the object at the global level, using the
+syntax described below. Note that *cmdprefix* is not simply the name of a
+command, but a full command prefix. In other words it may contain additional
+fixed argument words beyond the command word.
+
+ - *cmdprefix* __error__ *code* *message*
+
+ The executor has encountered an error, and *message* contains a
+ human-readable text explaining the nature of the problem. The *code* on the
+ other hand is a fixed machine-readable text. The following error codes can
+ be generated by executor objects.
+
+ * __BADSYM__
+
+ An unknown symbol was found in the input. This can happen if and only if
+ no __-any__ symbol was specified.
+
+ * __BADTRANS__
+
+ The underlying FA has no transition for the current combination of input
+ symbol and state. In other words, the executor was not able to compute a
+ new state for this combination.
+
+ - *cmdprefix* __final__ *stateid*
+
+ The executor has entered the final state *stateid*.
+
+ - *cmdprefix* __reset__
+
+ The executor was reset.
+
+ - *cmdprefix* __state__ *stateid*
+
+ The FA changed state due to a transition. *stateid* is the new state.
+
+# EXAMPLES
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_fa* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[automaton](../../../../index.md#automaton),
+[execution](../../../../index.md#execution), [finite
+automaton](../../../../index.md#finite_automaton),
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [regular
+expression](../../../../index.md#regular_expression), [regular
+grammar](../../../../index.md#regular_grammar), [regular
+languages](../../../../index.md#regular_languages),
+[running](../../../../index.md#running), [state](../../../../index.md#state),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2004 Andreas Kupries
+Copyright © 2007 Bogdan
ADDED embedded/md/tcllib/files/modules/grammar_fa/fa.md
Index: embedded/md/tcllib/files/modules/grammar_fa/fa.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_fa/fa.md
@@ -0,0 +1,620 @@
+
+[//000000001]: # (grammar::fa - Finite automaton operations and usage)
+[//000000002]: # (Generated from file 'fa.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::fa(n) 0.4 tcllib "Finite automaton operations and usage")
+
+# NAME
+
+grammar::fa - Create and manipulate finite automatons
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [FA METHODS](#section3)
+
+ - [EXAMPLES](#section4)
+
+ - [FINITE AUTOMATONS](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require snit 1.3
+package require struct::list
+package require struct::set
+package require grammar::fa::op ?0.2?
+package require grammar::fa ?0.4?
+
+[__::grammar::fa__ *faName* ?__=__|__:=__|__<--__|__as__|__deserialize__ *src*|__fromRegex__ *re* ?*over*??](#1)
+[__faName__ *option* ?*arg arg ...*?](#2)
+[*faName* __destroy__](#3)
+[*faName* __clear__](#4)
+[*faName* __=__ *srcFA*](#5)
+[*faName* __-->__ *dstFA*](#6)
+[*faName* __serialize__](#7)
+[*faName* __deserialize__ *serialization*](#8)
+[*faName* __states__](#9)
+[*faName* __state__ __add__ *s1* ?*s2* ...?](#10)
+[*faName* __state__ __delete__ *s1* ?*s2* ...?](#11)
+[*faName* __state__ __exists__ *s*](#12)
+[*faName* __state__ __rename__ *s* *snew*](#13)
+[*faName* __startstates__](#14)
+[*faName* __start__ __add__ *s1* ?*s2* ...?](#15)
+[*faName* __start__ __remove__ *s1* ?*s2* ...?](#16)
+[*faName* __start?__ *s*](#17)
+[*faName* __start?set__ *stateset*](#18)
+[*faName* __finalstates__](#19)
+[*faName* __final__ __add__ *s1* ?*s2* ...?](#20)
+[*faName* __final__ __remove__ *s1* ?*s2* ...?](#21)
+[*faName* __final?__ *s*](#22)
+[*faName* __final?set__ *stateset*](#23)
+[*faName* __symbols__](#24)
+[*faName* __symbols@__ *s* ?*d*?](#25)
+[*faName* __symbols@set__ *stateset*](#26)
+[*faName* __symbol__ __add__ *sym1* ?*sym2* ...?](#27)
+[*faName* __symbol__ __delete__ *sym1* ?*sym2* ...?](#28)
+[*faName* __symbol__ __rename__ *sym* *newsym*](#29)
+[*faName* __symbol__ __exists__ *sym*](#30)
+[*faName* __next__ *s* *sym* ?__-->__ *next*?](#31)
+[*faName* __!next__ *s* *sym* ?__-->__ *next*?](#32)
+[*faName* __nextset__ *stateset* *sym*](#33)
+[*faName* __is__ __deterministic__](#34)
+[*faName* __is__ __complete__](#35)
+[*faName* __is__ __useful__](#36)
+[*faName* __is__ __epsilon-free__](#37)
+[*faName* __reachable_states__](#38)
+[*faName* __unreachable_states__](#39)
+[*faName* __reachable__ *s*](#40)
+[*faName* __useful_states__](#41)
+[*faName* __unuseful_states__](#42)
+[*faName* __useful__ *s*](#43)
+[*faName* __epsilon_closure__ *s*](#44)
+[*faName* __reverse__](#45)
+[*faName* __complete__](#46)
+[*faName* __remove_eps__](#47)
+[*faName* __trim__ ?*what*?](#48)
+[*faName* __determinize__ ?*mapvar*?](#49)
+[*faName* __minimize__ ?*mapvar*?](#50)
+[*faName* __complement__](#51)
+[*faName* __kleene__](#52)
+[*faName* __optional__](#53)
+[*faName* __union__ *fa* ?*mapvar*?](#54)
+[*faName* __intersect__ *fa* ?*mapvar*?](#55)
+[*faName* __difference__ *fa* ?*mapvar*?](#56)
+[*faName* __concatenate__ *fa* ?*mapvar*?](#57)
+[*faName* __fromRegex__ *regex* ?*over*?](#58)
+
+# DESCRIPTION
+
+This package provides a container class for *finite automatons* (Short: FA). It
+allows the incremental definition of the automaton, its manipulation and
+querying of the definition. While the package provides complex operations on the
+automaton (via package __[grammar::fa::op](faop.md)__), it does not have the
+ability to execute a definition for a stream of symbols. Use the packages
+__[grammar::fa::dacceptor](dacceptor.md)__ and
+__[grammar::fa::dexec](dexec.md)__ for that. Another package related to this is
+__grammar::fa::compiler__. It turns a FA into an executor class which has the
+definition of the FA hardwired into it. The output of this package is
+configurable to suit a large number of different implementation languages and
+paradigms.
+
+For more information about what a finite automaton is see section [FINITE
+AUTOMATONS](#section5).
+
+# API
+
+The package exports the API described here.
+
+ - __::grammar::fa__ *faName* ?__=__|__:=__|__<--__|__as__|__deserialize__ *src*|__fromRegex__ *re* ?*over*??
+
+ Creates a new finite automaton with an associated global Tcl command whose
+ name is *faName*. This command may be used to invoke various operations on
+ the automaton. It has the following general form:
+
+ * __faName__ *option* ?*arg arg ...*?
+
+ *Option* and the *arg*s determine the exact behavior of the command. See
+ section [FA METHODS](#section3) for more explanations. The new automaton
+ will be empty if no *src* is specified. Otherwise it will contain a copy
+ of the definition contained in the *src*. The *src* has to be a FA
+ object reference for all operators except __deserialize__ and
+ __fromRegex__. The __deserialize__ operator requires *src* to be the
+ serialization of a FA instead, and __fromRegex__ takes a regular
+ expression in the form a of a syntax tree. See
+ __::grammar::fa::op::fromRegex__ for more detail on that.
+
+# FA METHODS
+
+All automatons provide the following methods for their manipulation:
+
+ - *faName* __destroy__
+
+ Destroys the automaton, including its storage space and associated command.
+
+ - *faName* __clear__
+
+ Clears out the definition of the automaton contained in *faName*, but does
+ *not* destroy the object.
+
+ - *faName* __=__ *srcFA*
+
+ Assigns the contents of the automaton contained in *srcFA* to *faName*,
+ overwriting any existing definition. This is the assignment operator for
+ automatons. It copies the automaton contained in the FA object *srcFA* over
+ the automaton definition in *faName*. The old contents of *faName* are
+ deleted by this operation.
+
+ This operation is in effect equivalent to
+
+ *faName* __deserialize__ [*srcFA* __serialize__]
+
+ - *faName* __-->__ *dstFA*
+
+ This is the reverse assignment operator for automatons. It copies the
+ automation contained in the object *faName* over the automaton definition in
+ the object *dstFA*. The old contents of *dstFA* are deleted by this
+ operation.
+
+ This operation is in effect equivalent to
+
+ *dstFA* __deserialize__ [*faName* __serialize__]
+
+ - *faName* __serialize__
+
+ This method serializes the automaton stored in *faName*. In other words it
+ returns a tcl *value* completely describing that automaton. This allows, for
+ example, the transfer of automatons over arbitrary channels, persistence,
+ etc. This method is also the basis for both the copy constructor and the
+ assignment operator.
+
+ The result of this method has to be semantically identical over all
+ implementations of the __grammar::fa__ interface. This is what will enable
+ us to copy automatons between different implementations of the same
+ interface.
+
+ The result is a list of three elements with the following structure:
+
+ The constant string __grammar::fa__.
+
+ A list containing the names of all known input symbols. The order of
+ elements in this list is not relevant.
+
+ The last item in the list is a dictionary, however the order of the keys is
+ important as well. The keys are the states of the serialized FA, and their
+ order is the order in which to create the states when deserializing. This is
+ relevant to preserve the order relationship between states.
+
+ The value of each dictionary entry is a list of three elements describing
+ the state in more detail.
+
+ A boolean flag. If its value is __true__ then the state is a start state,
+ otherwise it is not.
+
+ A boolean flag. If its value is __true__ then the state is a final state,
+ otherwise it is not.
+
+ The last element is a dictionary describing the transitions for the state.
+ The keys are symbols (or the empty string), and the values are sets of
+ successor states.
+
+ Assuming the following FA (which describes the life of a truck driver in a
+ very simple way :)
+
+ Drive -- yellow --> Brake -- red --> (Stop) -- red/yellow --> Attention -- green --> Drive
+ (...) is the start state.
+
+ a possible serialization is
+
+ grammar::fa \\
+ {yellow red green red/yellow} \\
+ {Drive {0 0 {yellow Brake}} \\
+ Brake {0 0 {red Stop}} \\
+ Stop {1 0 {red/yellow Attention}} \\
+ Attention {0 0 {green Drive}}}
+
+ A possible one, because I did not care about creation order here
+
+ - *faName* __deserialize__ *serialization*
+
+ This is the complement to __serialize__. It replaces the automaton
+ definition in *faName* with the automaton described by the *serialization*
+ value. The old contents of *faName* are deleted by this operation.
+
+ - *faName* __states__
+
+ Returns the set of all states known to *faName*.
+
+ - *faName* __state__ __add__ *s1* ?*s2* ...?
+
+ Adds the states *s1*, *s2*, et cetera to the FA definition in *faName*. The
+ operation will fail any of the new states is already declared.
+
+ - *faName* __state__ __delete__ *s1* ?*s2* ...?
+
+ Deletes the state *s1*, *s2*, et cetera, and all associated information from
+ the FA definition in *faName*. The latter means that the information about
+ in- or outbound transitions is deleted as well. If the deleted state was a
+ start or final state then this information is invalidated as well. The
+ operation will fail if the state *s* is not known to the FA.
+
+ - *faName* __state__ __exists__ *s*
+
+ A predicate. It tests whether the state *s* is known to the FA in *faName*.
+ The result is a boolean value. It will be set to __true__ if the state *s*
+ is known, and __false__ otherwise.
+
+ - *faName* __state__ __rename__ *s* *snew*
+
+ Renames the state *s* to *snew*. Fails if *s* is not a known state. Also
+ fails if *snew* is already known as a state.
+
+ - *faName* __startstates__
+
+ Returns the set of states which are marked as *start* states, also known as
+ *initial* states. See [FINITE AUTOMATONS](#section5) for explanations what
+ this means.
+
+ - *faName* __start__ __add__ *s1* ?*s2* ...?
+
+ Mark the states *s1*, *s2*, et cetera in the FA *faName* as *start* (aka
+ *initial*).
+
+ - *faName* __start__ __remove__ *s1* ?*s2* ...?
+
+ Mark the states *s1*, *s2*, et cetera in the FA *faName* as *not start* (aka
+ *not accepting*).
+
+ - *faName* __start?__ *s*
+
+ A predicate. It tests if the state *s* in the FA *faName* is *start* or not.
+ The result is a boolean value. It will be set to __true__ if the state *s*
+ is *start*, and __false__ otherwise.
+
+ - *faName* __start?set__ *stateset*
+
+ A predicate. It tests if the set of states *stateset* contains at least one
+ start state. They operation will fail if the set contains an element which
+ is not a known state. The result is a boolean value. It will be set to
+ __true__ if a start state is present in *stateset*, and __false__ otherwise.
+
+ - *faName* __finalstates__
+
+ Returns the set of states which are marked as
+ *[final](../../../../index.md#final)* states, also known as *accepting*
+ states. See [FINITE AUTOMATONS](#section5) for explanations what this means.
+
+ - *faName* __final__ __add__ *s1* ?*s2* ...?
+
+ Mark the states *s1*, *s2*, et cetera in the FA *faName* as
+ *[final](../../../../index.md#final)* (aka *accepting*).
+
+ - *faName* __final__ __remove__ *s1* ?*s2* ...?
+
+ Mark the states *s1*, *s2*, et cetera in the FA *faName* as *not final* (aka
+ *not accepting*).
+
+ - *faName* __final?__ *s*
+
+ A predicate. It tests if the state *s* in the FA *faName* is
+ *[final](../../../../index.md#final)* or not. The result is a boolean value.
+ It will be set to __true__ if the state *s* is
+ *[final](../../../../index.md#final)*, and __false__ otherwise.
+
+ - *faName* __final?set__ *stateset*
+
+ A predicate. It tests if the set of states *stateset* contains at least one
+ final state. They operation will fail if the set contains an element which
+ is not a known state. The result is a boolean value. It will be set to
+ __true__ if a final state is present in *stateset*, and __false__ otherwise.
+
+ - *faName* __symbols__
+
+ Returns the set of all symbols known to the FA *faName*.
+
+ - *faName* __symbols@__ *s* ?*d*?
+
+ Returns the set of all symbols for which the state *s* has transitions. If
+ the empty symbol is present then *s* has epsilon transitions. If two states
+ are specified the result is the set of symbols which have transitions from
+ *s* to *t*. This set may be empty if there are no transitions between the
+ two specified states.
+
+ - *faName* __symbols@set__ *stateset*
+
+ Returns the set of all symbols for which at least one state in the set of
+ states *stateset* has transitions. In other words, the union of [*faName*
+ __symbols@__ __s__] for all states __s__ in *stateset*. If the empty symbol
+ is present then at least one state contained in *stateset* has epsilon
+ transitions.
+
+ - *faName* __symbol__ __add__ *sym1* ?*sym2* ...?
+
+ Adds the symbols *sym1*, *sym2*, et cetera to the FA definition in *faName*.
+ The operation will fail any of the symbols is already declared. The empty
+ string is not allowed as a value for the symbols.
+
+ - *faName* __symbol__ __delete__ *sym1* ?*sym2* ...?
+
+ Deletes the symbols *sym1*, *sym2* et cetera, and all associated information
+ from the FA definition in *faName*. The latter means that all transitions
+ using the symbols are deleted as well. The operation will fail if any of the
+ symbols is not known to the FA.
+
+ - *faName* __symbol__ __rename__ *sym* *newsym*
+
+ Renames the symbol *sym* to *newsym*. Fails if *sym* is not a known symbol.
+ Also fails if *newsym* is already known as a symbol.
+
+ - *faName* __symbol__ __exists__ *sym*
+
+ A predicate. It tests whether the symbol *sym* is known to the FA in
+ *faName*. The result is a boolean value. It will be set to __true__ if the
+ symbol *sym* is known, and __false__ otherwise.
+
+ - *faName* __next__ *s* *sym* ?__-->__ *next*?
+
+ Define or query transition information.
+
+ If *next* is specified, then the method will add a transition from the state
+ *s* to the *successor* state *next* labeled with the symbol *sym* to the FA
+ contained in *faName*. The operation will fail if *s*, or *next* are not
+ known states, or if *sym* is not a known symbol. An exception to the latter
+ is that *sym* is allowed to be the empty string. In that case the new
+ transition is an *epsilon transition* which will not consume input when
+ traversed. The operation will also fail if the combination of (*s*, *sym*,
+ and *next*) is already present in the FA.
+
+ If *next* was not specified, then the method will return the set of states
+ which can be reached from *s* through a single transition labeled with
+ symbol *sym*.
+
+ - *faName* __!next__ *s* *sym* ?__-->__ *next*?
+
+ Remove one or more transitions from the Fa in *faName*.
+
+ If *next* was specified then the single transition from the state *s* to the
+ state *next* labeled with the symbol *sym* is removed from the FA. Otherwise
+ *all* transitions originating in state *s* and labeled with the symbol *sym*
+ will be removed.
+
+ The operation will fail if *s* and/or *next* are not known as states. It
+ will also fail if a non-empty *sym* is not known as symbol. The empty string
+ is acceptable, and allows the removal of epsilon transitions.
+
+ - *faName* __nextset__ *stateset* *sym*
+
+ Returns the set of states which can be reached by a single transition
+ originating in a state in the set *stateset* and labeled with the symbol
+ *sym*.
+
+ In other words, this is the union of [*faName* next __s__ *symbol*] for all
+ states __s__ in *stateset*.
+
+ - *faName* __is__ __deterministic__
+
+ A predicate. It tests whether the FA in *faName* is a deterministic FA or
+ not. The result is a boolean value. It will be set to __true__ if the FA is
+ deterministic, and __false__ otherwise.
+
+ - *faName* __is__ __complete__
+
+ A predicate. It tests whether the FA in *faName* is a complete FA or not. A
+ FA is complete if it has at least one transition per state and symbol. This
+ also means that a FA without symbols, or states is also complete. The result
+ is a boolean value. It will be set to __true__ if the FA is deterministic,
+ and __false__ otherwise.
+
+ Note: When a FA has epsilon-transitions transitions over a symbol for a
+ state S can be indirect, i.e. not attached directly to S, but to a state in
+ the epsilon-closure of S. The symbols for such indirect transitions count
+ when computing completeness.
+
+ - *faName* __is__ __useful__
+
+ A predicate. It tests whether the FA in *faName* is an useful FA or not. A
+ FA is useful if all states are *reachable* and *useful*. The result is a
+ boolean value. It will be set to __true__ if the FA is deterministic, and
+ __false__ otherwise.
+
+ - *faName* __is__ __epsilon-free__
+
+ A predicate. It tests whether the FA in *faName* is an epsilon-free FA or
+ not. A FA is epsilon-free if it has no epsilon transitions. This definition
+ means that all deterministic FAs are epsilon-free as well, and
+ epsilon-freeness is a necessary pre-condition for deterministic'ness. The
+ result is a boolean value. It will be set to __true__ if the FA is
+ deterministic, and __false__ otherwise.
+
+ - *faName* __reachable_states__
+
+ Returns the set of states which are reachable from a start state by one or
+ more transitions.
+
+ - *faName* __unreachable_states__
+
+ Returns the set of states which are not reachable from any start state by
+ any number of transitions. This is
+
+ [faName states] - [faName reachable_states]
+
+ - *faName* __reachable__ *s*
+
+ A predicate. It tests whether the state *s* in the FA *faName* can be
+ reached from a start state by one or more transitions. The result is a
+ boolean value. It will be set to __true__ if the state can be reached, and
+ __false__ otherwise.
+
+ - *faName* __useful_states__
+
+ Returns the set of states which are able to reach a final state by one or
+ more transitions.
+
+ - *faName* __unuseful_states__
+
+ Returns the set of states which are not able to reach a final state by any
+ number of transitions. This is
+
+ [faName states] - [faName useful_states]
+
+ - *faName* __useful__ *s*
+
+ A predicate. It tests whether the state *s* in the FA *faName* is able to
+ reach a final state by one or more transitions. The result is a boolean
+ value. It will be set to __true__ if the state is useful, and __false__
+ otherwise.
+
+ - *faName* __epsilon_closure__ *s*
+
+ Returns the set of states which are reachable from the state *s* in the FA
+ *faName* by one or more epsilon transitions, i.e transitions over the empty
+ symbol, transitions which do not consume input. This is called the *epsilon
+ closure* of *s*.
+
+ - *faName* __reverse__
+
+ - *faName* __complete__
+
+ - *faName* __remove_eps__
+
+ - *faName* __trim__ ?*what*?
+
+ - *faName* __determinize__ ?*mapvar*?
+
+ - *faName* __minimize__ ?*mapvar*?
+
+ - *faName* __complement__
+
+ - *faName* __kleene__
+
+ - *faName* __optional__
+
+ - *faName* __union__ *fa* ?*mapvar*?
+
+ - *faName* __intersect__ *fa* ?*mapvar*?
+
+ - *faName* __difference__ *fa* ?*mapvar*?
+
+ - *faName* __concatenate__ *fa* ?*mapvar*?
+
+ - *faName* __fromRegex__ *regex* ?*over*?
+
+ These methods provide more complex operations on the FA. Please see the
+ same-named commands in the package __[grammar::fa::op](faop.md)__ for
+ descriptions of what they do.
+
+# EXAMPLES
+
+# FINITE AUTOMATONS
+
+For the mathematically inclined, a FA is a 5-tuple (S,Sy,St,Fi,T) where
+
+ - S is a set of *states*,
+
+ - Sy a set of *input symbols*,
+
+ - St is a subset of S, the set of *start* states, also known as *initial*
+ states.
+
+ - Fi is a subset of S, the set of *[final](../../../../index.md#final)*
+ states, also known as *accepting*.
+
+ - T is a function from S x (Sy + epsilon) to {S}, the *transition function*.
+ Here __epsilon__ denotes the empty input symbol and is distinct from all
+ symbols in Sy; and {S} is the set of subsets of S. In other words, T maps a
+ combination of State and Input (which can be empty) to a set of *successor
+ states*.
+
+In computer theory a FA is most often shown as a graph where the nodes represent
+the states, and the edges between the nodes encode the transition function: For
+all n in S' = T (s, sy) we have one edge between the nodes representing s and n
+resp., labeled with sy. The start and accepting states are encoded through
+distinct visual markers, i.e. they are attributes of the nodes.
+
+FA's are used to process streams of symbols over Sy.
+
+A specific FA is said to *accept* a finite stream sy_1 sy_2 ... sy_n if there is
+a path in the graph of the FA beginning at a state in St and ending at a state
+in Fi whose edges have the labels sy_1, sy_2, etc. to sy_n. The set of all
+strings accepted by the FA is the *language* of the FA. One important
+equivalence is that the set of languages which can be accepted by an FA is the
+set of *[regular languages](../../../../index.md#regular_languages)*.
+
+Another important concept is that of deterministic FAs. A FA is said to be
+*deterministic* if for each string of input symbols there is exactly one path in
+the graph of the FA beginning at the start state and whose edges are labeled
+with the symbols in the string. While it might seem that non-deterministic FAs
+to have more power of recognition, this is not so. For each non-deterministic FA
+we can construct a deterministic FA which accepts the same language (-->
+Thompson's subset construction).
+
+While one of the premier applications of FAs is in
+*[parsing](../../../../index.md#parsing)*, especially in the
+*[lexer](../../../../index.md#lexer)* stage (where symbols == characters), this
+is not the only possibility by far.
+
+Quite a lot of processes can be modeled as a FA, albeit with a possibly large
+set of states. For these the notion of accepting states is often less or not
+relevant at all. What is needed instead is the ability to act to state changes
+in the FA, i.e. to generate some output in response to the input. This
+transforms a FA into a *finite transducer*, which has an additional set OSy of
+*output symbols* and also an additional *output function* O which maps from "S x
+(Sy + epsilon)" to "(Osy + epsilon)", i.e a combination of state and input,
+possibly empty to an output symbol, or nothing.
+
+For the graph representation this means that edges are additional labeled with
+the output symbol to write when this edge is traversed while matching input.
+Note that for an application "writing an output symbol" can also be "executing
+some code".
+
+Transducers are not handled by this package. They will get their own package in
+the future.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_fa* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[automaton](../../../../index.md#automaton), [finite
+automaton](../../../../index.md#finite_automaton),
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [regular
+expression](../../../../index.md#regular_expression), [regular
+grammar](../../../../index.md#regular_grammar), [regular
+languages](../../../../index.md#regular_languages),
+[state](../../../../index.md#state),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2004-2009 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_fa/faop.md
Index: embedded/md/tcllib/files/modules/grammar_fa/faop.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_fa/faop.md
@@ -0,0 +1,447 @@
+
+[//000000001]: # (grammar::fa::op - Finite automaton operations and usage)
+[//000000002]: # (Generated from file 'faop.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::fa::op(n) 0.4 tcllib "Finite automaton operations and usage")
+
+# NAME
+
+grammar::fa::op - Operations on finite automatons
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [EXAMPLES](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require snit
+package require struct::list
+package require struct::set
+package require grammar::fa::op ?0.4.1?
+
+[__::grammar::fa::op::constructor__ *cmd*](#1)
+[__::grammar::fa::op::reverse__ *fa*](#2)
+[__::grammar::fa::op::complete__ *fa* ?*sink*?](#3)
+[__::grammar::fa::op::remove_eps__ *fa*](#4)
+[__::grammar::fa::op::trim__ *fa* ?*what*?](#5)
+[__::grammar::fa::op::determinize__ *fa* ?*mapvar*?](#6)
+[__::grammar::fa::op::minimize__ *fa* ?*mapvar*?](#7)
+[__::grammar::fa::op::complement__ *fa*](#8)
+[__::grammar::fa::op::kleene__ *fa*](#9)
+[__::grammar::fa::op::optional__ *fa*](#10)
+[__::grammar::fa::op::union__ *fa* *fb* ?*mapvar*?](#11)
+[__::grammar::fa::op::intersect__ *fa* *fb* ?*mapvar*?](#12)
+[__::grammar::fa::op::difference__ *fa* *fb* ?*mapvar*?](#13)
+[__::grammar::fa::op::concatenate__ *fa* *fb* ?*mapvar*?](#14)
+[__::grammar::fa::op::fromRegex__ *fa* *regex* ?*over*?](#15)
+[__::grammar::fa::op::toRegexp__ *fa*](#16)
+[__::grammar::fa::op::toRegexp2__ *fa*](#17)
+[__::grammar::fa::op::toTclRegexp__ *regexp* *symdict*](#18)
+[__::grammar::fa::op::simplifyRegexp__ *regexp*](#19)
+
+# DESCRIPTION
+
+This package provides a number of complex operations on finite automatons
+(Short: FA), as provided by the package __[grammar::fa](fa.md)__. The package
+does not provide the ability to create and/or manipulate such FAs, nor the
+ability to execute a FA for a stream of symbols. Use the packages
+__[grammar::fa](fa.md)__ and __grammar::fa::interpreter__ for that. Another
+package related to this is __grammar::fa::compiler__ which turns a FA into an
+executor class which has the definition of the FA hardwired into it.
+
+For more information about what a finite automaton is see section *FINITE
+AUTOMATONS* in package __[grammar::fa](fa.md)__.
+
+# API
+
+The package exports the API described here. All commands modify their first
+argument. I.e. whatever FA they compute is stored back into it. Some of the
+operations will construct an automaton whose states are all new, but related to
+the states in the source automaton(s). These operations take variable names as
+optional arguments where they will store mappings which describe the
+relationship(s). The operations can be loosely partitioned into structural and
+language operations. The latter are defined in terms of the language the
+automaton(s) accept, whereas the former are defined in terms of the structural
+properties of the involved automaton(s). Some operations are both. *Structure
+operations*
+
+ - __::grammar::fa::op::constructor__ *cmd*
+
+ This command has to be called by the user of the package before any other
+ operations is performed, to establish a command which can be used to
+ construct a FA container object. If this is not done several operations will
+ fail as they are unable to construct internal and transient containers to
+ hold state and/or partial results.
+
+ Any container class using this package for complex operations should set its
+ own class command as the constructor. See package __[grammar::fa](fa.md)__
+ for an example.
+
+ - __::grammar::fa::op::reverse__ *fa*
+
+ Reverses the *fa*. This is done by reversing the direction of all
+ transitions and swapping the sets of *start* and
+ *[final](../../../../index.md#final)* states. The language of *fa* changes
+ unpredictably.
+
+ - __::grammar::fa::op::complete__ *fa* ?*sink*?
+
+ Completes the *fa* *complete*, but nothing is done if the *fa* is already
+ *complete*. This implies that only the first in a series of multiple
+ consecutive complete operations on *fa* will perform anything. The remainder
+ will be null operations.
+
+ The language of *fa* is unchanged by this operation.
+
+ This is done by adding a single new state, the *sink*, and transitions from
+ all other states to that sink for all symbols they have no transitions for.
+ The sink itself is made complete by adding loop transitions for all symbols.
+
+ Note: When a FA has epsilon-transitions transitions over a symbol for a
+ state S can be indirect, i.e. not attached directly to S, but to a state in
+ the epsilon-closure of S. The symbols for such indirect transitions count
+ when computing completeness of a state. In other words, these indirectly
+ reached symbols are *not* missing.
+
+ The argument *sink* provides the name for the new state and most not be
+ present in the *fa* if specified. If the name is not specified the command
+ will name the state "sink__n__", where __n__ is set so that there are no
+ collisions with existing states.
+
+ Note that the sink state is *not useful* by definition. In other words,
+ while the FA becomes complete, it is also *not useful* in the strict sense
+ as it has a state from which no final state can be reached.
+
+ - __::grammar::fa::op::remove_eps__ *fa*
+
+ Removes all epsilon-transitions from the *fa* in such a manner the the
+ language of *fa* is unchanged. However nothing is done if the *fa* is
+ already *epsilon-free*. This implies that only the first in a series of
+ multiple consecutive complete operations on *fa* will perform anything. The
+ remainder will be null operations.
+
+ *Note:* This operation may cause states to become unreachable or not useful.
+ These states are not removed by this operation. Use
+ __::grammar::fa::op::trim__ for that instead.
+
+ - __::grammar::fa::op::trim__ *fa* ?*what*?
+
+ Removes unwanted baggage from *fa*. The legal values for *what* are listed
+ below. The command defaults to __!reachable|!useful__ if no specific
+ argument was given.
+
+ * __!reachable__
+
+ Removes all states which are not reachable from a start state.
+
+ * __!useful__
+
+ Removes all states which are unable to reach a final state.
+
+ * __!reachable&!useful__
+
+ * __!(reachable|useful)__
+
+ Removes all states which are not reachable from a start state and are
+ unable to reach a final state.
+
+ * __!reachable|!useful__
+
+ * __!(reachable&useful)__
+
+ Removes all states which are not reachable from a start state or are
+ unable to reach a final state.
+
+ - __::grammar::fa::op::determinize__ *fa* ?*mapvar*?
+
+ Makes the *fa* deterministic without changing the language accepted by the
+ *fa*. However nothing is done if the *fa* is already *deterministic*. This
+ implies that only the first in a series of multiple consecutive complete
+ operations on *fa* will perform anything. The remainder will be null
+ operations.
+
+ The command will store a dictionary describing the relationship between the
+ new states of the resulting dfa and the states of the input nfa in *mapvar*,
+ if it has been specified. Keys of the dictionary are the handles for the
+ states of the resulting dfa, values are sets of states from the input nfa.
+
+ *Note*: An empty dictionary signals that the command was able to make the
+ *fa* deterministic without performing a full subset construction, just by
+ removing states and shuffling transitions around (As part of making the FA
+ epsilon-free).
+
+ *Note*: The algorithm fails to make the FA deterministic in the technical
+ sense if the FA has no start state(s), because determinism requires the FA
+ to have exactly one start states. In that situation we make a best effort;
+ and the missing start state will be the only condition preventing the
+ generated result from being *deterministic*. It should also be noted that in
+ this case the possibilities for trimming states from the FA are also
+ severely reduced as we cannot declare states unreachable.
+
+ - __::grammar::fa::op::minimize__ *fa* ?*mapvar*?
+
+ Creates a FA which accepts the same language as *fa*, but has a minimal
+ number of states. Uses Brzozowski's method to accomplish this.
+
+ The command will store a dictionary describing the relationship between the
+ new states of the resulting minimal fa and the states of the input fa in
+ *mapvar*, if it has been specified. Keys of the dictionary are the handles
+ for the states of the resulting minimal fa, values are sets of states from
+ the input fa.
+
+ *Note*: An empty dictionary signals that the command was able to minimize
+ the *fa* without having to compute new states. This should happen if and
+ only if the input FA was already minimal.
+
+ *Note*: If the algorithm has no start or final states to work with then the
+ result might be technically minimal, but have a very unexpected structure.
+ It should also be noted that in this case the possibilities for trimming
+ states from the FA are also severely reduced as we cannot declare states
+ unreachable.
+
+*Language operations* All operations in this section require that all input FAs
+have at least one start and at least one final state. Otherwise the language of
+the FAs will not be defined, making the operation senseless (as it operates on
+the languages of the FAs in a defined manner).
+
+ - __::grammar::fa::op::complement__ *fa*
+
+ Complements *fa*. This is possible if and only if *fa* is *complete* and
+ *deterministic*. The resulting FA accepts the complementary language of
+ *fa*. In other words, all inputs not accepted by the input are accepted by
+ the result, and vice versa.
+
+ The result will have all states and transitions of the input, and different
+ final states.
+
+ - __::grammar::fa::op::kleene__ *fa*
+
+ Applies Kleene's closure to *fa*. The resulting FA accepts all strings __S__
+ for which we can find a natural number __n__ (0 inclusive) and strings
+ __A1__ ... __An__ in the language of *fa* such that __S__ is the
+ concatenation of __A1__ ... __An__. In other words, the language of the
+ result is the infinite union over finite length concatenations over the
+ language of *fa*.
+
+ The result will have all states and transitions of the input, and new start
+ and final states.
+
+ - __::grammar::fa::op::optional__ *fa*
+
+ Makes the *fa* optional. In other words it computes the FA which accepts the
+ language of *fa* and the empty the word (epsilon) as well.
+
+ The result will have all states and transitions of the input, and new start
+ and final states.
+
+ - __::grammar::fa::op::union__ *fa* *fb* ?*mapvar*?
+
+ Combines the FAs *fa* and *fb* such that the resulting FA accepts the union
+ of the languages of the two FAs.
+
+ The result will have all states and transitions of the two input FAs, and
+ new start and final states. All states of *fb* which exist in *fa* as well
+ will be renamed, and the *mapvar* will contain a mapping from the old states
+ of *fb* to the new ones, if present.
+
+ It should be noted that the result will be non-deterministic, even if the
+ inputs are deterministic.
+
+ - __::grammar::fa::op::intersect__ *fa* *fb* ?*mapvar*?
+
+ Combines the FAs *fa* and *fb* such that the resulting FA accepts the
+ intersection of the languages of the two FAs. In other words, the result
+ will accept a word if and only if the word is accepted by both *fa* and
+ *fb*. The result will be useful, but not necessarily deterministic or
+ minimal.
+
+ The command will store a dictionary describing the relationship between the
+ new states of the resulting fa and the pairs of states of the input FAs in
+ *mapvar*, if it has been specified. Keys of the dictionary are the handles
+ for the states of the resulting fa, values are pairs of states from the
+ input FAs. Pairs are represented by lists. The first element in each pair
+ will be a state in *fa*, the second element will be drawn from *fb*.
+
+ - __::grammar::fa::op::difference__ *fa* *fb* ?*mapvar*?
+
+ Combines the FAs *fa* and *fb* such that the resulting FA accepts the
+ difference of the languages of the two FAs. In other words, the result will
+ accept a word if and only if the word is accepted by *fa*, but not by *fb*.
+ This can also be expressed as the intersection of *fa* with the complement
+ of *fb*. The result will be useful, but not necessarily deterministic or
+ minimal.
+
+ The command will store a dictionary describing the relationship between the
+ new states of the resulting fa and the pairs of states of the input FAs in
+ *mapvar*, if it has been specified. Keys of the dictionary are the handles
+ for the states of the resulting fa, values are pairs of states from the
+ input FAs. Pairs are represented by lists. The first element in each pair
+ will be a state in *fa*, the second element will be drawn from *fb*.
+
+ - __::grammar::fa::op::concatenate__ *fa* *fb* ?*mapvar*?
+
+ Combines the FAs *fa* and *fb* such that the resulting FA accepts the
+ cross-product of the languages of the two FAs. I.e. a word W will be
+ accepted by the result if there are two words A and B accepted by *fa*, and
+ *fb* resp. and W is the concatenation of A and B.
+
+ The result FA will be non-deterministic.
+
+ - __::grammar::fa::op::fromRegex__ *fa* *regex* ?*over*?
+
+ Generates a non-deterministic FA which accepts the same language as the
+ regular expression *regex*. If the *over* is specified it is treated as the
+ set of symbols the regular expression and the automaton are defined over.
+ The command will compute the set from the "S" constructors in *regex* when
+ *over* was not specified. This set is important if and only if the
+ complement operator "!" is used in *regex* as the complementary language of
+ an FA is quite different for different sets of symbols.
+
+ The regular expression is represented by a nested list, which forms a syntax
+ tree. The following structures are legal:
+
+ * {S x}
+
+ Atomic regular expression. Everything else is constructed from these.
+ Accepts the __S__ymbol "x".
+
+ * {. A1 A2 ...}
+
+ Concatenation operator. Accepts the concatenation of the regular
+ expressions __A1__, __A2__, etc.
+
+ *Note* that this operator accepts zero or more arguments. With zero
+ arguments the represented language is *epsilon*, the empty word.
+
+ * {| A1 A2 ...}
+
+ Choice operator, also called "Alternative". Accepts all input accepted
+ by at least one of the regular expressions __A1__, __A2__, etc. In other
+ words, the union of __A1__, __A2__.
+
+ *Note* that this operator accepts zero or more arguments. With zero
+ arguments the represented language is the *empty* language, the language
+ without words.
+
+ * {& A1 A2 ...}
+
+ Intersection operator, logical and. Accepts all input accepted which is
+ accepted by all of the regular expressions __A1__, __A2__, etc. In other
+ words, the intersection of __A1__, __A2__.
+
+ * {? A}
+
+ Optionality operator. Accepts the empty word and anything from the
+ regular expression __A__.
+
+ * {* A}
+
+ Kleene closure. Accepts the empty word and any finite concatenation of
+ words accepted by the regular expression __A__.
+
+ * {+ A}
+
+ Positive Kleene closure. Accepts any finite concatenation of words
+ accepted by the regular expression __A__, but not the empty word.
+
+ * {! A}
+
+ Complement operator. Accepts any word not accepted by the regular
+ expression __A__. Note that the complement depends on the set of symbol
+ the result should run over. See the discussion of the argument *over*
+ before.
+
+ - __::grammar::fa::op::toRegexp__ *fa*
+
+ This command generates and returns a regular expression which accepts the
+ same language as the finite automaton *fa*. The regular expression is in the
+ format as described above, for __::grammar::fa::op::fromRegex__.
+
+ - __::grammar::fa::op::toRegexp2__ *fa*
+
+ This command has the same functionality as __::grammar::fa::op::toRegexp__,
+ but uses a different algorithm to simplify the generated regular
+ expressions.
+
+ - __::grammar::fa::op::toTclRegexp__ *regexp* *symdict*
+
+ This command generates and returns a regular expression in Tcl syntax for
+ the regular expression *regexp*, if that is possible. *regexp* is in the
+ same format as expected by __::grammar::fa::op::fromRegex__.
+
+ The command will fail and throw an error if *regexp* contains
+ complementation and intersection operations.
+
+ The argument *symdict* is a dictionary mapping symbol names to pairs of
+ *syntactic type* and Tcl-regexp. If a symbol occurring in the *regexp* is
+ not listed in this dictionary then single-character symbols are considered
+ to designate themselves whereas multiple-character symbols are considered to
+ be a character class name.
+
+ - __::grammar::fa::op::simplifyRegexp__ *regexp*
+
+ This command simplifies a regular expression by applying the following
+ algorithm first to the main expression and then recursively to all
+ sub-expressions:
+
+ Convert the expression into a finite automaton.
+
+ Minimize the automaton.
+
+ Convert the automaton back to a regular expression.
+
+ Choose the shorter of original expression and expression from the previous
+ step.
+
+# EXAMPLES
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_fa* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[automaton](../../../../index.md#automaton), [finite
+automaton](../../../../index.md#finite_automaton),
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [regular
+expression](../../../../index.md#regular_expression), [regular
+grammar](../../../../index.md#regular_grammar), [regular
+languages](../../../../index.md#regular_languages),
+[state](../../../../index.md#state),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2004-2008 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/gasm.md
Index: embedded/md/tcllib/files/modules/grammar_me/gasm.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/gasm.md
@@ -0,0 +1,425 @@
+
+[//000000001]: # (grammar::me::cpu::gasm - Grammar operations and usage)
+[//000000002]: # (Generated from file 'gasm.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me::cpu::gasm(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me::cpu::gasm - ME assembler
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [DEFINITIONS](#section2)
+
+ - [API](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require grammar::me::cpu::gasm ?0.1?
+
+[__::grammar::me::cpu::gasm::begin__ *g* *n* ?*mode*? ?*note*?](#1)
+[__::grammar::me::cpu::gasm::done__ __-->__ *t*](#2)
+[__::grammar::me::cpu::gasm::state__](#3)
+[__::grammar::me::cpu::gasm::state!__ *s*](#4)
+[__::grammar::me::cpu::gasm::lift__ *t* *dst* __=__ *src*](#5)
+[__::grammar::me::cpu::gasm::Inline__ *t* *node* *label*](#6)
+[__::grammar::me::cpu::gasm::Cmd__ *cmd* ?*arg*...?](#7)
+[__::grammar::me::cpu::gasm::Bra__](#8)
+[__::grammar::me::cpu::gasm::Nop__ *text*](#9)
+[__::grammar::me::cpu::gasm::Note__ *text*](#10)
+[__::grammar::me::cpu::gasm::Jmp__ *label*](#11)
+[__::grammar::me::cpu::gasm::Exit__](#12)
+[__::grammar::me::cpu::gasm::Who__ *label*](#13)
+[__::grammar::me::cpu::gasm::/Label__ *name*](#14)
+[__::grammar::me::cpu::gasm::/Clear__](#15)
+[__::grammar::me::cpu::gasm::/Ok__](#16)
+[__::grammar::me::cpu::gasm::/Fail__](#17)
+[__::grammar::me::cpu::gasm::/At__ *name*](#18)
+[__::grammar::me::cpu::gasm::/CloseLoop__](#19)
+
+# DESCRIPTION
+
+This package provides a simple in-memory assembler. Its origin is that of a
+support package for use by packages converting PEG and other grammars into a
+corresponding matcher based on the ME virtual machine, like
+__page::compiler::peg::mecpu__. Despite that it is actually mostly agnostic
+regarding the instructions, users can choose any instruction set they like.
+
+The program under construction is held in a graph structure (See package
+__[struct::graph](../struct/graph.md)__) during assembly and subsequent
+manipulation, with instructions represented by nodes, and the flow of execution
+between instructions explicitly encoded in the arcs between them.
+
+In this model jumps are not encoded explicitly, they are implicit in the arcs.
+The generation of explicit jumps is left to any code converting the graph
+structure into a more conventional representation. The same goes for branches.
+They are implicitly encoded by all instructions which have two outgoing arcs,
+whereas all other instructions have only one outgoing arc. Their conditonality
+is handled by tagging their outgoing arcs with information about the conditions
+under which they are taken.
+
+While the graph the assembler operates on is supplied from the outside, i.e.
+external, it does manage some internal state, namely:
+
+ 1. The handle of the graph node most assembler operations will work on, the
+ *anchor*.
+
+ 1. A mapping from arbitrary strings to instructions. I.e. it is possible to
+ *label* an instruction during assembly, and later recall that instruction
+ by its label.
+
+ 1. The condition code to use when creating arcs between instructions, which is
+ one of __always__, __ok__, and __fail__.
+
+ 1. The current operation mode, one of __halt__, __okfail__, and __!okfail__.
+
+ 1. The name of a node in a tree. This, and the operation mode above are the
+ parts most heavily influenced by the needs of a grammar compiler, as they
+ assume some basic program structures (selected through the operation mode),
+ and intertwine the graph with a tree, like the AST for the grammar to be
+ compiled.
+
+# DEFINITIONS
+
+As the graph the assembler is operating on, and the tree it is intertwined with,
+are supplied to the assembler from the outside it is necessary to specify the
+API expected from them, and to describe the structures expected and/or generated
+by the assembler in either.
+
+ 1. Any graph object command used by the assembler has to provide the API as
+ specified in the documentation for the package
+ __[struct::graph](../struct/graph.md)__.
+
+ 1. Any tree object command used by the assembler has to provide the API as
+ specified in the documentation for the package
+ __[struct::tree](../struct/struct_tree.md)__.
+
+ 1. Any instruction (node) generated by the assembler in a graph will have at
+ least two, and at most three attributes:
+
+ - __instruction__
+
+ The value of this attribute is the name of the instruction. The only
+ names currently defined by the assembler are the three
+ pseudo-instructions
+
+ * __NOP__
+
+ This instruction does nothing. Useful for fixed framework nodes,
+ unchanging jump destinations, and the like. No arguments.
+
+ * __C__
+
+ A .NOP to allow the insertion of arbitrary comments into the
+ instruction stream, i.e. a comment node. One argument, the text of
+ the comment.
+
+ * __BRA__
+
+ A .NOP serving as explicitly coded conditional branch. No
+ arguments.
+
+ However we reserve the space of all instructions whose names begin with
+ a "." (dot) for future use by the assembler.
+
+ - __arguments__
+
+ The value of this attribute is a list of strings, the arguments of the
+ instruction. The contents are dependent on the actual instruction and
+ the assembler doesn't know or care about them. This means for example
+ that it has no builtin knowledge about what instruction need which
+ arguments and thus doesn't perform any type of checking.
+
+ - __expr__
+
+ This attribute is optional. When it is present its value is the name of
+ a node in the tree intertwined with the graph.
+
+ 1. Any arc between two instructions will have one attribute:
+
+ - __condition__
+
+ The value of this attribute determines under which condition execution
+ will take this arc. It is one of __always__, __ok__, and __fail__. The
+ first condition is used for all arcs which are the single outgoing arc
+ of an instruction. The other two are used for the two outgoing arcs of
+ an instruction which implicitly encode a branch.
+
+ 1. A tree node given to the assembler for cross-referencing will be written to
+ and given the following attributes, some fixed, some dependent on the
+ operation mode. All values will be references to nodes in the instruction
+ graph. Some of the instruction will expect some or specific sets of these
+ attributes.
+
+ - __gas::entry__
+
+ Always written.
+
+ - __gas::exit__
+
+ Written for all modes but __okfail__.
+
+ - __gas::exit::ok__
+
+ Written for mode __okfail__.
+
+ - __gas::exit::fail__
+
+ Written for mode __okfail__.
+
+# API
+
+ - __::grammar::me::cpu::gasm::begin__ *g* *n* ?*mode*? ?*note*?
+
+ This command starts the assembly of an instruction sequence, and
+ (re)initializes the state of the assembler. After completion of the
+ instruction sequence use __::grammar::me::cpu::gasm::done__ to finalize the
+ assembler.
+
+ It will operate on the graph *g* in the specified *mode* (Default is
+ __okfail__). As part of the initialization it will always create a standard
+ .NOP instruction and label it "entry". The creation of the remaining
+ standard instructions is *mode*-dependent:
+
+ * __halt__
+
+ An "icf_halt" instruction labeled "exit/return".
+
+ * __!okfail__
+
+ An "icf_ntreturn" instruction labeled "exit/return".
+
+ * __okfail__
+
+ Two .NOP instructions labeled "exit/ok" and "exit/fail" respectively.
+
+ The *note*, if specified (default is not), is given to the "entry" .NOP
+ instruction.
+
+ The node reference *n* is simply stored for use by
+ __::grammar::me::cpu::gasm::done__. It has to refer to a node in the tree
+ *t* argument of that command.
+
+ After the initialization is done the "entry" instruction will be the
+ *anchor*, and the condition code will be set to __always__.
+
+ The command returns the empy string as its result.
+
+ - __::grammar::me::cpu::gasm::done__ __-->__ *t*
+
+ This command finalizes the creation of an instruction sequence and then
+ clears the state of the assembler. *NOTE* that this *does not* delete any of
+ the created instructions. They can be made available to future begin/done
+ cycles. Further assembly will be possible only after reinitialization of the
+ system via __::grammar::me::cpu::gasm::begin__.
+
+ Before the state is cleared selected references to selected instructions
+ will be written to attributes of the node *n* in the tree *t*. Which
+ instructions are saved is *mode*-dependent. Both *mode* and the destination
+ node *n* were specified during invokation of
+ __::grammar::me::cpu::gasm::begin__.
+
+ Independent of the mode a reference to the instruction labeled "entry" will
+ be saved to the attribute __gas::entry__ of *n*. The reference to the node
+ *n* will further be saved into the attribute "expr" of the "entry"
+ instruction. Beyond that
+
+ * __halt__
+
+ A reference to the instruction labeled "exit/return" will be saved to
+ the attribute __gas::exit__ of *n*.
+
+ * __okfail__
+
+ See __halt__.
+
+ * __!okfail__
+
+ Reference to the two instructions labeled "exit/ok" and "exit/fail" will
+ be saved to the attributes __gas::exit::ok__ and __gas::exit::fail__ of
+ *n* respectively.
+
+ The command returns the empy string as its result.
+
+ - __::grammar::me::cpu::gasm::state__
+
+ This command returns the current state of the assembler. Its format is not
+ documented and considered to be internal to the package.
+
+ - __::grammar::me::cpu::gasm::state!__ *s*
+
+ This command takes a serialized assembler state *s* as returned by
+ __::grammar::me::cpu::gasm::state__ and makes it the current state of the
+ assembler.
+
+ *Note* that this may overwrite label definitions, however all
+ non-conflicting label definitions in the state before are not touched and
+ merged with *s*.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::lift__ *t* *dst* __=__ *src*
+
+ This command operates on the tree *t*. It copies the contents of the
+ attributes __gas::entry__, __gas::exit::ok__ and __gas::exit::fail__ from
+ the node *src* to the node *dst*. It returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::Inline__ *t* *node* *label*
+
+ This command links an instruction sequence created by an earlier begin/done
+ pair into the current instruction sequence.
+
+ To this end it
+
+ reads the instruction references from the attributes __gas::entry__,
+ __gas::exit::ok__, and __gas::exit::fail__ from the node *n* of the tree *t*
+ and makes them available to assembler und the labels *label*/entry,
+ *label*/exit::ok, and *label*/exit::fail respectively.
+
+ Creates an arc from the *anchor* to the node labeled *label*/entry, and tags
+ it with the current condition code.
+
+ Makes the node labeled *label*/exit/ok the new *anchor*.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::Cmd__ *cmd* ?*arg*...?
+
+ This is the basic command to add instructions to the graph. It creates a new
+ instruction of type *cmd* with the given arguments *arg*... If the *anchor*
+ was defined it will also create an arc from the *anchor* to the new
+ instruction using the current condition code. After the call the new
+ instruction will be the *anchor* and the current condition code will be set
+ to __always__.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::Bra__
+
+ This is a convenience command to create a .BRA pseudo-instruction. It uses
+ __::grammar::me::cpu::gasm::Cmd__ to actually create the instruction and
+ inherits its behaviour.
+
+ - __::grammar::me::cpu::gasm::Nop__ *text*
+
+ This is a convenience command to create a .NOP pseudo-instruction. It uses
+ __::grammar::me::cpu::gasm::Cmd__ to actually create the instruction and
+ inherits its behaviour. The *text* will be saved as the first and only
+ argument of the new instruction.
+
+ - __::grammar::me::cpu::gasm::Note__ *text*
+
+ This is a convenience command to create a .C pseudo-instruction, i.e. a
+ comment. It uses __::grammar::me::cpu::gasm::Cmd__ to actually create the
+ instruction and inherits its behaviour. The *text* will be saved as the
+ first and only argument of the new instruction.
+
+ - __::grammar::me::cpu::gasm::Jmp__ *label*
+
+ This command creates an arc from the *anchor* to the instruction labeled
+ with *label*, and tags with the the current condition code.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::Exit__
+
+ This command creates an arc from the *anchor* to one of the exit
+ instructions, based on the operation mode (see
+ __::grammar::me::cpu::gasm::begin__), and tags it with current condition
+ code.
+
+ For mode __okfail__ it links to the instruction labeled either "exit/ok" or
+ "exit/fail", depending on the current condition code, and tagging it with
+ the current condition code For the other two modes it links to the
+ instruction labeled "exit/return", tagging it condition code __always__,
+ independent the current condition code.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::Who__ *label*
+
+ This command returns a reference to the instruction labeled with *label*.
+
+ - __::grammar::me::cpu::gasm::/Label__ *name*
+
+ This command labels the *anchor* with *name*. *Note* that an instruction can
+ have more than one label.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::/Clear__
+
+ This command clears the *anchor*, leaving it undefined, and further resets
+ the current condition code to __always__.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::/Ok__
+
+ This command sets the current condition code to __ok__.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::/Fail__
+
+ This command sets the current condition code to __fail__.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::/At__ *name*
+
+ This command sets the *anchor* to the instruction labeled with *name*, and
+ further resets the current condition code to __always__.
+
+ The command returns the empty string as its result.
+
+ - __::grammar::me::cpu::gasm::/CloseLoop__
+
+ This command marks the *anchor* as the last instruction in a loop body, by
+ creating the attribute __LOOP__.
+
+ The command returns the empty string as its result.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[assembler](../../../../index.md#assembler),
+[grammar](../../../../index.md#grammar), [graph](../../../../index.md#graph),
+[parsing](../../../../index.md#parsing), [tree](../../../../index.md#tree),
+[virtual machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_ast.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_ast.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_ast.md
@@ -0,0 +1,146 @@
+
+[//000000001]: # (grammar::me_ast - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_ast.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me_ast(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me_ast - Various representations of ASTs
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Description](#section1)
+
+ - [AST VALUES](#section2)
+
+ - [AST OBJECTS](#section3)
+
+ - [EXTENDED AST OBJECTS](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# DESCRIPTION
+
+This document specifies various representations for the *[abstract syntax
+tree](../../../../index.md#abstract_syntax_tree)*s (short
+*[AST](../../../../index.md#ast)*) generated by instances of ME virtual
+machines, independent of variant. Please go and read the document
+__[grammar::me_intro](me_intro.md)__ first if you do not know what a ME virtual
+machine is.
+
+ASTs and all the representations we specify distinguish between two types of
+nodes, namely:
+
+ - Terminal
+
+ Terminal nodes refer to the terminal symbols found in the token stream. They
+ are always leaf nodes. I.e. terminal nodes never have children.
+
+ - Nonterminal
+
+ Nonterminal nodes represent a nonterminal symbol of the grammar used during
+ parsing. They can occur as leaf and inner nodes of the tree.
+
+Both types of nodes carry basic range information telling a user which parts of
+the input are covered by the node by providing the location of the first and
+last tokens found within the range. Locations are provided as non-negative
+integer offsets from the beginning of the token stream, with the first token
+found in the stream located at offset 0 (zero).
+
+The root of an AS tree can be either a terminal or nonterminal node.
+
+# AST VALUES
+
+This representation of ASTs is a Tcl list. The main list represents the root
+node of the tree, with the representations of the children nested within.
+
+Each node is represented by a single Tcl list containing three or more elements.
+The first element is either the empty string or the name of a nonterminal symbol
+(which is never the empty string). The second and third elements are then the
+locations of the first and last tokens. Any additional elements after the third
+are then the representations of the children, with the leftmost child first,
+i.e. as the fourth element of the list representing the node.
+
+# AST OBJECTS
+
+In this representation an AST is represented by a Tcl object command whose API
+is compatible to the tree objects provided by the package
+__[struct::tree](../struct/struct_tree.md)__. I.e it has to support at least all
+of the methods described by that package, and may support more.
+
+Because of this the remainder of the specifications is written using the terms
+of __[struct::tree](../struct/struct_tree.md)__.
+
+Each node of the AST directly maps to a node in the tree object. All data beyond
+the child nodes, i.e. node type and input locations, are stored in attributes of
+the node in the tree object. They are:
+
+ - type
+
+ The type of the AST node. The recognized values are __terminal__ and
+ __nonterminal__.
+
+ - range
+
+ The locations of the first and last token of the terminal data in the input
+ covered by the node. This is a list containing two locations.
+
+ - detail
+
+ This attribute is present only for nonterminal nodes. It contains the name
+ of the nonterminal symbol stored in the node.
+
+# EXTENDED AST OBJECTS
+
+Extended AST objects are like AST objects, with additional information.
+
+ - detail
+
+ This attribute is now present at all nodes. Its contents are unchanged for
+ nonterminal nodes. For terminal nodes it contains a list describing all
+ tokens from the input which are covered by the node.
+
+ Each element of the list contains the token name, the associated lexeme
+ attribute, line number, and column index, in this order.
+
+ - range_lc
+
+ This new attribute is defined for all nodes, and contains the locations from
+ attribute *range* translated into line number and column index. Lines are
+ counted from 1, columns are counted from 0.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[AST](../../../../index.md#ast), [abstract syntax
+tree](../../../../index.md#abstract_syntax_tree)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_cpu.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_cpu.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_cpu.md
@@ -0,0 +1,313 @@
+
+[//000000001]: # (grammar::me::cpu - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_cpu.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me::cpu(n) 0.2 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me::cpu - Virtual machine implementation II for parsing token streams
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [CLASS API](#subsection1)
+
+ - [OBJECT API](#subsection2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require grammar::me::cpu ?0.2?
+
+[__::grammar::me::cpu__ *meName* *matchcode*](#1)
+[__meName__ __option__ ?*arg arg ...*?](#2)
+[*meName* __lc__ *location*](#3)
+[*meName* __tok__ ?*from* ?*to*??](#4)
+[*meName* __pc__ *state*](#5)
+[*meName* __iseof__ *state*](#6)
+[*meName* __at__ *state*](#7)
+[*meName* __cc__ *state*](#8)
+[*meName* __sv__](#9)
+[*meName* __ok__](#10)
+[*meName* __error__](#11)
+[*meName* __lstk__ *state*](#12)
+[*meName* __astk__ *state*](#13)
+[*meName* __mstk__ *state*](#14)
+[*meName* __estk__ *state*](#15)
+[*meName* __rstk__ *state*](#16)
+[*meName* __nc__ *state*](#17)
+[*meName* __ast__](#18)
+[*meName* __halted__](#19)
+[*meName* __code__](#20)
+[*meName* __eof__](#21)
+[*meName* __put__ *tok* *lex* *line* *col*](#22)
+[*meName* __putstring__ *string* *lvar* *cvar*](#23)
+[*meName* __run__ ?*n*?](#24)
+[*meName* __pull__ *nextcmd*](#25)
+[*meName* __reset__](#26)
+[*meName* __destroy__](#27)
+
+# DESCRIPTION
+
+This package provides an implementation of the ME virtual machine. Please go and
+read the document __[grammar::me_intro](me_intro.md)__ first if you do not know
+what a ME virtual machine is.
+
+This implementation provides an object-based API and the machines are not truly
+tied to Tcl. A C implementation of the same API is quite possible.
+
+Internally the package actually uses the value-based machine manipulation
+commands as provided by the package __[grammar::me::cpu::core](me_cpucore.md)__
+to perform its duties.
+
+# API
+
+## CLASS API
+
+The package directly provides only a single command for the construction of ME
+virtual machines.
+
+ - __::grammar::me::cpu__ *meName* *matchcode*
+
+ The command creates a new ME machine object with an associated global Tcl
+ command whose name is *meName*. This command may be used to invoke various
+ operations on the machine. It has the following general form:
+
+ * __meName__ __option__ ?*arg arg ...*?
+
+ *Option* and the *arg*s determine the exact behavior of the command.
+
+ The argument *matchcode* contains the match instructions the machine has to
+ execute while parsing the input stream. Please read section __MATCH CODE
+ REPRESENTATION__ of the documentation for the package
+ __[grammar::me::cpu::core](me_cpucore.md)__ for the specification of the
+ structure of this value.
+
+ The *tokmap* argument taken by the implementation provided by the package
+ __[grammar::me::tcl](me_tcl.md)__ is here hidden inside of the match
+ instructions and therefore not needed.
+
+## OBJECT API
+
+All ME virtual machine objects created by the class command specified in section
+[CLASS API](#subsection1) support the methods listed below.
+
+The machines provided by this package provide methods for operation in both
+push- and pull-styles. Push-style means that tokens are pushed into the machine
+state when they arrive, triggering further execution until they are consumed. In
+other words, this allows the machine to be suspended and resumed at will and an
+arbitrary number of times, the quasi-parallel operation of several machines, and
+the operation as part of the event loop.
+
+ - *meName* __lc__ *location*
+
+ This method converts the location of a token given as offset in the input
+ stream into the associated line number and column index. The result of the
+ command is a 2-element list containing the two values, in the order
+ mentioned in the previous sentence. This allows higher levels to convert the
+ location information found in the error status and the generated AST into
+ more human readable data.
+
+ *Note* that the command is not able to convert locations which have not been
+ reached by the machine yet. In other words, if the machine has read 7 tokens
+ the command is able to convert the offsets __0__ to __6__, but nothing
+ beyond that. This also shows that it is not possible to convert offsets
+ which refer to locations before the beginning of the stream.
+
+ - *meName* __tok__ ?*from* ?*to*??
+
+ This method returns a Tcl list containing the part of the input stream
+ between the locations *from* and *to* (both inclusive). If *to* is not
+ specified it will default to the value of *from*. If *from* is not specified
+ either the whole input stream is returned.
+
+ Each element of the returned list is a list of four elements, the token, its
+ associated lexeme, line number, and column index, in this order. This
+ command places the same restrictions on its location arguments as the method
+ __lc__.
+
+ - *meName* __pc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current value of the stored program counter.
+
+ - *meName* __iseof__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current value of the stored eof flag.
+
+ - *meName* __at__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current location in the input stream.
+
+ - *meName* __cc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current token.
+
+ - *meName* __sv__
+
+ This command returns the current semantic value *SV* stored in the machine.
+ This is an abstract syntax tree as specified in the document
+ __[grammar::me_ast](me_ast.md)__, section __AST VALUES__.
+
+ - *meName* __ok__
+
+ This method returns the current match status *OK*.
+
+ - *meName* __error__
+
+ This method returns the current error status *ER*.
+
+ - *meName* __lstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ location stack.
+
+ - *meName* __astk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ AST stack.
+
+ - *meName* __mstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ AST marker stack.
+
+ - *meName* __estk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ error stack.
+
+ - *meName* __rstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ subroutine return stack.
+
+ - *meName* __nc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ nonterminal match cache as a dictionary.
+
+ - *meName* __ast__
+
+ This method returns the current top entry of the AST stack *AS*. This is an
+ abstract syntax tree as specified in the document
+ __[grammar::me_ast](me_ast.md)__, section __AST VALUES__.
+
+ - *meName* __halted__
+
+ This method returns a boolean value telling the caller whether the engine
+ has halted execution or not. Halt means that no further matching is
+ possible, and the information retrieved via the other method is final.
+ Attempts to __run__ the engine will be ignored, until a __reset__ is made.
+
+ - *meName* __code__
+
+ This method returns the *code* information used to construct the object. In
+ other words, the match program executed by the machine.
+
+ - *meName* __eof__
+
+ This method adds an end of file marker to the end of the input stream. This
+ signals the machine that the current contents of the input queue are the
+ final parts of the input and nothing will come after. Attempts to put more
+ characters into the queue will fail.
+
+ - *meName* __put__ *tok* *lex* *line* *col*
+
+ This method adds the token *tok* to the end of the input stream, with
+ associated lexeme data *lex* and *line*/*col*umn information.
+
+ - *meName* __putstring__ *string* *lvar* *cvar*
+
+ This method adds each individual character in the *string* as a token to the
+ end of the input stream, from first to last. The lexemes will be empty and
+ the line/col information is computed based on the characters encountered and
+ the data in the variables *lvar* and *cvar*.
+
+ - *meName* __run__ ?*n*?
+
+ This methods causes the engine to execute match instructions until either
+
+ *n* instructions have been executed, or
+
+ a halt instruction was executed, or
+
+ the input queue is empty and the code is asking for more tokens to process.
+
+ If no limit *n* was set only the last two conditions are checked for.
+
+ - *meName* __pull__ *nextcmd*
+
+ This method implements pull-style operation of the machine. It causes it to
+ execute match instructions until either a halt instruction is reached, or
+ the command prefix *nextcmd* ceases to deliver more tokens.
+
+ The command prefix *nextcmd* represents the input stream of characters and
+ is invoked by the machine whenever the a new character from the stream is
+ required. The instruction for handling this is *ict_advance*. The callback
+ has to return either the empty list, or a list of 4 elements containing the
+ token, its lexeme attribute, and its location as line number and column
+ index, in this order. The empty list is the signal that the end of the input
+ stream has been reached. The lexeme attribute is stored in the terminal
+ cache, but otherwise not used by the machine.
+
+ The end of the input stream for this method does not imply that method
+ __eof__ is called for the machine as a whole. By avoiding this and still
+ asking for an explicit call of the method it is possible to mix push- and
+ pull-style operation during the lifetime of the machine.
+
+ - *meName* __reset__
+
+ This method resets the machine to its initial state, discarding any state it
+ may have.
+
+ - *meName* __destroy__
+
+ This method deletes the object and releases all resurces it claimed.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005-2006 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_cpucore.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_cpucore.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_cpucore.md
@@ -0,0 +1,430 @@
+
+[//000000001]: # (grammar::me::cpu::core - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_cpucore.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me::cpu::core(n) 0.2 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me::cpu::core - ME virtual machine state manipulation
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [MATCH PROGRAM REPRESENTATION](#subsection1)
+
+ - [CPU STATE](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require grammar::me::cpu::core ?0.2?
+
+[__::grammar::me::cpu::core__ __disasm__ *asm*](#1)
+[__::grammar::me::cpu::core__ __asm__ *asm*](#2)
+[__::grammar::me::cpu::core__ __new__ *asm*](#3)
+[__::grammar::me::cpu::core__ __lc__ *state* *location*](#4)
+[__::grammar::me::cpu::core__ __tok__ *state* ?*from* ?*to*??](#5)
+[__::grammar::me::cpu::core__ __pc__ *state*](#6)
+[__::grammar::me::cpu::core__ __iseof__ *state*](#7)
+[__::grammar::me::cpu::core__ __at__ *state*](#8)
+[__::grammar::me::cpu::core__ __cc__ *state*](#9)
+[__::grammar::me::cpu::core__ __sv__ *state*](#10)
+[__::grammar::me::cpu::core__ __ok__ *state*](#11)
+[__::grammar::me::cpu::core__ __error__ *state*](#12)
+[__::grammar::me::cpu::core__ __lstk__ *state*](#13)
+[__::grammar::me::cpu::core__ __astk__ *state*](#14)
+[__::grammar::me::cpu::core__ __mstk__ *state*](#15)
+[__::grammar::me::cpu::core__ __estk__ *state*](#16)
+[__::grammar::me::cpu::core__ __rstk__ *state*](#17)
+[__::grammar::me::cpu::core__ __nc__ *state*](#18)
+[__::grammar::me::cpu::core__ __ast__ *state*](#19)
+[__::grammar::me::cpu::core__ __halted__ *state*](#20)
+[__::grammar::me::cpu::core__ __code__ *state*](#21)
+[__::grammar::me::cpu::core__ __eof__ *statevar*](#22)
+[__::grammar::me::cpu::core__ __put__ *statevar* *tok* *lex* *line* *col*](#23)
+[__::grammar::me::cpu::core__ __run__ *statevar* ?*n*?](#24)
+
+# DESCRIPTION
+
+This package provides an implementation of the ME virtual machine. Please go and
+read the document __[grammar::me_intro](me_intro.md)__ first if you do not know
+what a ME virtual machine is.
+
+This implementation represents each ME virtual machine as a Tcl value and
+provides commands to manipulate and query such values to show the effects of
+executing instructions, adding tokens, retrieving state, etc.
+
+The values fully follow the paradigm of Tcl that every value is a string and
+while also allowing C implementations for a proper Tcl_ObjType to keep all the
+important data in native data structures. Because of the latter it is
+recommended to access the state values *only* through the commands of this
+package to ensure that internal representation is not shimmered away.
+
+The actual structure used by all state values is described in section [CPU
+STATE](#section3).
+
+# API
+
+The package directly provides only a single command, and all the functionality
+is made available through its methods.
+
+ - __::grammar::me::cpu::core__ __disasm__ *asm*
+
+ This method returns a list containing a disassembly of the match
+ instructions in *asm*. The format of *asm* is specified in the section
+ [MATCH PROGRAM REPRESENTATION](#subsection1).
+
+ Each element of the result contains instruction label, instruction name, and
+ the instruction arguments, in this order. The label can be the empty string.
+ Jump destinations are shown as labels, strings and tokens unencoded. Token
+ names are prefixed with their numeric id, if, and only if a tokmap is
+ defined. The two components are separated by a colon.
+
+ - __::grammar::me::cpu::core__ __asm__ *asm*
+
+ This method returns code in the format as specified in section [MATCH
+ PROGRAM REPRESENTATION](#subsection1) generated from ME assembly code *asm*,
+ which is in the format as returned by the method __disasm__.
+
+ - __::grammar::me::cpu::core__ __new__ *asm*
+
+ This method creates state value for a ME virtual machine in its initial
+ state and returns it as its result.
+
+ The argument *matchcode* contains a Tcl representation of the match
+ instructions the machine has to execute while parsing the input stream. Its
+ format is specified in the section [MATCH PROGRAM
+ REPRESENTATION](#subsection1).
+
+ The *tokmap* argument taken by the implementation provided by the package
+ __[grammar::me::tcl](me_tcl.md)__ is here hidden inside of the match
+ instructions and therefore not needed.
+
+ - __::grammar::me::cpu::core__ __lc__ *state* *location*
+
+ This method takes the state value of a ME virtual machine and uses it to
+ convert a location in the input stream (as offset) into a line number and
+ column index. The result of the method is a 2-element list containing the
+ two pieces in the order mentioned in the previous sentence.
+
+ *Note* that the method cannot convert locations which the machine has not
+ yet read from the input stream. In other words, if the machine has read 7
+ characters so far it is possible to convert the offsets __0__ to __6__, but
+ nothing beyond that. This also shows that it is not possible to convert
+ offsets which refer to locations before the beginning of the stream.
+
+ This utility allows higher levels to convert the location offsets found in
+ the error status and the AST into more human readable data.
+
+ - __::grammar::me::cpu::core__ __tok__ *state* ?*from* ?*to*??
+
+ This method takes the state value of a ME virtual machine and returns a Tcl
+ list containing the part of the input stream between the locations *from*
+ and *to* (both inclusive). If *to* is not specified it will default to the
+ value of *from*. If *from* is not specified either the whole input stream is
+ returned.
+
+ This method places the same restrictions on its location arguments as the
+ method __lc__.
+
+ - __::grammar::me::cpu::core__ __pc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current value of the stored program counter.
+
+ - __::grammar::me::cpu::core__ __iseof__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current value of the stored eof flag.
+
+ - __::grammar::me::cpu::core__ __at__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current location in the input stream.
+
+ - __::grammar::me::cpu::core__ __cc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current token.
+
+ - __::grammar::me::cpu::core__ __sv__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current semantic value stored in it. This is an abstract syntax tree as
+ specified in the document __[grammar::me_ast](me_ast.md)__, section __AST
+ VALUES__.
+
+ - __::grammar::me::cpu::core__ __ok__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ match status stored in it.
+
+ - __::grammar::me::cpu::core__ __error__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current error status stored in it.
+
+ - __::grammar::me::cpu::core__ __lstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ location stack.
+
+ - __::grammar::me::cpu::core__ __astk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ AST stack.
+
+ - __::grammar::me::cpu::core__ __mstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ AST marker stack.
+
+ - __::grammar::me::cpu::core__ __estk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ error stack.
+
+ - __::grammar::me::cpu::core__ __rstk__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ subroutine return stack.
+
+ - __::grammar::me::cpu::core__ __nc__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ nonterminal match cache as a dictionary.
+
+ - __::grammar::me::cpu::core__ __ast__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ abstract syntax tree currently at the top of the AST stack stored in it.
+ This is an abstract syntax tree as specified in the document
+ __[grammar::me_ast](me_ast.md)__, section __AST VALUES__.
+
+ - __::grammar::me::cpu::core__ __halted__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ current halt status stored in it, i.e. if the machine has stopped or not.
+
+ - __::grammar::me::cpu::core__ __code__ *state*
+
+ This method takes the state value of a ME virtual machine and returns the
+ code stored in it, i.e. the instructions executed by the machine.
+
+ - __::grammar::me::cpu::core__ __eof__ *statevar*
+
+ This method takes the state value of a ME virtual machine as stored in the
+ variable named by *statevar* and modifies it so that the eof flag inside is
+ set. This signals to the machine that whatever token are in the input queue
+ are the last to be processed. There will be no more.
+
+ - __::grammar::me::cpu::core__ __put__ *statevar* *tok* *lex* *line* *col*
+
+ This method takes the state value of a ME virtual machine as stored in the
+ variable named by *statevar* and modifies it so that the token *tok* is
+ added to the end of the input queue, with associated lexeme data *lex* and
+ *line*/*col*umn information.
+
+ The operation will fail with an error if the eof flag of the machine has
+ been set through the method __eof__.
+
+ - __::grammar::me::cpu::core__ __run__ *statevar* ?*n*?
+
+ This method takes the state value of a ME virtual machine as stored in the
+ variable named by *statevar*, executes a number of instructions and stores
+ the state resulting from their modifications back into the variable.
+
+ The execution loop will run until either
+
+ *n* instructions have been executed, or
+
+ a halt instruction was executed, or
+
+ the input queue is empty and the code is asking for more tokens to process.
+
+ If no limit *n* was set only the last two conditions are checked for.
+
+## MATCH PROGRAM REPRESENTATION
+
+A match program is represented by nested Tcl list. The first element, *asm*, is
+a list of integer numbers, the instructions to execute, and their arguments. The
+second element, *[pool](../../../../index.md#pool)*, is a list of strings,
+referenced by the instructions, for error messages, token names, etc. The third
+element, *tokmap*, provides ordering information for the tokens, mapping their
+names to their numerical rank. This element can be empty, forcing lexicographic
+comparison when matching ranges.
+
+All ME instructions are encoded as integer numbers, with the mapping given
+below. A number of the instructions, those which handle error messages, have
+been given an additional argument to supply that message explicitly instead of
+having it constructed from token names, etc. This allows the machine state to
+store only the message ids instead of the full strings.
+
+Jump destination arguments are absolute indices into the *asm* element, refering
+to the instruction to jump to. Any string arguments are absolute indices into
+the *[pool](../../../../index.md#pool)* element. Tokens, characters, messages,
+and token (actually character) classes to match are coded as references into the
+*[pool](../../../../index.md#pool)* as well.
+
+ 1. "__ict_advance__ *message*"
+
+ 1. "__ict_match_token__ *tok* *message*"
+
+ 1. "__ict_match_tokrange__ *tokbegin* *tokend* *message*"
+
+ 1. "__ict_match_tokclass__ *code* *message*"
+
+ 1. "__inc_restore__ *branchlabel* *nt*"
+
+ 1. "__inc_save__ *nt*"
+
+ 1. "__icf_ntcall__ *branchlabel*"
+
+ 1. "__icf_ntreturn__"
+
+ 1. "__iok_ok__"
+
+ 1. "__iok_fail__"
+
+ 1. "__iok_negate__"
+
+ 1. "__icf_jalways__ *branchlabel*"
+
+ 1. "__icf_jok__ *branchlabel*"
+
+ 1. "__icf_jfail__ *branchlabel*"
+
+ 1. "__icf_halt__"
+
+ 1. "__icl_push__"
+
+ 1. "__icl_rewind__"
+
+ 1. "__icl_pop__"
+
+ 1. "__ier_push__"
+
+ 1. "__ier_clear__"
+
+ 1. "__ier_nonterminal__ *message*"
+
+ 1. "__ier_merge__"
+
+ 1. "__isv_clear__"
+
+ 1. "__isv_terminal__"
+
+ 1. "__isv_nonterminal_leaf__ *nt*"
+
+ 1. "__isv_nonterminal_range__ *nt*"
+
+ 1. "__isv_nonterminal_reduce__ *nt*"
+
+ 1. "__ias_push__"
+
+ 1. "__ias_mark__"
+
+ 1. "__ias_mrewind__"
+
+ 1. "__ias_mpop__"
+
+# CPU STATE
+
+A state value is a list containing the following elements, in the order listed
+below:
+
+ 1. *code*: Match instructions, see [MATCH PROGRAM
+ REPRESENTATION](#subsection1).
+
+ 1. *pc*: Program counter, *int*.
+
+ 1. *halt*: Halt flag, *boolean*.
+
+ 1. *eof*: Eof flag, *boolean*
+
+ 1. *tc*: Terminal cache, and input queue. Structure see below.
+
+ 1. *cl*: Current location, *int*.
+
+ 1. *ct*: Current token, *[string](../../../../index.md#string)*.
+
+ 1. *ok*: Match status, *boolean*.
+
+ 1. *sv*: Semantic value, *[list](../../../../index.md#list)*.
+
+ 1. *er*: Error status, *[list](../../../../index.md#list)*.
+
+ 1. *ls*: Location stack, *[list](../../../../index.md#list)*.
+
+ 1. *as*: AST stack, *[list](../../../../index.md#list)*.
+
+ 1. *ms*: AST marker stack, *[list](../../../../index.md#list)*.
+
+ 1. *es*: Error stack, *[list](../../../../index.md#list)*.
+
+ 1. *rs*: Return stack, *[list](../../../../index.md#list)*.
+
+ 1. *nc*: Nonterminal cache, *dictionary*.
+
+*tc*, the input queue of tokens waiting for processing and the terminal cache
+containing the tokens already processing are one unified data structure simply
+holding all tokens and their information, with the current location separating
+that which has been processed from that which is waiting. Each element of the
+queue/cache is a list containing the token, its lexeme information, line number,
+and column index, in this order.
+
+All stacks have their top element aat the end, i.e. pushing an item is
+equivalent to appending to the list representing the stack, and popping it
+removes the last element.
+
+*er*, the error status is either empty or a list of two elements, a location in
+the input, and a list of messages, encoded as references into the
+*[pool](../../../../index.md#pool)* element of the *code*.
+
+*nc*, the nonterminal cache is keyed by nonterminal name and location, each
+value a four-element list containing current location, match status, semantic
+value, and error status, in this order.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005-2006 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_intro.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_intro.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_intro.md
@@ -0,0 +1,111 @@
+
+[//000000001]: # (grammar::me_intro - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_intro.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me_intro(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me_intro - Introduction to virtual machines for parsing token streams
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Description](#section1)
+
+ - [Bugs, Ideas, Feedback](#section2)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# DESCRIPTION
+
+This document is an introduction to and overview of the basic facilities for the
+parsing and/or matching of *token* streams. One possibility often used for the
+token domain are characters.
+
+The packages themselves all provide variants of one *[virtual
+machine](../../../../index.md#virtual_machine)*, called a *match engine* (short
+*ME*), which has all the facilities needed for the matching and parsing of a
+stream, and which are either controlled directly, or are customized with a match
+program. The virtual machine is basically a pushdown automaton, with additional
+elements for backtracking and/or handling of semantic data and construction of
+abstract syntax trees (*[AST](../../../../index.md#ast)*).
+
+Because of the high degree of similarity in the actual implementations of the
+aforementioned virtual machine and the data structures they receive and generate
+these common parts are specified in a separate document which will be referenced
+by the documentation for packages actually implementing it.
+
+The relevant documents are:
+
+ - __[grammar::me_vm](me_vm.md)__
+
+ Virtual machine specification.
+
+ - __[grammar::me_ast](me_ast.md)__
+
+ Specification of various representations used for abstract syntax trees.
+
+ - __[grammar::me::util](me_util.md)__
+
+ Utility commands.
+
+ - __[grammar::me::tcl](me_tcl.md)__
+
+ Singleton ME virtual machine implementation tied to Tcl for control flow and
+ stacks. Hardwired for pull operation. Uninteruptible during processing.
+
+ - __[grammar::me::cpu](me_cpu.md)__
+
+ Object-based ME virtual machine implementation with explicit control flow,
+ and stacks, using bytecodes. Suspend/Resumable. Push/pull operation.
+
+ - __[grammar::me::cpu::core](me_cpucore.md)__
+
+ Core functionality for state manipulation and stepping used in the bytecode
+ based implementation of ME virtual machines.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[CFG](../../../../index.md#cfg), [CFL](../../../../index.md#cfl),
+[LL(k)](../../../../index.md#ll_k_), [PEG](../../../../index.md#peg),
+[TPDL](../../../../index.md#tpdl), [context-free
+grammar](../../../../index.md#context_free_grammar), [context-free
+languages](../../../../index.md#context_free_languages),
+[expression](../../../../index.md#expression),
+[grammar](../../../../index.md#grammar),
+[matching](../../../../index.md#matching),
+[parsing](../../../../index.md#parsing), [parsing expression
+grammar](../../../../index.md#parsing_expression_grammar), [push down
+automaton](../../../../index.md#push_down_automaton), [recursive
+descent](../../../../index.md#recursive_descent), [top-down parsing
+languages](../../../../index.md#top_down_parsing_languages),
+[transducer](../../../../index.md#transducer), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_tcl.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_tcl.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_tcl.md
@@ -0,0 +1,386 @@
+
+[//000000001]: # (grammar::me::tcl - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_tcl.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me::tcl(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me::tcl - Virtual machine implementation I for parsing token streams
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [API](#section2)
+
+ - [MACHINE STATE](#section3)
+
+ - [MACHINE INSTRUCTIONS](#section4)
+
+ - [Bugs, Ideas, Feedback](#section5)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require grammar::me::tcl ?0.1?
+
+[__::grammar::me::tcl__ __cmd__ *...*](#1)
+[__::grammar::me::tcl__ __init__ *nextcmd* ?*tokmap*?](#2)
+[__::grammar::me::tcl__ __lc__ *location*](#3)
+[__::grammar::me::tcl__ __tok__ *from* ?*to*?](#4)
+[__::grammar::me::tcl__ __tokens__](#5)
+[__::grammar::me::tcl__ __sv__](#6)
+[__::grammar::me::tcl__ __ast__](#7)
+[__::grammar::me::tcl__ __astall__](#8)
+[__::grammar::me::tcl__ __ctok__](#9)
+[__::grammar::me::tcl__ __nc__](#10)
+[__::grammar::me::tcl__ __next__](#11)
+[__::grammar::me::tcl__ __ord__](#12)
+[__::grammar::me::tcl::ict_advance__ *message*](#13)
+[__::grammar::me::tcl::ict_match_token__ *tok* *message*](#14)
+[__::grammar::me::tcl::ict_match_tokrange__ *tokbegin* *tokend* *message*](#15)
+[__::grammar::me::tcl::ict_match_tokclass__ *code* *message*](#16)
+[__::grammar::me::tcl::inc_restore__ *nt*](#17)
+[__::grammar::me::tcl::inc_save__ *nt* *startlocation*](#18)
+[__::grammar::me::tcl::iok_ok__](#19)
+[__::grammar::me::tcl::iok_fail__](#20)
+[__::grammar::me::tcl::iok_negate__](#21)
+[__::grammar::me::tcl::icl_get__](#22)
+[__::grammar::me::tcl::icl_rewind__ *oldlocation*](#23)
+[__::grammar::me::tcl::ier_get__](#24)
+[__::grammar::me::tcl::ier_clear__](#25)
+[__::grammar::me::tcl::ier_nonterminal__ *message* *location*](#26)
+[__::grammar::me::tcl::ier_merge__ *olderror*](#27)
+[__::grammar::me::tcl::isv_clear__](#28)
+[__::grammar::me::tcl::isv_terminal__](#29)
+[__::grammar::me::tcl::isv_nonterminal_leaf__ *nt* *startlocation*](#30)
+[__::grammar::me::tcl::isv_nonterminal_range__ *nt* *startlocation*](#31)
+[__::grammar::me::tcl::isv_nonterminal_reduce__ *nt* *startlocation* ?*marker*?](#32)
+[__::grammar::me::tcl::ias_push__](#33)
+[__::grammar::me::tcl::ias_mark__](#34)
+[__::grammar::me::tcl::ias_pop2mark__ *marker*](#35)
+
+# DESCRIPTION
+
+This package provides an implementation of the ME virtual machine. Please go and
+read the document __[grammar::me_intro](me_intro.md)__ first if you do not know
+what a ME virtual machine is.
+
+This implementation is tied very strongly to Tcl. All the stacks in the machine
+state are handled through the Tcl stack, all control flow is handled by Tcl
+commands, and the remaining machine instructions are directly mapped to Tcl
+commands. Especially the matching of nonterminal symbols is handled by Tcl
+procedures as well, essentially extending the machine implementation with custom
+instructions.
+
+Further on the implementation handles only a single machine which is
+uninteruptible during execution and hardwired for pull operation. I.e. it
+explicitly requests each new token through a callback, pulling them into its
+state.
+
+A related package is __[grammar::peg::interp](../grammar_peg/peg_interp.md)__
+which provides a generic interpreter / parser for parsing expression grammars
+(PEGs), implemented on top of this implementation of the ME virtual machine.
+
+# API
+
+The commands documented in this section do not implement any of the instructions
+of the ME virtual machine. They provide the facilities for the initialization of
+the machine and the retrieval of important information.
+
+ - __::grammar::me::tcl__ __cmd__ *...*
+
+ This is an ensemble command providing access to the commands listed in this
+ section. See the methods themselves for detailed specifications.
+
+ - __::grammar::me::tcl__ __init__ *nextcmd* ?*tokmap*?
+
+ This command (re)initializes the machine. It returns the empty string. This
+ command has to be invoked before any other command of this package.
+
+ The command prefix *nextcmd* represents the input stream of characters and
+ is invoked by the machine whenever the a new character from the stream is
+ required. The instruction for handling this is *ict_advance*. The callback
+ has to return either the empty list, or a list of 4 elements containing the
+ token, its lexeme attribute, and its location as line number and column
+ index, in this order. The empty list is the signal that the end of the input
+ stream has been reached. The lexeme attribute is stored in the terminal
+ cache, but otherwise not used by the machine.
+
+ The optional dictionary *tokmap* maps from tokens to integer numbers. If
+ present the numbers impose an order on the tokens, which is subsequently
+ used by *ict_match_tokrange* to determine if a token is in the specified
+ range or not. If no token map is specified the lexicographic order of th
+ token names will be used instead. This choice is especially asensible when
+ using characters as tokens.
+
+ - __::grammar::me::tcl__ __lc__ *location*
+
+ This command converts the location of a token given as offset in the input
+ stream into the associated line number and column index. The result of the
+ command is a 2-element list containing the two values, in the order
+ mentioned in the previous sentence. This allows higher levels to convert the
+ location information found in the error status and the generated AST into
+ more human readable data.
+
+ *Note* that the command is not able to convert locations which have not been
+ reached by the machine yet. In other words, if the machine has read 7 tokens
+ the command is able to convert the offsets __0__ to __6__, but nothing
+ beyond that. This also shows that it is not possible to convert offsets
+ which refer to locations before the beginning of the stream.
+
+ After a call of __init__ the state used for the conversion is cleared,
+ making further conversions impossible until the machine has read tokens
+ again.
+
+ - __::grammar::me::tcl__ __tok__ *from* ?*to*?
+
+ This command returns a Tcl list containing the part of the input stream
+ between the locations *from* and *to* (both inclusive). If *to* is not
+ specified it will default to the value of *from*.
+
+ Each element of the returned list is a list of four elements, the token, its
+ associated lexeme, line number, and column index, in this order. In other
+ words, each element has the same structure as the result of the *nextcmd*
+ callback given to __::grammar::me::tcl::init__
+
+ This command places the same restrictions on its location arguments as
+ __::grammar::me::tcl::lc__.
+
+ - __::grammar::me::tcl__ __tokens__
+
+ This command returns the number of tokens currently known to the ME virtual
+ machine.
+
+ - __::grammar::me::tcl__ __sv__
+
+ This command returns the current semantic value *SV* stored in the machine.
+ This is an abstract syntax tree as specified in the document
+ __[grammar::me_ast](me_ast.md)__, section __AST VALUES__.
+
+ - __::grammar::me::tcl__ __ast__
+
+ This method returns the abstract syntax tree currently at the top of the AST
+ stack of the ME virtual machine. This is an abstract syntax tree as
+ specified in the document __[grammar::me_ast](me_ast.md)__, section __AST
+ VALUES__.
+
+ - __::grammar::me::tcl__ __astall__
+
+ This method returns the whole stack of abstract syntax trees currently known
+ to the ME virtual machine. Each element of the returned list is an abstract
+ syntax tree as specified in the document __[grammar::me_ast](me_ast.md)__,
+ section __AST VALUES__. The top of the stack resides at the end of the list.
+
+ - __::grammar::me::tcl__ __ctok__
+
+ This method returns the current token considered by the ME virtual machine.
+
+ - __::grammar::me::tcl__ __nc__
+
+ This method returns the contents of the nonterminal cache as a dictionary
+ mapping from "__symbol__,__location__" to match information.
+
+ - __::grammar::me::tcl__ __next__
+
+ This method returns the next token callback as specified during
+ initialization of the ME virtual machine.
+
+ - __::grammar::me::tcl__ __ord__
+
+ This method returns a dictionary containing the *tokmap* specified during
+ initialization of the ME virtual machine. ____::grammar::me::tcl::ok____
+ This variable contains the current match status *OK*. It is provided as
+ variable instead of a command because that makes access to this information
+ faster, and the speed of access is considered very important here as this
+ information is used constantly to determine the control flow.
+
+# MACHINE STATE
+
+Please go and read the document __[grammar::me_vm](me_vm.md)__ first for a
+specification of the basic ME virtual machine and its state.
+
+This implementation manages the state described in that document, except for the
+stacks minus the AST stack. In other words, location stack, error stack, return
+stack, and ast marker stack are implicitly managed through standard Tcl scoping,
+i.e. Tcl variables in procedures, outside of this implementation.
+
+# MACHINE INSTRUCTIONS
+
+Please go and read the document __[grammar::me_vm](me_vm.md)__ first for a
+specification of the basic ME virtual machine and its instruction set.
+
+This implementation maps all instructions to Tcl commands in the namespace
+"::grammar::me::tcl", except for the stack related commands, nonterminal symbols
+and control flow. Here we simply list the commands and explain the differences
+to the specified instructions, if there are any. For their semantics see the
+aforementioned specification. The machine commands are *not* reachable through
+the ensemble command __::grammar::me::tcl__.
+
+ - __::grammar::me::tcl::ict_advance__ *message*
+
+ No changes.
+
+ - __::grammar::me::tcl::ict_match_token__ *tok* *message*
+
+ No changes.
+
+ - __::grammar::me::tcl::ict_match_tokrange__ *tokbegin* *tokend* *message*
+
+ If, and only if a token map was specified during initialization then the
+ arguments are the numeric representations of the smallest and largest tokens
+ in the range. Otherwise they are the relevant tokens themselves and
+ lexicographic comparison is used.
+
+ - __::grammar::me::tcl::ict_match_tokclass__ *code* *message*
+
+ No changes.
+
+ - __::grammar::me::tcl::inc_restore__ *nt*
+
+ Instead of taking a branchlabel the command returns a boolean value. The
+ result will be __true__ if and only if cached information was found. The
+ caller has to perform the appropriate branching.
+
+ - __::grammar::me::tcl::inc_save__ *nt* *startlocation*
+
+ The command takes the start location as additional argument, as it is
+ managed on the Tcl stack, and not in the machine state.
+
+ - __icf_ntcall__ *branchlabel*
+
+ - __icf_ntreturn__
+
+ These two instructions are not mapped to commands. They are control flow
+ instructions and handled in Tcl.
+
+ - __::grammar::me::tcl::iok_ok__
+
+ No changes.
+
+ - __::grammar::me::tcl::iok_fail__
+
+ No changes.
+
+ - __::grammar::me::tcl::iok_negate__
+
+ No changes.
+
+ - __icf_jalways__ *branchlabel*
+
+ - __icf_jok__ *branchlabel*
+
+ - __icf_jfail__ *branchlabel*
+
+ - __icf_halt__
+
+ These four instructions are not mapped to commands. They are control flow
+ instructions and handled in Tcl.
+
+ - __::grammar::me::tcl::icl_get__
+
+ This command returns the current location *CL* in the input. It replaces
+ *icl_push*.
+
+ - __::grammar::me::tcl::icl_rewind__ *oldlocation*
+
+ The command takes the location as argument as it comes from the Tcl stack,
+ not the machine state.
+
+ - __icl_pop__
+
+ Not mapped, the stacks are not managed by the package.
+
+ - __::grammar::me::tcl::ier_get__
+
+ This command returns the current error state *ER*. It replaces *ier_push*.
+
+ - __::grammar::me::tcl::ier_clear__
+
+ No changes.
+
+ - __::grammar::me::tcl::ier_nonterminal__ *message* *location*
+
+ The command takes the location as argument as it comes from the Tcl stack,
+ not the machine state.
+
+ - __::grammar::me::tcl::ier_merge__ *olderror*
+
+ The command takes the second error state to merge as argument as it comes
+ from the Tcl stack, not the machine state.
+
+ - __::grammar::me::tcl::isv_clear__
+
+ No changes.
+
+ - __::grammar::me::tcl::isv_terminal__
+
+ No changes.
+
+ - __::grammar::me::tcl::isv_nonterminal_leaf__ *nt* *startlocation*
+
+ The command takes the start location as argument as it comes from the Tcl
+ stack, not the machine state.
+
+ - __::grammar::me::tcl::isv_nonterminal_range__ *nt* *startlocation*
+
+ The command takes the start location as argument as it comes from the Tcl
+ stack, not the machine state.
+
+ - __::grammar::me::tcl::isv_nonterminal_reduce__ *nt* *startlocation* ?*marker*?
+
+ The command takes start location and marker as argument as it comes from the
+ Tcl stack, not the machine state.
+
+ - __::grammar::me::tcl::ias_push__
+
+ No changes.
+
+ - __::grammar::me::tcl::ias_mark__
+
+ This command returns a marker for the current state of the AST stack *AS*.
+ The marker stack is not managed by the machine.
+
+ - __::grammar::me::tcl::ias_pop2mark__ *marker*
+
+ The command takes the marker as argument as it comes from the Tcl stack, not
+ the machine state. It replaces *ias_mpop*.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_util.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_util.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_util.md
@@ -0,0 +1,113 @@
+
+[//000000001]: # (grammar::me::util - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_util.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me::util(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me::util - AST utilities
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Bugs, Ideas, Feedback](#section2)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require grammar::me::util ?0.1?
+
+[__::grammar::me::util::ast2tree__ *ast* *tree* ?*root*?](#1)
+[__::grammar::me::util::ast2etree__ *ast* *mcmd* *tree* ?*root*?](#2)
+[__mcmd__ __lc__ *location*](#3)
+[__mcmd__ __tok__ *from* ?*to*?](#4)
+[__::grammar::me::util::tree2ast__ *tree* ?*root*?](#5)
+
+# DESCRIPTION
+
+This package provides a number of utility command for the conversion between the
+various representations of abstract syntax trees as specified in the document
+__[grammar::me_ast](me_ast.md)__.
+
+ - __::grammar::me::util::ast2tree__ *ast* *tree* ?*root*?
+
+ This command converts an *ast* from value to object representation. All
+ nodes in the *ast* will be converted into nodes of this *tree*, with the
+ root of the AST a child of the node *root*. If this node is not explicitly
+ specified the root of the tree is used. Existing content of tree is not
+ touched, i.e. neither removed nor changed, with the exception of the
+ specified root node, which will gain a new child.
+
+ - __::grammar::me::util::ast2etree__ *ast* *mcmd* *tree* ?*root*?
+
+ This command is like __::grammar::me::util::ast2tree__, except that the
+ result is in the extended object representation of the input AST. The source
+ of the extended information is the command prefix *mcmd*. It has to
+ understand two methods, __lc__, and __tok__, with the semantics specified
+ below.
+
+ * __mcmd__ __lc__ *location*
+
+ Takes the location of a token given as offset in the input stream and
+ return a 2-element list containing the associated line number and column
+ index, in this order.
+
+ * __mcmd__ __tok__ *from* ?*to*?
+
+ Takes one or two locations *from* and *to* as offset in the input stream
+ and returns a Tcl list containing the specified part of the input
+ stream. Both location are inclusive. If *to* is not specified it will
+ default to the value of *from*.
+
+ Each element of the returned list is a list containing the token, its
+ associated lexeme, the line number, and column index, in this order.
+
+ Both the ensemble command __::grammar::me::tcl__ provided by the package
+ __[grammar::me::tcl](me_tcl.md)__ and the objects command created by the
+ package __::grammar::me::cpu__ fit the above specification.
+
+ - __::grammar::me::util::tree2ast__ *tree* ?*root*?
+
+ This command converts an *ast* in (extended) object representation into a
+ value and returns it. If a *root* node is specified the AST is generated
+ from that node downward. Otherwise the root of the tree object is used as
+ the starting point.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[abstract syntax tree](../../../../index.md#abstract_syntax_tree), [syntax
+tree](../../../../index.md#syntax_tree), [tree](../../../../index.md#tree)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_me/me_vm.md
Index: embedded/md/tcllib/files/modules/grammar_me/me_vm.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_me/me_vm.md
@@ -0,0 +1,543 @@
+
+[//000000001]: # (grammar::me_vm - Grammar operations and usage)
+[//000000002]: # (Generated from file 'me_vm.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::me_vm(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::me_vm - Virtual machine for parsing token streams
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Description](#section1)
+
+ - [MACHINE STATE](#section2)
+
+ - [MACHINE INSTRUCTIONS](#section3)
+
+ - [TERMINAL MATCHING](#subsection1)
+
+ - [NONTERMINAL MATCHING](#subsection2)
+
+ - [UNCONDITIONAL MATCHING](#subsection3)
+
+ - [CONTROL FLOW](#subsection4)
+
+ - [INPUT LOCATION HANDLING](#subsection5)
+
+ - [ERROR HANDLING](#subsection6)
+
+ - [SEMANTIC VALUES](#subsection7)
+
+ - [AST STACK HANDLING](#subsection8)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# DESCRIPTION
+
+Please go and read the document __[grammar::me_intro](me_intro.md)__ first for
+an overview of the various documents and their relations.
+
+This document specifies a virtual machine for the controlled matching and
+parsing of token streams, creating an *[abstract syntax
+tree](../../../../index.md#abstract_syntax_tree)* (short
+*[AST](../../../../index.md#ast)*) reflecting the structure of the input.
+Special machine features are the caching and reuse of partial results, caching
+of the encountered input, and the ability to backtrack in both input and AST
+creation.
+
+These features make the specified virtual machine especially useful to packrat
+parsers based on parsing expression grammars. It is however not restricted to
+this type of parser. Normal LL and LR parsers can be implemented with it as
+well.
+
+The following sections will discuss first the abstract state kept by ME virtual
+machines, and then their instruction set.
+
+# MACHINE STATE
+
+A ME virtual machine manages the following state:
+
+ - *Current token* CT
+
+ The token from the input under consideration by the machine.
+
+ This information is used and modified by the instructions defined in the
+ section [TERMINAL MATCHING](#subsection1).
+
+ - *Current location* CL
+
+ The location of the *current token* in the input stream, as offset relative
+ to the beginning of the stream. The first token is considered to be at
+ offset __0__.
+
+ This information is implicitly used and modified by the instructions defined
+ in the sections [TERMINAL MATCHING](#subsection1) and [NONTERMINAL
+ MATCHING](#subsection2), and can be directly queried and modified by the
+ instructions defined in section [INPUT LOCATION HANDLING](#subsection5).
+
+ - *Location stack* LS
+
+ In addition to the above a stack of locations, for backtracking. Locations
+ can put on the stack, removed from it, and removed with setting the current
+ location.
+
+ This information is implicitly used and modified by the instructions defined
+ in the sections [TERMINAL MATCHING](#subsection1) and [NONTERMINAL
+ MATCHING](#subsection2), and can be directly queried and modified by the
+ instructions defined in section [INPUT LOCATION HANDLING](#subsection5).
+
+ - *Match status* OK
+
+ A boolean value, the result of the last attempt at matching input. It is set
+ to __true__ if that attempt was successful, and __false__ otherwise.
+
+ This information is influenced by the instructions defined in the sections
+ [TERMINAL MATCHING](#subsection1), [NONTERMINAL MATCHING](#subsection2), and
+ [UNCONDITIONAL MATCHING](#subsection3). It is queried by the instructions
+ defined in the section [CONTROL FLOW](#subsection4).
+
+ - *Semantic value* SV
+
+ The semantic value associated with (generated by) the last attempt at
+ matching input. Contains either the empty string or a node for the abstract
+ syntax tree constructed from the input.
+
+ This information is influenced by the instructions defined in the sections
+ [SEMANTIC VALUES](#subsection7), and [AST STACK HANDLING](#subsection8).
+
+ - *AST stack* AS
+
+ A stack of partial abstract syntax trees constructed by the machine during
+ matching.
+
+ This information is influenced by the instructions defined in the sections
+ [SEMANTIC VALUES](#subsection7), and [AST STACK HANDLING](#subsection8).
+
+ - *AST Marker stack* MS
+
+ In addition to the above a stack of stacks, for backtracking. This is
+ actually a stack of markers into the AST stack, thus implicitly snapshooting
+ the state of the AST stack at some point in time. Markers can be put on the
+ stack, dropped from it, and used to roll back the AST stack to an earlier
+ state.
+
+ This information is influenced by the instructions defined in the sections
+ [SEMANTIC VALUES](#subsection7), and [AST STACK HANDLING](#subsection8).
+
+ - *Error status* ER
+
+ Error information associated with the last attempt at matching input.
+ Contains either the empty string or a list of 2 elements, a location in the
+ input and a list of error messages associated with it, in this order.
+
+ *Note* that error information can be set even if the last attempt at
+ matching input was successful. For example the *-operator (matching a
+ sub-expression zero or more times) in a parsing expression grammar is always
+ successful, even if it encounters a problem further in the input and has to
+ backtrack. Such problems must not be forgotten when continuing to match.
+
+ This information is queried and influenced by the instructions defined in
+ the sections [TERMINAL MATCHING](#subsection1), [NONTERMINAL
+ MATCHING](#subsection2), and [ERROR HANDLING](#subsection6).
+
+ - *Error stack* ES
+
+ In addition to the above a stack of error information, to allow the merging
+ of current and older error information when performing backtracking in
+ choices after an unsucessful match.
+
+ This information is queried and influenced by the instructions defined in
+ the sections [TERMINAL MATCHING](#subsection1), [NONTERMINAL
+ MATCHING](#subsection2), and [ERROR HANDLING](#subsection6).
+
+ - *Return stack* RS
+
+ A stack of program counter values, i.e. locations in the code controlling
+ the virtual machine, for the management of subroutine calls, i.e. the
+ matching of nonterminal symbols.
+
+ This information is queried and influenced by the instructions defined in
+ the section [NONTERMINAL MATCHING](#subsection2).
+
+ - *Nonterminal cache* NC
+
+ A cache of machine states (A 4-tuple containing a location in the input,
+ match status *OK*, semantic value *SV*, and error status *ER*) keyed by name
+ of nonterminal symbol and location in the input stream.
+
+ The key location is where machine started the attempt to match the named
+ nonterminal symbol, and the location in the value is where machine ended up
+ after the attempt completed, independent of the success of the attempt.
+
+ This status is queried and influenced by the instructions defined in the
+ section [NONTERMINAL MATCHING](#subsection2).
+
+# MACHINE INSTRUCTIONS
+
+With the machine state specified it is now possible to explain the instruction
+set of ME virtual machines. They are grouped roughly by the machine state they
+influence and/or query.
+
+## TERMINAL MATCHING
+
+First the instructions to match tokens from the input stream, and by extension
+all terminal symbols.
+
+These instructions are the only ones which may retrieve a new token from the
+input stream. This is a *may* and not a *will* because the instructions will a
+retrieve new token if, and only if the current location *CL* is at the head of
+the stream. If the machine has backtracked (see __icl_rewind__) the instructions
+will retrieve the token to compare against from the internal cache.
+
+ - __ict_advance__ *message*
+
+ This instruction tries to advance to the next token in the input stream,
+ i.e. the one after the current location *CL*. The instruction will fail if,
+ and only if the end of the input stream is reached, i.e. if there is no next
+ token.
+
+ The sucess/failure of the instruction is remembered in the match status
+ *OK*. In the case of failure the error status *ER* is set to the current
+ location and the message *message*. In the case of success the error status
+ *ER* is cleared, the new token is made the current token *CT*, and the new
+ location is made the current location *CL*.
+
+ The argument *message* is a reference to the string to put into the error
+ status *ER*, if such is needed.
+
+ - __ict_match_token__ *tok* *message*
+
+ This instruction tests the current token *CT* for equality with the argument
+ *tok* and records the result in the match status *OK*. The instruction fails
+ if the current token is not equal to *tok*.
+
+ In case of failure the error status *ER* is set to the current location *CL*
+ and the message *message*, and the current location *CL* is moved one token
+ backwards. Otherwise, i.e. upon success, the error status *ER* is cleared
+ and the current location *CL* is not touched.
+
+ - __ict_match_tokrange__ *tokbegin* *tokend* *message*
+
+ This instruction tests the current token *CT* for being in the range of
+ tokens from *tokbegin* to *tokend* (inclusive) and records the result in the
+ match status *OK*. The instruction fails if the current token is not inside
+ the range.
+
+ In case of failure the error status *ER* is set to the current location *CL*
+ and the message *message*, and the current location *CL* is moved one token
+ backwards. Otherwise, i.e. upon success, the error status *ER* is cleared
+ and the current location *CL* is not touched.
+
+ - __ict_match_tokclass__ *code* *message*
+
+ This instruction tests the current token *CT* for being a member of the
+ token class *code* and records the result in the match status *OK*. The
+ instruction fails if the current token is not a member of the specified
+ class.
+
+ In case of failure the error status *ER* is set to the current location *CL*
+ and the message *message*, and the current location *CL* is moved one token
+ backwards. Otherwise, i.e. upon success, the error status *ER* is cleared
+ and the current location *CL* is not touched.
+
+ Currently the following classes are legal:
+
+ * alnum
+
+ A token is accepted if it is a unicode alphabetical character, or a
+ digit.
+
+ * alpha
+
+ A token is accepted if it is a unicode alphabetical character.
+
+ * digit
+
+ A token is accepted if it is a unicode digit character.
+
+ * xdigit
+
+ A token is accepted if it is a hexadecimal digit character.
+
+ * punct
+
+ A token is accepted if it is a unicode punctuation character.
+
+ * space
+
+ A token is accepted if it is a unicode space character.
+
+## NONTERMINAL MATCHING
+
+The instructions in this section handle the matching of nonterminal symbols.
+They query the nonterminal cache *NC* for saved information, and put such
+information into the cache.
+
+The usage of the cache is a performance aid for backtracking parsers, allowing
+them to avoid an expensive rematch of complex nonterminal symbols if they have
+been encountered before.
+
+ - __inc_restore__ *branchlabel* *nt*
+
+ This instruction checks if the nonterminal cache *NC* contains information
+ about the nonterminal symbol *nt*, at the current location *CL*. If that is
+ the case the instruction will update the machine state (current location
+ *CL*, match status *OK*, semantic value *SV*, and error status *ER*) with
+ the found information and continue execution at the instruction refered to
+ by the *branchlabel*. The new current location *CL* will be the last token
+ matched by the nonterminal symbol, i.e. belonging to it.
+
+ If no information was found the instruction will continue execution at the
+ next instruction.
+
+ Together with __icf_ntcall__ it is possible to generate code for memoized
+ and non-memoized matching of nonterminal symbols, either as subroutine
+ calls, or inlined in the caller.
+
+ - __inc_save__ *nt*
+
+ This instruction saves the current state of the machine (current location
+ *CL*, match status *OK*, semantic value *SV*, and error status *ER*), to the
+ nonterminal cache *NC*. It will also pop an entry from the location stack
+ *LS* and save it as the start location of the match.
+
+ It is expected to be called at the end of matching a nonterminal symbol,
+ with *nt* the name of the nonterminal symbol the code was working on. This
+ allows the instruction __inc_restore__ to check for and retrieve the data,
+ should we have to match this nonterminal symbol at the same location again,
+ during backtracking.
+
+ - __icf_ntcall__ *branchlabel*
+
+ This instruction invokes the code for matching the nonterminal symbol *nt*
+ as a subroutine. To this end it stores the current program counter *PC* on
+ the return stack *RS*, the current location *CL* on the location stack *LS*,
+ and then continues execution at the address *branchlabel*.
+
+ The next matching __icf_ntreturn__ will cause the execution to continue at
+ the instruction coming after the call.
+
+ - __icf_ntreturn__
+
+ This instruction will pop an entry from the return stack *RS*, assign it to
+ the program counter *PC*, and then continue execution at the new address.
+
+## UNCONDITIONAL MATCHING
+
+The instructions in this section are the remaining match operators. They change
+the match status *OK* directly and unconditionally.
+
+ - __iok_ok__
+
+ This instruction sets the match status *OK* to __true__, indicating a
+ successful match.
+
+ - __iok_fail__
+
+ This instruction sets the match status *OK* to __false__, indicating a
+ failed match.
+
+ - __iok_negate__
+
+ This instruction negates the match status *OK*, turning a failure into a
+ success and vice versa.
+
+## CONTROL FLOW
+
+The instructions in this section implement both conditional and unconditional
+control flow. The conditional jumps query the match status *OK*.
+
+ - __icf_jalways__ *branchlabel*
+
+ This instruction sets the program counter *PC* to the address specified by
+ *branchlabel* and then continues execution from there. This is an
+ unconditional jump.
+
+ - __icf_jok__ *branchlabel*
+
+ This instruction sets the program counter *PC* to the address specified by
+ *branchlabel*. This happens if, and only if the match status *OK* indicates
+ a success. Otherwise it simply continues execution at the next instruction.
+ This is a conditional jump.
+
+ - __icf_jfail__ *branchlabel*
+
+ This instruction sets the program counter *PC* to the address specified by
+ *branchlabel*. This happens if, and only if the match status *OK* indicates
+ a failure. Otherwise it simply continues execution at the next instruction.
+ This is a conditional jump.
+
+ - __icf_halt__
+
+ This instruction halts the machine and blocks any further execution.
+
+## INPUT LOCATION HANDLING
+
+The instructions in this section are for backtracking, they manipulate the
+current location *CL* of the machine state. They allow a user of the machine to
+query and save locations in the input, and to rewind the current location *CL*
+to saved locations, making them one of the components enabling the
+implementation of backtracking parsers.
+
+ - __icl_push__
+
+ This instruction pushes a copy of the current location *CL* on the location
+ stack *LS*.
+
+ - __icl_rewind__
+
+ This instruction pops an entry from the location stack *LS* and then moves
+ the current location *CL* back to this point in the input.
+
+ - __icl_pop__
+
+ This instruction pops an entry from the location stack *LS* and discards it.
+
+## ERROR HANDLING
+
+The instructions in this section provide read and write access to the error
+status *ER* of the machine.
+
+ - __ier_push__
+
+ This instruction pushes a copy of the current error status *ER* on the error
+ stack *ES*.
+
+ - __ier_clear__
+
+ This instruction clears the error status *ER*.
+
+ - __ier_nonterminal__ *message*
+
+ This instruction checks if the error status *ER* contains an error whose
+ location is just past the location found in the top entry of the location
+ stack *LS*. Nothing happens if no such error is found. Otherwise the found
+ error is replaced by an error at the location found on the stack, having the
+ message *message*.
+
+ - __ier_merge__
+
+ This instruction pops an entry from the error stack *ES*, merges it with the
+ current error status *ER* and stores the result of the merge as the new
+ error status *ER*.
+
+ The merge is performed as described below:
+
+ If one of the two error states is empty the other is chosen. If neither
+ error state is empty, and refering to different locations, then the error
+ state with the location further in the input is chosen. If both error states
+ refer to the same location their messages are merged (with removing
+ duplicates).
+
+## SEMANTIC VALUES
+
+The instructions in this section manipulate the semantic value *SV*.
+
+ - __isv_clear__
+
+ This instruction clears the semantic value *SV*.
+
+ - __isv_terminal__
+
+ This instruction creates a terminal AST node for the current token *CT*,
+ makes it the semantic value *SV*, and also pushes the node on the AST stack
+ *AS*.
+
+ - __isv_nonterminal_leaf__ *nt*
+
+ This instruction creates a nonterminal AST node without any children for the
+ nonterminal *nt*, and makes it the semantic value *SV*.
+
+ This instruction should be executed if, and only if the match status *OK*
+ indicates a success. In the case of a failure __isv_clear__ should be
+ called.
+
+ - __isv_nonterminal_range__ *nt*
+
+ This instruction creates a nonterminal AST node for the nonterminal *nt*,
+ with a single terminal node as its child, and makes this AST the semantic
+ value *SV*. The terminal node refers to the input string from the location
+ found on top of the location stack *LS* to the current location *CL* (both
+ inclusive).
+
+ This instruction should be executed if, and only if the match status *OK*
+ indicates a success. In the case of a failure __isv_clear__ should be
+ called.
+
+ - __isv_nonterminal_reduce__ *nt*
+
+ This instruction creates a nonterminal AST node for the nonterminal *nt* and
+ makes it the semantic value *SV*.
+
+ All entries on the AST stack *AS* above the marker found in the top entry of
+ the AST Marker stack *MS* become children of the new node, with the entry at
+ the stack top becoming the rightmost child. If the AST Marker stack *MS* is
+ empty the whole stack is used. The AST marker stack *MS* is left unchanged.
+
+ This instruction should be executed if, and only if the match status *OK*
+ indicates a success. In the case of a failure __isv_clear__ should be
+ called.
+
+## AST STACK HANDLING
+
+The instructions in this section manipulate the AST stack *AS*, and the AST
+Marker stack *MS*.
+
+ - __ias_push__
+
+ This instruction pushes the semantic value *SV* on the AST stack *AS*.
+
+ - __ias_mark__
+
+ This instruction pushes a marker for the current state of the AST stack *AS*
+ on the AST Marker stack *MS*.
+
+ - __ias_mrewind__
+
+ This instruction pops an entry from the AST Marker stack *MS* and then
+ proceeds to pop entries from the AST stack *AS* until the state represented
+ by the popped marker has been reached again. Nothing is done if the AST
+ stack *AS* is already smaller than indicated by the popped marker.
+
+ - __ias_mpop__
+
+ This instruction pops an entry from the AST Marker stack *MS* and discards
+ it.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_me* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_peg/peg.md
Index: embedded/md/tcllib/files/modules/grammar_peg/peg.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_peg/peg.md
@@ -0,0 +1,561 @@
+
+[//000000001]: # (grammar::peg - Grammar operations and usage)
+[//000000002]: # (Generated from file 'peg.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::peg(n) 0.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::peg - Create and manipulate parsing expression grammars
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [TERMS & CONCEPTS](#subsection1)
+
+ - [CONTAINER CLASS API](#subsection2)
+
+ - [CONTAINER OBJECT API](#subsection3)
+
+ - [PARSING EXPRESSIONS](#subsection4)
+
+ - [PARSING EXPRESSION GRAMMARS](#section2)
+
+ - [REFERENCES](#section3)
+
+ - [Bugs, Ideas, Feedback](#section4)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require snit
+package require grammar::peg ?0.1?
+
+[__::grammar::peg__ *pegName* ?__=__|__:=__|__<--__|__as__|__deserialize__ *src*?](#1)
+[*pegName* __destroy__](#2)
+[*pegName* __clear__](#3)
+[*pegName* __=__ *srcPEG*](#4)
+[*pegName* __-->__ *dstPEG*](#5)
+[*pegName* __serialize__](#6)
+[*pegName* __deserialize__ *serialization*](#7)
+[*pegName* __is valid__](#8)
+[*pegName* __start__ ?*pe*?](#9)
+[*pegName* __nonterminals__](#10)
+[*pegName* __nonterminal add__ *nt* *pe*](#11)
+[*pegName* __nonterminal delete__ *nt1* ?*nt2* ...?](#12)
+[*pegName* __nonterminal exists__ *nt*](#13)
+[*pegName* __nonterminal rename__ *nt* *ntnew*](#14)
+[*pegName* __nonterminal mode__ *nt* ?*mode*?](#15)
+[*pegName* __nonterminal rule__ *nt*](#16)
+[*pegName* __unknown nonterminals__](#17)
+
+# DESCRIPTION
+
+This package provides a container class for *parsing expression grammars*
+(Short: PEG). It allows the incremental definition of the grammar, its
+manipulation and querying of the definition. The package neither provides
+complex operations on the grammar, nor has it the ability to execute a grammar
+definition for a stream of symbols. Two packages related to this one are
+__grammar::mengine__ and __grammar::peg::interpreter__. The first of them
+defines a general virtual machine for the matching of a character stream, and
+the second implements an interpreter for parsing expression grammars on top of
+that virtual machine.
+
+## TERMS & CONCEPTS
+
+PEGs are similar to context-free grammars, but not equivalent; in some cases
+PEGs are strictly more powerful than context-free grammars (there exist PEGs for
+some non-context-free languages). The formal mathematical definition of parsing
+expressions and parsing expression grammars can be found in section [PARSING
+EXPRESSION GRAMMARS](#section2).
+
+In short, we have *terminal symbols*, which are the most basic building blocks
+for *sentences*, and *nonterminal symbols* with associated *parsing
+expressions*, defining the grammatical structure of the sentences. The two sets
+of symbols are distinctive, and do not overlap. When speaking about symbols the
+word "symbol" is often left out. The union of the sets of terminal and
+nonterminal symbols is called the set of *symbols*.
+
+Here the set of *terminal symbols* is not explicitly managed, but implicitly
+defined as the set of all characters. Note that this means that we inherit from
+Tcl the ability to handle all of Unicode.
+
+A pair of *nonterminal* and *[parsing
+expression](../../../../index.md#parsing_expression)* is also called a
+*grammatical rule*, or *rule* for short. In the context of a rule the
+nonterminal is often called the left-hand-side (LHS), and the parsing expression
+the right-hand-side (RHS).
+
+The *start expression* of a grammar is a parsing expression from which all the
+sentences contained in the language specified by the grammar are *derived*. To
+make the understanding of this term easier let us assume for a moment that the
+RHS of each rule, and the start expression, is either a sequence of symbols, or
+a series of alternate parsing expressions. In the latter case the rule can be
+seen as a set of rules, each providing one alternative for the nonterminal. A
+parsing expression A' is now a derivation of a parsing expression A if we pick
+one of the nonterminals N in the expression, and one of the alternative rules R
+for N, and then replace the nonterminal in A with the RHS of the chosen rule.
+Here we can see why the terminal symbols are called such. They cannot be
+expanded any further, thus terminate the process of deriving new expressions. An
+example
+
+ Rules
+ (1) A <- a B c
+ (2a) B <- d B
+ (2b) B <- e
+
+ Some derivations, using starting expression A.
+
+ A -/1/-> a B c -/2a/-> a d B c -/2b/-> a d e c
+
+A derived expression containing only terminal symbols is a *sentence*. The set
+of all sentences which can be derived from the start expression is the
+*language* of the grammar.
+
+Some definitions for nonterminals and expressions:
+
+ 1. A nonterminal A is called *reachable* if it is possible to derive a parsing
+ expression from the start expression which contains A.
+
+ 1. A nonterminal A is called *useful* if it is possible to derive a sentence
+ from it.
+
+ 1. A nonterminal A is called *recursive* if it is possible to derive a parsing
+ expression from it which contains A, again.
+
+ 1. The *FIRST set* of a nonterminal A contains all the symbols which can occur
+ of as the leftmost symbol in a parsing expression derived from A. If the
+ FIRST set contains A itself then that nonterminal is called
+ *left-recursive*.
+
+ 1. The *LAST set* of a nonterminal A contains all the symbols which can occur
+ of as the rightmost symbol in a parsing expression derived from A. If the
+ LAST set contains A itself then that nonterminal is called
+ *right-recursive*.
+
+ 1. The *FOLLOW set* of a nonterminal A contains all the symbols which can
+ occur after A in a parsing expression derived from the start expression.
+
+ 1. A nonterminal (or parsing expression) is called *nullable* if the empty
+ sentence can be derived from it.
+
+And based on the above definitions for grammars:
+
+ 1. A grammar G is *recursive* if and only if it contains a nonterminal A which
+ is recursive. The terms *left-* and *right-recursive*, and *useful* are
+ analogously defined.
+
+ 1. A grammar is *minimal* if it contains only *reachable* and *useful*
+ nonterminals.
+
+ 1. A grammar is *wellformed* if it is not left-recursive. Such grammars are
+ also *complete*, which means that they always succeed or fail on all input
+ sentences. For an incomplete grammar on the other hand input sentences
+ exist for which an attempt to match them against the grammar will not
+ terminate.
+
+ 1. As we wish to allow ourselves to build a grammar incrementally in a
+ container object we will encounter stages where the RHS of one or more
+ rules reference symbols which are not yet known to the container. Such a
+ grammar we call *invalid*. We cannot use the term *incomplete* as this term
+ is already taken, see the last item.
+
+## CONTAINER CLASS API
+
+The package exports the API described here.
+
+ - __::grammar::peg__ *pegName* ?__=__|__:=__|__<--__|__as__|__deserialize__ *src*?
+
+ The command creates a new container object for a parsing expression grammar
+ and returns the fully qualified name of the object command as its result.
+ The API the returned command is following is described in the section
+ [CONTAINER OBJECT API](#subsection3). It may be used to invoke various
+ operations on the container and the grammar within.
+
+ The new container, i.e. grammar will be empty if no *src* is specified.
+ Otherwise it will contain a copy of the grammar contained in the *src*. The
+ *src* has to be a container object reference for all operators except
+ __deserialize__. The __deserialize__ operator requires *src* to be the
+ serialization of a parsing expression grammar instead.
+
+ An empty grammar has no nonterminal symbols, and the start expression is the
+ empty expression, i.e. epsilon. It is *valid*, but not *useful*.
+
+## CONTAINER OBJECT API
+
+All grammar container objects provide the following methods for the manipulation
+of their contents:
+
+ - *pegName* __destroy__
+
+ Destroys the grammar, including its storage space and associated command.
+
+ - *pegName* __clear__
+
+ Clears out the definition of the grammar contained in *pegName*, but does
+ *not* destroy the object.
+
+ - *pegName* __=__ *srcPEG*
+
+ Assigns the contents of the grammar contained in *srcPEG* to *pegName*,
+ overwriting any existing definition. This is the assignment operator for
+ grammars. It copies the grammar contained in the grammar object *srcPEG*
+ over the grammar definition in *pegName*. The old contents of *pegName* are
+ deleted by this operation.
+
+ This operation is in effect equivalent to
+
+ *pegName* __deserialize__ [*srcPEG* __serialize__]
+
+ - *pegName* __-->__ *dstPEG*
+
+ This is the reverse assignment operator for grammars. It copies the
+ automation contained in the object *pegName* over the grammar definition in
+ the object *dstPEG*. The old contents of *dstPEG* are deleted by this
+ operation.
+
+ This operation is in effect equivalent to
+
+ *dstPEG* __deserialize__ [*pegName* __serialize__]
+
+ - *pegName* __serialize__
+
+ This method serializes the grammar stored in *pegName*. In other words it
+ returns a tcl *value* completely describing that grammar. This allows, for
+ example, the transfer of grammars over arbitrary channels, persistence, etc.
+ This method is also the basis for both the copy constructor and the
+ assignment operator.
+
+ The result of this method has to be semantically identical over all
+ implementations of the __grammar::peg__ interface. This is what will enable
+ us to copy grammars between different implementations of the same interface.
+
+ The result is a list of four elements with the following structure:
+
+ The constant string __grammar::peg__.
+
+ A dictionary. Its keys are the names of all known nonterminal symbols, and
+ their associated values are the parsing expressions describing their
+ sentennial structure.
+
+ A dictionary. Its keys are the names of all known nonterminal symbols, and
+ their associated values hints to a matcher regarding the semantic values
+ produced by the symbol.
+
+ The last item is a parsing expression, the *start expression* of the
+ grammar.
+
+ Assuming the following PEG for simple mathematical expressions
+
+ Digit <- '0'/'1'/'2'/'3'/'4'/'5'/'6'/'7'/'8'/'9'
+ Sign <- '+' / '-'
+ Number <- Sign? Digit+
+ Expression <- '(' Expression ')' / (Factor (MulOp Factor)*)
+ MulOp <- '*' / '/'
+ Factor <- Term (AddOp Term)*
+ AddOp <- '+'/'-'
+ Term <- Number
+
+ a possible serialization is
+
+ grammar::peg \\
+ {Expression {/ {x ( Expression )} {x Factor {* {x MulOp Factor}}}} \\
+ Factor {x Term {* {x AddOp Term}}} \\
+ Term Number \\
+ MulOp {/ * /} \\
+ AddOp {/ + -} \\
+ Number {x {? Sign} {+ Digit}} \\
+ Sign {/ + -} \\
+ Digit {/ 0 1 2 3 4 5 6 7 8 9} \\
+ } \\
+ {Expression value Factor value \\
+ Term value MulOp value \\
+ AddOp value Number value \\
+ Sign value Digit value \\
+ }
+ Expression
+
+ A possible one, because the order of the nonterminals in the dictionary is
+ not relevant.
+
+ - *pegName* __deserialize__ *serialization*
+
+ This is the complement to __serialize__. It replaces the grammar definition
+ in *pegName* with the grammar described by the *serialization* value. The
+ old contents of *pegName* are deleted by this operation.
+
+ - *pegName* __is valid__
+
+ A predicate. It tests whether the PEG in *pegName* is *valid*. See section
+ [TERMS & CONCEPTS](#subsection1) for the definition of this grammar
+ property. The result is a boolean value. It will be set to __true__ if the
+ PEG has the tested property, and __false__ otherwise.
+
+ - *pegName* __start__ ?*pe*?
+
+ This method defines the *start expression* of the grammar. It replaces the
+ previously defined start expression with the parsing expression *pe*. The
+ method fails and throws an error if *pe* does not contain a valid parsing
+ expression as specified in the section [PARSING EXPRESSIONS](#subsection4).
+ In that case the existing start expression is not changed. The method
+ returns the empty string as its result.
+
+ If the method is called without an argument it will return the currently
+ defined start expression.
+
+ - *pegName* __nonterminals__
+
+ Returns the set of all nonterminal symbols known to the grammar.
+
+ - *pegName* __nonterminal add__ *nt* *pe*
+
+ This method adds the nonterminal *nt* and its associated parsing expression
+ *pe* to the set of nonterminal symbols and rules of the PEG contained in the
+ object *pegName*. The method fails and throws an error if either the string
+ *nt* is already known as a symbol of the grammar, or if *pe* does not
+ contain a valid parsing expression as specified in the section [PARSING
+ EXPRESSIONS](#subsection4). In that case the current set of nonterminal
+ symbols and rules is not changed. The method returns the empty string as its
+ result.
+
+ - *pegName* __nonterminal delete__ *nt1* ?*nt2* ...?
+
+ This method removes the named symbols *nt1*, *nt2* from the set of
+ nonterminal symbols of the PEG contained in the object *pegName*. The method
+ fails and throws an error if any of the strings is not known as a
+ nonterminal symbol. In that case the current set of nonterminal symbols is
+ not changed. The method returns the empty string as its result.
+
+ The stored grammar becomes invalid if the deleted nonterminals are
+ referenced by the RHS of still-known rules.
+
+ - *pegName* __nonterminal exists__ *nt*
+
+ A predicate. It tests whether the nonterminal symbol *nt* is known to the
+ PEG in *pegName*. The result is a boolean value. It will be set to __true__
+ if the symbol *nt* is known, and __false__ otherwise.
+
+ - *pegName* __nonterminal rename__ *nt* *ntnew*
+
+ This method renames the nonterminal symbol *nt* to *ntnew*. The method fails
+ and throws an error if either *nt* is not known as a nonterminal, or if
+ *ntnew* is a known symbol. The method returns the empty string as its
+ result.
+
+ - *pegName* __nonterminal mode__ *nt* ?*mode*?
+
+ This mode returns or sets the semantic mode associated with the nonterminal
+ symbol *nt*. If no *mode* is specified the current mode of the nonterminal
+ is returned. Otherwise the current mode is set to *mode*. The method fails
+ and throws an error if *nt* is not known as a nonterminal. The grammar
+ interpreter implemented by the package __grammar::peg::interpreter__
+ recognizes the following modes:
+
+ * value
+
+ The semantic value of the nonterminal is the abstract syntax tree
+ created from the AST's of the RHS and a node for the nonterminal itself.
+
+ * match
+
+ The semantic value of the nonterminal is an the abstract syntax tree
+ consisting of single a node for the string matched by the RHS. The ASTs
+ generated by the RHS are discarded.
+
+ * leaf
+
+ The semantic value of the nonterminal is an the abstract syntax tree
+ consisting of single a node for the nonterminal itself. The ASTs
+ generated by the RHS are discarded.
+
+ * discard
+
+ The nonterminal has no semantic value. The ASTs generated by the RHS are
+ discarded (as well).
+
+ - *pegName* __nonterminal rule__ *nt*
+
+ This method returns the parsing expression associated with the nonterminal
+ *nt*. The method fails and throws an error if *nt* is not known as a
+ nonterminal.
+
+ - *pegName* __unknown nonterminals__
+
+ This method returns a list containing the names of all nonterminal symbols
+ which are referenced on the RHS of a grammatical rule, but have no rule
+ definining their structure. In other words, a list of the nonterminal
+ symbols which make the grammar invalid. The grammar is valid if this list is
+ empty.
+
+## PARSING EXPRESSIONS
+
+Various methods of PEG container objects expect a parsing expression as their
+argument, or will return such. This section specifies the format such parsing
+expressions are in.
+
+ 1. The string __epsilon__ is an atomic parsing expression. It matches the
+ empty string.
+
+ 1. The string __alnum__ is an atomic parsing expression. It matches any
+ alphanumeric character.
+
+ 1. The string __alpha__ is an atomic parsing expression. It matches any
+ alphabetical character.
+
+ 1. The string __dot__ is an atomic parsing expression. It matches any
+ character.
+
+ 1. The expression [list t __x__] is an atomic parsing expression. It matches
+ the terminal string __x__.
+
+ 1. The expression [list n __A__] is an atomic parsing expression. It matches
+ the nonterminal __A__.
+
+ 1. For parsing expressions __e1__, __e2__, ... the result of [list / __e1__
+ __e2__ ... ] is a parsing expression as well. This is the *ordered choice*,
+ aka *prioritized choice*.
+
+ 1. For parsing expressions __e1__, __e2__, ... the result of [list x __e1__
+ __e2__ ... ] is a parsing expression as well. This is the *sequence*.
+
+ 1. For a parsing expression __e__ the result of [list * __e__] is a parsing
+ expression as well. This is the *kleene closure*, describing zero or more
+ repetitions.
+
+ 1. For a parsing expression __e__ the result of [list + __e__] is a parsing
+ expression as well. This is the *positive kleene closure*, describing one
+ or more repetitions.
+
+ 1. For a parsing expression __e__ the result of [list & __e__] is a parsing
+ expression as well. This is the *and lookahead predicate*.
+
+ 1. For a parsing expression __e__ the result of [list ! __e__] is a parsing
+ expression as well. This is the *not lookahead predicate*.
+
+ 1. For a parsing expression __e__ the result of [list ? __e__] is a parsing
+ expression as well. This is the *optional input*.
+
+Examples of parsing expressions where already shown, in the description of the
+method __serialize__.
+
+# PARSING EXPRESSION GRAMMARS
+
+For the mathematically inclined, a PEG is a 4-tuple (VN,VT,R,eS) where
+
+ - VN is a set of *nonterminal symbols*,
+
+ - VT is a set of *terminal symbols*,
+
+ - R is a finite set of rules, where each rule is a pair (A,e), A in VN, and
+ *[e](../../../../index.md#e)* a *[parsing
+ expression](../../../../index.md#parsing_expression)*.
+
+ - eS is a parsing expression, the *start expression*.
+
+Further constraints are
+
+ - The intersection of VN and VT is empty.
+
+ - For all A in VT exists exactly one pair (A,e) in R. In other words, R is a
+ function from nonterminal symbols to parsing expressions.
+
+Parsing expression are inductively defined via
+
+ - The empty string (epsilon) is a parsing expression.
+
+ - A terminal symbol *a* is a parsing expression.
+
+ - A nonterminal symbol *A* is a parsing expression.
+
+ - *e1**e2* is a parsing expression for parsing expressions *e1* and *2*. This
+ is called *sequence*.
+
+ - *e1*/*e2* is a parsing expression for parsing expressions *e1* and *2*. This
+ is called *ordered choice*.
+
+ - *[e](../../../../index.md#e)** is a parsing expression for parsing
+ expression *[e](../../../../index.md#e)*. This is called *zero-or-more
+ repetitions*, also known as *kleene closure*.
+
+ - *[e](../../../../index.md#e)*+ is a parsing expression for parsing
+ expression *[e](../../../../index.md#e)*. This is called *one-or-more
+ repetitions*, also known as *positive kleene closure*.
+
+ - !*[e](../../../../index.md#e)* is a parsing expression for parsing
+ expression *e1*. This is called a *not lookahead predicate*.
+
+ - &*[e](../../../../index.md#e)* is a parsing expression for parsing
+ expression *e1*. This is called an *and lookahead predicate*.
+
+PEGs are used to define a grammatical structure for streams of symbols over VT.
+They are a modern phrasing of older formalisms invented by Alexander Birham.
+These formalisms were called TS (TMG recognition scheme), and gTS (generalized
+TS). Later they were renamed to TPDL (Top-Down Parsing Languages) and gTPDL
+(generalized TPDL).
+
+They can be easily implemented by recursive descent parsers with backtracking.
+This makes them relatives of LL(k) Context-Free Grammars.
+
+# REFERENCES
+
+ 1. [The Packrat Parsing and Parsing Expression Grammars
+ Page](http://www.pdos.lcs.mit.edu/~baford/packrat/), by Bryan Ford,
+ Massachusetts Institute of Technology. This is the main entry page to PEGs,
+ and their realization through Packrat Parsers.
+
+ 1. [Parsing Techniques - A Practical Guide
+ ](http://www.cs.vu.nl/~dick/PTAPG.html), an online book offering a clear,
+ accessible, and thorough discussion of many different parsing techniques
+ with their interrelations and applicabilities, including error recovery
+ techniques.
+
+ 1. [Compilers and Compiler Generators](http://scifac.ru.ac.za/compilers/), an
+ online book using CoCo/R, a generator for recursive descent parsers.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_peg* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[LL(k)](../../../../index.md#ll_k_), [TDPL](../../../../index.md#tdpl),
+[context-free languages](../../../../index.md#context_free_languages),
+[expression](../../../../index.md#expression),
+[grammar](../../../../index.md#grammar),
+[parsing](../../../../index.md#parsing), [parsing
+expression](../../../../index.md#parsing_expression), [parsing expression
+grammar](../../../../index.md#parsing_expression_grammar), [push down
+automaton](../../../../index.md#push_down_automaton), [recursive
+descent](../../../../index.md#recursive_descent),
+[state](../../../../index.md#state), [top-down parsing
+languages](../../../../index.md#top_down_parsing_languages),
+[transducer](../../../../index.md#transducer)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/grammar_peg/peg_interp.md
Index: embedded/md/tcllib/files/modules/grammar_peg/peg_interp.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/grammar_peg/peg_interp.md
@@ -0,0 +1,138 @@
+
+[//000000001]: # (grammar::peg::interp - Grammar operations and usage)
+[//000000002]: # (Generated from file 'peg_interp.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (grammar::peg::interp(n) 0.1.1 tcllib "Grammar operations and usage")
+
+# NAME
+
+grammar::peg::interp - Interpreter for parsing expression grammars
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [THE INTERPRETER API](#section2)
+
+ - [Bugs, Ideas, Feedback](#section3)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.4
+package require grammar::mengine ?0.1?
+package require grammar::peg::interp ?0.1.1?
+
+[__::grammar::peg::interp::setup__ *peg*](#1)
+[__::grammar::peg::interp::parse__ *nextcmd* *errorvar* *astvar*](#2)
+
+# DESCRIPTION
+
+This package provides commands for the controlled matching of a character stream
+via a parsing expression grammar and the creation of an abstract syntax tree for
+the stream and partials.
+
+It is built on top of the virtual machine provided by the package
+__[grammar::me::tcl](../grammar_me/me_tcl.md)__ and directly interprets the
+parsing expression grammar given to it. In other words, the grammar is *not*
+pre-compiled but used as is.
+
+The grammar to be interpreted is taken from a container object following the
+interface specified by the package __grammar::peg::container__. Only the
+relevant parts are copied into the state of this package.
+
+It should be noted that the package provides exactly one instance of the
+interpreter, and interpreting a second grammar requires the user to either abort
+or complete a running interpretation, or to put them into different Tcl
+interpreters.
+
+Also of note is that the implementation assumes a pull-type handling of the
+input. In other words, the interpreter pulls characters from the input stream as
+it needs them. For usage in a push environment, i.e. where the environment
+pushes new characters as they come we have to put the engine into its own
+thread.
+
+# THE INTERPRETER API
+
+The package exports the following API
+
+ - __::grammar::peg::interp::setup__ *peg*
+
+ This command (re)initializes the interpreter. It returns the empty string.
+ This command has to be invoked first, before any matching run.
+
+ Its argument *peg* is the handle of an object containing the parsing
+ expression grammar to interpret. This grammar has to be valid, or an error
+ will be thrown.
+
+ - __::grammar::peg::interp::parse__ *nextcmd* *errorvar* *astvar*
+
+ This command interprets the loaded grammar and tries to match it against the
+ stream of characters represented by the command prefix *nextcmd*.
+
+ The command prefix *nextcmd* represents the input stream of characters and
+ is invoked by the interpreter whenever the a new character from the stream
+ is required. The callback has to return either the empty list, or a list of
+ 4 elements containing the token, its lexeme attribute, and its location as
+ line number and column index, in this order. The empty list is the signal
+ that the end of the input stream has been reached. The lexeme attribute is
+ stored in the terminal cache, but otherwise not used by the machine.
+
+ The result of the command is a boolean value indicating whether the matching
+ process was successful (__true__), or not (__false__). In the case of a
+ match failure error information will be stored into the variable referenced
+ by *errorvar*. The variable referenced by *astvar* will always contain the
+ generated abstract syntax tree, however in the case of an error it will be
+ only partial and possibly malformed.
+
+ The abstract syntax tree is represented by a nested list, as described in
+ section __AST VALUES__ of document
+ *[grammar::me_ast](../grammar_me/me_ast.md)*.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *grammar_peg* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# KEYWORDS
+
+[LL(k)](../../../../index.md#ll_k_), [TDPL](../../../../index.md#tdpl),
+[context-free languages](../../../../index.md#context_free_languages),
+[expression](../../../../index.md#expression),
+[grammar](../../../../index.md#grammar),
+[matching](../../../../index.md#matching),
+[parsing](../../../../index.md#parsing), [parsing
+expression](../../../../index.md#parsing_expression), [parsing expression
+grammar](../../../../index.md#parsing_expression_grammar), [push down
+automaton](../../../../index.md#push_down_automaton), [recursive
+descent](../../../../index.md#recursive_descent),
+[state](../../../../index.md#state), [top-down parsing
+languages](../../../../index.md#top_down_parsing_languages),
+[transducer](../../../../index.md#transducer), [virtual
+machine](../../../../index.md#virtual_machine)
+
+# CATEGORY
+
+Grammars and finite automata
+
+# COPYRIGHT
+
+Copyright © 2005-2011 Andreas Kupries
ADDED embedded/md/tcllib/files/modules/hook/hook.md
Index: embedded/md/tcllib/files/modules/hook/hook.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/hook/hook.md
@@ -0,0 +1,360 @@
+
+[//000000001]: # (hook - Hooks)
+[//000000002]: # (Generated from file 'hook.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (hook(n) 0.1 tcllib "Hooks")
+
+# NAME
+
+hook - Hooks
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Concepts](#section2)
+
+ - [Introduction](#subsection1)
+
+ - [Bindings](#subsection2)
+
+ - [Subjects and observers](#subsection3)
+
+ - [Reference](#section3)
+
+ - [Example](#section4)
+
+ - [Credits](#section5)
+
+ - [Bugs, Ideas, Feedback](#section6)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require hook ?0.1?
+
+[__hook__ __bind__ ?*subject*? ?*hook*? ?*observer*? ?*cmdPrefix*?](#1)
+[__hook__ __call__ *subject* *hook* ?*args*...?](#2)
+[__hook__ __forget__ *object*](#3)
+[__hook__ __cget__ *option*](#4)
+[__hook__ __configure__ __option__ *value* ...](#5)
+
+# DESCRIPTION
+
+This package provides the __hook__ ensemble command, which implements the
+Subject/Observer pattern. It allows *subjects*, which may be *modules*,
+*objects*, *widgets*, and so forth, to synchronously call *hooks* which may be
+bound to an arbitrary number of subscribers, called *observers*. A subject may
+call any number of distinct hooks, and any number of observers can bind
+callbacks to a particular hook called by a particular subject. Hook bindings can
+be queried and deleted.
+
+This man page is intended to be a reference only.
+
+# Concepts
+
+## Introduction
+
+Tcl modules usually send notifications to other modules in two ways: via Tk
+events, and via callback options like the text widget's __-yscrollcommand__
+option. Tk events are available only in Tk, and callback options require tight
+coupling between the modules sending and receiving the notification.
+
+Loose coupling between sender and receiver is often desirable, however. In
+Model/View/Controller terms, a View can send a command (stemming from user
+input) to the Controller, which updates the Model. The Model can then call a
+hook *to which all relevant Views subscribe.* The Model is decoupled from the
+Views, and indeed need not know whether any Views actually exist. At present,
+Tcl/Tk has no standard mechanism for implementing loose coupling of this kind.
+This package defines a new command, __hook__, which implements just such a
+mechanism.
+
+## Bindings
+
+The __hook__ command manages a collection of hook bindings. A hook binding has
+four elements:
+
+ 1. A *[subject](../../../../index.md#subject)*: the name of the entity that
+ will be calling the hook.
+
+ 1. The *[hook](../../../../index.md#hook)* itself. A hook usually reflects
+ some occurrence in the life of the
+ *[subject](../../../../index.md#subject)* that other entities might care to
+ know about. A *[hook](../../../../index.md#hook)* has a name, and may also
+ have arguments. Hook names are arbitrary strings. Each
+ *[subject](../../../../index.md#subject)* must document the names and
+ arguments of the hooks it can call.
+
+ 1. The name of the *[observer](../../../../index.md#observer)* that wishes to
+ receive the *[hook](../../../../index.md#hook)* from the
+ *[subject](../../../../index.md#subject)*.
+
+ 1. A command prefix to which the *[hook](../../../../index.md#hook)* arguments
+ will be appended when the binding is executed.
+
+## Subjects and observers
+
+For convenience, this document collectively refers to subjects and observers as
+*objects*, while placing no requirements on how these *objects* are actually
+implemented. An object can be a __[TclOO](../../../../index.md#tcloo)__ or
+__[Snit](../../../../index.md#snit)__ or __XOTcl__ object, a Tcl command, a
+namespace, a module, a pseudo-object managed by some other object (as tags are
+managed by the Tk text widget) or simply a well-known name.
+
+Subject and observer names are arbitrary strings; however, as __hook__ might be
+used at the package level, it's necessary to have conventions that avoid name
+collisions between packages written by different people.
+
+Therefore, any subject or observer name used in core or package level code
+should look like a Tcl command name, and should be defined in a namespace owned
+by the package. Consider, for example, an ensemble command __::foo__ that
+creates a set of pseudo-objects and uses __hook__ to send notifications. The
+pseudo-objects have names that are not commands and exist in their own
+namespace, rather like file handles do. To avoid name collisions with subjects
+defined by other packages, users of __hook__, these __::foo__ handles should
+have names like __::foo::1__, __::foo::2__, and so on.
+
+Because object names are arbitrary strings, application code can use whatever
+additional conventions are dictated by the needs of the application.
+
+# Reference
+
+Hook provides the following commands:
+
+ - __hook__ __bind__ ?*subject*? ?*hook*? ?*observer*? ?*cmdPrefix*?
+
+ This subcommand is used to create, update, delete, and query hook bindings.
+
+ Called with no arguments it returns a list of the subjects with hooks to
+ which observers are currently bound.
+
+ Called with one argument, a *subject*, it returns a list of the subject's
+ hooks to which observers are currently bound.
+
+ Called with two arguments, a *subject* and a *hook*, it returns a list of
+ the observers which are currently bound to this *subject* and *hook*.
+
+ Called with three arguments, a *subject*, a *hook*, and an *observer*, it
+ returns the binding proper, the command prefix to be called when the hook is
+ called, or the empty string if there is no such binding.
+
+ Called with four arguments, it creates, updates, or deletes a binding. If
+ *cmdPrefix* is the empty string, it deletes any existing binding for the
+ *subject*, *hook*, and *observer*; nothing is returned. Otherwise,
+ *cmdPrefix* must be a command prefix taking as many additional arguments as
+ are documented for the *subject* and *hook*. The binding is added or
+ updated, and the observer is returned.
+
+ If the *observer* is the empty string, "", it will create a new binding
+ using an automatically generated observer name of the form
+ __::hook::ob__<__number__>. The automatically generated name will be
+ returned, and can be used to query, update, and delete the binding as usual.
+ If automated observer names are always used, the observer name effectively
+ becomes a unique binding ID.
+
+ It is possible to call __hook bind__ to create or delete a binding to a
+ *subject* and *hook* while in an observer binding for that same *subject*
+ and *hook*. The following rules determine what happens when
+
+ hook bind $s $h $o $binding
+
+ is called during the execution of
+
+ hook call $s $h
+
+ No binding is ever called after it is deleted.
+
+ When a binding is called, the most recently given command prefix is always
+ used.
+
+ The set of observers whose bindings are to be called is determined when this
+ method begins to execute, and does not change thereafter, except that
+ deleted bindings are not called.
+
+ In particular:
+
+ If __$o__s binding to __$s__ and __$h__ is deleted, and __$o__s binding has
+ not yet been called during this execution of
+
+ hook call $s $h
+
+ it will not be called. (Note that it might already have been called; and in
+ all likelihood, it is probably deleting itself.)
+
+ If __$o__ changes the command prefix that's bound to __$s__ and __$h__, and
+ if __$o__s binding has not yet been called during this execution of
+
+ hook call $s $h
+
+ the new binding will be called when the time comes. (But again, it is
+ probably __$o__s binding that is is making the change.)
+
+ If a new observer is bound to __$s__ and __$h__, its binding will not be
+ called until the next invocation of
+
+ hook call $s $h
+
+ - __hook__ __call__ *subject* *hook* ?*args*...?
+
+ This command is called when the named *subject* wishes to call the named
+ *hook*. All relevant bindings are called with the specified arguments in the
+ global namespace. Note that the bindings are called synchronously, before
+ the command returns; this allows the *args* to include references to
+ entities that will be cleaned up as soon as the hook has been called.
+
+ The order in which the bindings are called is not guaranteed. If sequence
+ among observers must be preserved, define one observer and have its bindings
+ call the other callbacks directly in the proper sequence.
+
+ Because the __hook__ mechanism is intended to support loose coupling, it is
+ presumed that the *subject* has no knowledge of the observers, nor any
+ expectation regarding return values. This has a number of implications:
+
+ __hook call__ returns the empty string.
+
+ Normal return values from observer bindings are ignored.
+
+ Errors and other exceptional returns propagate normally by default. This
+ will rarely be what is wanted, because the subjects usually have no
+ knowledge of the observers and will therefore have no particular competence
+ at handling their errors. That makes it an application issue, and so
+ applications will usually want to define an __-errorcommand__.
+
+ If the __-errorcommand__ configuration option has a non-empty value, its
+ value will be invoked for all errors and other exceptional returns in
+ observer bindings. See __hook configure__, below, for more information on
+ configuration options.
+
+ - __hook__ __forget__ *object*
+
+ This command deletes any existing bindings in which the named *object*
+ appears as either the *[subject](../../../../index.md#subject)* or the
+ *[observer](../../../../index.md#observer)*. Bindings deleted by this method
+ will never be called again. In particular,
+
+ If an observer is forgotten during a call to __hook call__, any uncalled
+ binding it might have had to the relevant subject and hook will *not* be
+ called subsequently.
+
+ If a subject __$s__ is forgotten during a call to
+
+ hook call $s $h
+
+ then __hook call__ will return as soon as the current binding returns. No
+ further bindings will be called.
+
+ - __hook__ __cget__ *option*
+
+ This command returns the value of one of the __hook__ command's
+ configuration options.
+
+ - __hook__ __configure__ __option__ *value* ...
+
+ This command sets the value of one or more of the __hook__ command's
+ configuration options:
+
+ * __-errorcommand__ *cmdPrefix*
+
+ If the value of this option is the empty string, "", then errors and
+ other exception returns in binding scripts are propagated normally.
+ Otherwise, it must be a command prefix taking three additional
+ arguments:
+
+ a 4-element list {subject hook arglist observer},
+
+ the result string, and
+
+ the return options dictionary.
+
+ Given this information, the __-errorcommand__ can choose to log the
+ error, call __interp bgerror__, delete the errant binding (thus
+ preventing the error from arising a second time) and so forth.
+
+ * __-tracecommand__ *cmdPrefix*
+
+ The option's value should be a command prefix taking four arguments:
+
+ a *[subject](../../../../index.md#subject)*,
+
+ a *[hook](../../../../index.md#hook)*,
+
+ a list of the hook's argument values, and
+
+ a list of *objects* the hook was called for.
+
+ The command will be called for each hook that is called. This allows the
+ application to trace hook execution for debugging purposes.
+
+# Example
+
+The __::model__ module calls the hook in response to commands that
+change the model's data:
+
+ hook call ::model
+
+The __.view__ megawidget displays the model state, and needs to know about model
+updates. Consequently, it subscribes to the ::model's hook.
+
+ hook bind ::model .view [list .view ModelUpdate]
+
+When the __::model__ calls the hook, the __.view__s ModelUpdate subcommand will
+be called.
+
+Later the __.view__ megawidget is destroyed. In its destructor, it tells the
+*[hook](../../../../index.md#hook)* that it no longer exists:
+
+ hook forget .view
+
+All bindings involving __.view__ are deleted.
+
+# Credits
+
+Hook has been designed and implemented by William H. Duquette.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *hook* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[uevent(n)](../uev/uevent.md)
+
+# KEYWORDS
+
+[callback](../../../../index.md#callback), [event](../../../../index.md#event),
+[hook](../../../../index.md#hook), [observer](../../../../index.md#observer),
+[producer](../../../../index.md#producer),
+[publisher](../../../../index.md#publisher),
+[subject](../../../../index.md#subject),
+[subscriber](../../../../index.md#subscriber),
+[uevent](../../../../index.md#uevent)
+
+# CATEGORY
+
+Programming tools
+
+# COPYRIGHT
+
+Copyright © 2010, by William H. Duquette
ADDED embedded/md/tcllib/files/modules/html/html.md
Index: embedded/md/tcllib/files/modules/html/html.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/html/html.md
@@ -0,0 +1,544 @@
+
+[//000000001]: # (html - HTML Generation)
+[//000000002]: # (Generated from file 'html.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (html(n) 1.4.4 tcllib "HTML Generation")
+
+# NAME
+
+html - Procedures to generate HTML structures
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Bugs, Ideas, Feedback](#section2)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.2
+package require html ?1.4.4?
+
+[__::html::author__ *author*](#1)
+[__::html::bodyTag__ *args*](#2)
+[__::html::cell__ *param value* ?*tag*?](#3)
+[__::html::checkbox__ *name value*](#4)
+[__::html::checkSet__ *key sep list*](#5)
+[__::html::checkValue__ *name* ?*value*?](#6)
+[__::html::closeTag__](#7)
+[__::html::default__ *key* ?*param*?](#8)
+[__::html::description__ *description*](#9)
+[__::html::end__](#10)
+[__::html::eval__ *arg* ?*args*?](#11)
+[__::html::extractParam__ *param key* ?*varName*?](#12)
+[__::html::font__ *args*](#13)
+[__::html::for__ *start test next body*](#14)
+[__::html::foreach__ *varlist1 list1* ?*varlist2 list2 ...*? *body*](#15)
+[__::html::formValue__ *name* ?*defvalue*?](#16)
+[__::html::getFormInfo__ *args*](#17)
+[__::html::getTitle__](#18)
+[__::html::h__ *level string* ?*param*?](#19)
+[__::html::h1__ *string* ?*param*?](#20)
+[__::html::h2__ *string* ?*param*?](#21)
+[__::html::h3__ *string* ?*param*?](#22)
+[__::html::h4__ *string* ?*param*?](#23)
+[__::html::h5__ *string* ?*param*?](#24)
+[__::html::h6__ *string* ?*param*?](#25)
+[__::html::hdrRow__ *args*](#26)
+[__::html::head__ *title*](#27)
+[__::html::headTag__ *string*](#28)
+[__::html::html_entities__ *string*](#29)
+[__::html::if__ *expr1 body1* ?__elseif__ *expr2 body2 ...*? ?__else__ *bodyN*?](#30)
+[__::html::init__ ?*list*?](#31)
+[__::html::keywords__ *args*](#32)
+[__::html::mailto__ *email* ?*subject*?](#33)
+[__::html::meta__ *args*](#34)
+[__::html::css__ *href*](#35)
+[__::html::css-clear__](#36)
+[__::html::js__ *href*](#37)
+[__::html::js-clear__](#38)
+[__::html::minorList__ *list* ?*ordered*?](#39)
+[__::html::minorMenu__ *list* ?*sep*?](#40)
+[__::html::nl2br__ *string*](#41)
+[__::html::openTag__ *tag* ?*param*?](#42)
+[__::html::paramRow__ *list* ?*rparam*? ?*cparam*?](#43)
+[__::html::passwordInput__ ?*name*?](#44)
+[__::html::passwordInputRow__ *label* ?*name*?](#45)
+[__::html::quoteFormValue__ *value*](#46)
+[__::html::radioSet__ *key sep list*](#47)
+[__::html::radioValue__ *name value*](#48)
+[__::html::refresh__ *seconds url*](#49)
+[__::html::row__ *args*](#50)
+[__::html::select__ *name param choices* ?*current*?](#51)
+[__::html::selectPlain__ *name param choices* ?*current*?](#52)
+[__::html::set__ *var val*](#53)
+[__::html::submit__ *label* ?*name*?](#54)
+[__::html::tableFromArray__ *arrname* ?*param*? ?*pat*?](#55)
+[__::html::tableFromList__ *querylist* ?*param*?](#56)
+[__::html::textarea__ *name* ?*param*? ?*current*?](#57)
+[__::html::textInput__ *name value args*](#58)
+[__::html::textInputRow__ *label name value args*](#59)
+[__::html::varEmpty__ *name*](#60)
+[__::html::while__ *test body*](#61)
+[__::html::doctype__ *id*](#62)
+
+# DESCRIPTION
+
+The package __html__ provides commands that generate HTML. These commands
+typically return an HTML string as their result. In particular, they do not
+output their result to __stdout__.
+
+The command __::html::init__ should be called early to initialize the module.
+You can also use this procedure to define default values for HTML tag
+parameters.
+
+ - __::html::author__ *author*
+
+ *Side effect only*. Call this before __::html::head__ to define an author
+ for the page. The author is noted in a comment in the HEAD section.
+
+ - __::html::bodyTag__ *args*
+
+ Generate a *body* tag. The tag parameters are taken from *args* or from the
+ body.* attributes define with __::html::init__.
+
+ - __::html::cell__ *param value* ?*tag*?
+
+ Generate a *td* (or *th*) tag, a value, and a closing *td* (or *th*) tag.
+ The tag parameters come from *param* or TD.* attributes defined with
+ __::html::init__. This uses __::html::font__ to insert a standard *font* tag
+ into the table cell. The *tag* argument defaults to "td".
+
+ - __::html::checkbox__ *name value*
+
+ Generate a *[checkbox](../../../../index.md#checkbox)* form element with the
+ specified name and value. This uses __::html::checkValue__.
+
+ - __::html::checkSet__ *key sep list*
+
+ Generate a set of *[checkbox](../../../../index.md#checkbox)* form elements
+ and associated labels. The *list* should contain an alternating list of
+ labels and values. This uses __::html::checkbox__. All the
+ *[checkbox](../../../../index.md#checkbox)* buttons share the same *key* for
+ their name. The *sep* is text used to separate the elements.
+
+ - __::html::checkValue__ *name* ?*value*?
+
+ Generate the "name=*name* value=*value*" for a
+ *[checkbox](../../../../index.md#checkbox)* form element. If the CGI
+ variable *name* has the value *value*, then SELECTED is added to the return
+ value. *value* defaults to "1".
+
+ - __::html::closeTag__
+
+ Pop a tag off the stack created by __::html::openTag__ and generate the
+ corresponding close tag (e.g., ).
+
+ - __::html::default__ *key* ?*param*?
+
+ This procedure is used by __::html::tagParam__ to generate the name, value
+ list of parameters for a tag. The __::html::default__ procedure is used to
+ generate default values for those items not already in *param*. If the value
+ identified by *key* matches a value in *param* then this procedure returns
+ the empty string. Otherwise, it returns a "parameter=value" string for a
+ form element identified by *key*. The *key* has the form "tag.parameter"
+ (e.g., body.bgcolor). Use __::html::init__ to register default values.
+ *param* defaults to the empty string.
+
+ - __::html::description__ *description*
+
+ *Side effect only*. Call this before __::html::head__ to define a
+ description *meta* tag for the page. This tag is generated later in the call
+ to __::html::head__.
+
+ - __::html::end__
+
+ Pop all open tags from the stack and generate the corresponding close HTML
+ tags, (e.g., ).
+
+ - __::html::eval__ *arg* ?*args*?
+
+ This procedure is similar to the built-in Tcl __eval__ command. The only
+ difference is that it returns "" so it can be called from an HTML template
+ file without appending unwanted results.
+
+ - __::html::extractParam__ *param key* ?*varName*?
+
+ This is a parsing procedure that extracts the value of *key* from *param*,
+ which is a HTML-style "name=quotedvalue" list. *varName* is used as the name
+ of a Tcl variable that is changed to have the value found in the parameters.
+ The function returns 1 if the parameter was found in *param*, otherwise it
+ returns 0. If the *varName* is not specified, then *key* is used as the
+ variable name.
+
+ - __::html::font__ *args*
+
+ Generate a standard *font* tag. The parameters to the tag are taken from
+ *args* and the HTML defaults defined with __::html::init__.
+
+ - __::html::for__ *start test next body*
+
+ This procedure is similar to the built-in Tcl __for__ control structure.
+ Rather than evaluating the body, it returns the subst'ed *body*. Each
+ iteration of the loop causes another string to be concatenated to the result
+ value.
+
+ - __::html::foreach__ *varlist1 list1* ?*varlist2 list2 ...*? *body*
+
+ This procedure is similar to the built-in Tcl
+ __[foreach](../../../../index.md#foreach)__ control structure. Rather than
+ evaluating the body, it returns the subst'ed *body*. Each iteration of the
+ loop causes another string to be concatenated to the result value.
+
+ - __::html::formValue__ *name* ?*defvalue*?
+
+ Return a name and value pair, where the value is initialized from existing
+ CGI data, if any. The result has this form:
+
+ name="fred" value="freds value"
+
+ - __::html::getFormInfo__ *args*
+
+ Generate hidden fields to capture form values. If *args* is empty, then
+ hidden fields are generated for all CGI values. Otherwise args is a list of
+ string match patterns for form element names.
+
+ - __::html::getTitle__
+
+ Return the title string, with out the surrounding *title* tag, set with a
+ previous call to __::html::title__.
+
+ - __::html::h__ *level string* ?*param*?
+
+ Generate a heading (e.g., *h__level__*) tag. The *string* is nested in the
+ heading, and *param* is used for the tag parameters.
+
+ - __::html::h1__ *string* ?*param*?
+
+ Generate an *h1* tag. See __::html::h__.
+
+ - __::html::h2__ *string* ?*param*?
+
+ Generate an *h2* tag. See __::html::h__.
+
+ - __::html::h3__ *string* ?*param*?
+
+ Generate an *h3* tag. See __::html::h__.
+
+ - __::html::h4__ *string* ?*param*?
+
+ Generate an *h4* tag. See __::html::h__.
+
+ - __::html::h5__ *string* ?*param*?
+
+ Generate an *h5* tag. See __::html::h__.
+
+ - __::html::h6__ *string* ?*param*?
+
+ Generate an *h6* tag. See __::html::h__.
+
+ - __::html::hdrRow__ *args*
+
+ Generate a table row, including *tr* and *th* tags. Each value in *args* is
+ place into its own table cell. This uses __::html::cell__.
+
+ - __::html::head__ *title*
+
+ Generate the *head* section that includes the page *title*. If previous
+ calls have been made to __::html::author__, __::html::keywords__,
+ __::html::description__, or __::html::meta__ then additional tags are
+ inserted into the *head* section. This leaves an open
+ *[html](../../../../index.md#html)* tag pushed on the stack with
+ __::html::openTag__.
+
+ - __::html::headTag__ *string*
+
+ Save a tag for inclusion in the *head* section generated by
+ __::html::head__. The *string* is everything in the tag except the enclosing
+ angle brackets, < >.
+
+ - __::html::html_entities__ *string*
+
+ This command replaces all special characters in the *string* with their HTML
+ entities and returns the modified text.
+
+ - __::html::if__ *expr1 body1* ?__elseif__ *expr2 body2 ...*? ?__else__ *bodyN*?
+
+ This procedure is similar to the built-in Tcl __if__ control structure.
+ Rather than evaluating the body of the branch that is taken, it returns the
+ subst'ed *body*. Note that the syntax is slightly more restrictive than that
+ of the built-in Tcl __if__ control structure.
+
+ - __::html::init__ ?*list*?
+
+ __::html::init__ accepts a Tcl-style name-value list that defines values for
+ items with a name of the form "tag.parameter". For example, a default with
+ key "body.bgcolor" defines the background color for the *body* tag.
+
+ - __::html::keywords__ *args*
+
+ *Side effect only*. Call this before __::html::head__ to define a keyword
+ *meta* tag for the page. The *meta* tag is included in the result of
+ __::html::head__.
+
+ - __::html::mailto__ *email* ?*subject*?
+
+ Generate a hypertext link to a mailto: URL.
+
+ - __::html::meta__ *args*
+
+ *Side effect only*. Call this before __::html::head__ to define a *meta* tag
+ for the page. The *args* is a Tcl-style name, value list that is used for
+ the name= and value= parameters for the *meta* tag. The *meta* tag is
+ included in the result of __::html::head__.
+
+ - __::html::css__ *href*
+
+ *Side effect only*. Call this before __::html::head__ to define a *link* tag
+ for a linked CSS document. The *href* value is a HTTP URL to a CSS document.
+ The *link* tag is included in the result of __::html::head__.
+
+ Multiple calls of this command are allowed, enabling the use of multiple CSS
+ document references. In other words, the arguments of multiple calls are
+ accumulated, and do not overwrite each other.
+
+ - __::html::css-clear__
+
+ *Side effect only*. Call this before __::html::head__ to clear all links to
+ CSS documents.
+
+ Multiple calls of this command are allowed, doing nothing after the first of
+ a sequence with no intervening __::html::css__.
+
+ - __::html::js__ *href*
+
+ *Side effect only*. Call this before __::html::head__ to define a *script*
+ tag for a linked JavaScript document. The *href* is a HTTP URL to a
+ JavaScript document. The *script* tag is included in the result of
+ __::html::head__.
+
+ Multiple calls of this command are allowed, enabling the use of multiple
+ JavaScript document references. In other words, the arguments of multiple
+ calls are accumulated, and do not overwrite each other.
+
+ - __::html::js-clear__
+
+ *Side effect only*. Call this before __::html::head__ to clear all links to
+ JavaScript documents.
+
+ Multiple calls of this command are allowed, doing nothing after the first of
+ a sequence with no intervening __::html::js__.
+
+ - __::html::minorList__ *list* ?*ordered*?
+
+ Generate an ordered or unordered list of links. The *list* is a Tcl-style
+ name, value list of labels and urls for the links. *ordered* is a boolean
+ used to choose between an ordered or unordered list. It defaults to
+ __false__.
+
+ - __::html::minorMenu__ *list* ?*sep*?
+
+ Generate a series of hypertext links. The *list* is a Tcl-style name, value
+ list of labels and urls for the links. The *sep* is the text to put between
+ each link. It defaults to " | ".
+
+ - __::html::nl2br__ *string*
+
+ This command replaces all line-endings in the *string* with a *br* tag and
+ returns the modified text.
+
+ - __::html::openTag__ *tag* ?*param*?
+
+ Push *tag* onto a stack and generate the opening tag for *tag*. Use
+ __::html::closeTag__ to pop the tag from the stack. The second argument
+ provides any tag arguments, as a list whose elements are formatted to be in
+ the form "__key__=__value__".
+
+ - __::html::paramRow__ *list* ?*rparam*? ?*cparam*?
+
+ Generate a table row, including *tr* and *td* tags. Each value in *list* is
+ placed into its own table cell. This uses __::html::cell__. The value of
+ *rparam* is used as parameter for the *tr* tag. The value of *cparam* is
+ passed to __::html::cell__ as parameter for the *td* tags.
+
+ - __::html::passwordInput__ ?*name*?
+
+ Generate an *input* tag of type *[password](../../../../index.md#password)*.
+ The *name* defaults to "password".
+
+ - __::html::passwordInputRow__ *label* ?*name*?
+
+ Format a table row containing a label and an *input* tag of type
+ *[password](../../../../index.md#password)*. The *name* defaults to
+ "password".
+
+ - __::html::quoteFormValue__ *value*
+
+ Quote special characters in *value* by replacing them with HTML entities for
+ quotes, ampersand, and angle brackets.
+
+ - __::html::radioSet__ *key sep list*
+
+ Generate a set of *input* tags of type *radio* and an associated text label.
+ All the radio buttons share the same *key* for their name. The *sep* is text
+ used to separate the elements. The *list* is a Tcl-style label, value list.
+
+ - __::html::radioValue__ *name value*
+
+ Generate the "name=*name* value=*value*" for a *radio* form element. If the
+ CGI variable *name* has the value *value*, then SELECTED is added to the
+ return value.
+
+ - __::html::refresh__ *seconds url*
+
+ Set up a refresh *meta* tag. Call this before __::html::head__ and the HEAD
+ section will contain a *meta* tag that causes the document to refresh in
+ *seconds* seconds. The *url* is optional. If specified, it specifies a new
+ page to load after the refresh interval.
+
+ - __::html::row__ *args*
+
+ Generate a table row, including *tr* and *td* tags. Each value in *args* is
+ place into its own table cell. This uses __::html::cell__. Ignores any
+ default information set up via __::html::init__.
+
+ - __::html::select__ *name param choices* ?*current*?
+
+ Generate a *select* form element and nested *option* tags. The *name* and
+ *param* are used to generate the *select* tag. The *choices* list is a
+ Tcl-style name, value list.
+
+ - __::html::selectPlain__ *name param choices* ?*current*?
+
+ Like __::html::select__ except that *choices* is a Tcl list of values used
+ for the *option* tags. The label and the value for each *option* are the
+ same.
+
+ - __::html::set__ *var val*
+
+ This procedure is similar to the built-in Tcl
+ __[set](../../../../index.md#set)__ command. The main difference is that it
+ returns "" so it can be called from an HTML template file without appending
+ unwanted results. The other difference is that it must take two arguments.
+
+ - __::html::submit__ *label* ?*name*?
+
+ Generate an *input* tag of type *submit*. *name* defaults to "submit".
+
+ - __::html::tableFromArray__ *arrname* ?*param*? ?*pat*?
+
+ Generate a two-column *[table](../../../../index.md#table)* and nested rows
+ to display a Tcl array. The table gets a heading that matches the array
+ name, and each generated row contains a name, value pair. The array names
+ are sorted (__lsort__ without special options). The argument *param* is for
+ the *[table](../../../../index.md#table)* tag and has to contain a
+ pre-formatted string. The *pat* is a __string match__ pattern used to select
+ the array elements to show in the table. It defaults to __*__, i.e. the
+ whole array is shown.
+
+ - __::html::tableFromList__ *querylist* ?*param*?
+
+ Generate a two-column *[table](../../../../index.md#table)* and nested rows
+ to display *querylist*, which is a Tcl dictionary. Each generated row
+ contains a name, value pair. The information is shown in the same order as
+ specified in the dictionary. The argument *param* is for the
+ *[table](../../../../index.md#table)* tag and has to contain a pre-formatted
+ string.
+
+ - __::html::textarea__ *name* ?*param*? ?*current*?
+
+ Generate a *textarea* tag wrapped around its current values.
+
+ - __::html::textInput__ *name value args*
+
+ Generate an *input* form tag with type *[text](../../../../index.md#text)*.
+ This uses __::html::formValue__. The args is any additional tag attributes
+ you want to put into the *input* tag.
+
+ - __::html::textInputRow__ *label name value args*
+
+ Generate an *input* form tag with type *[text](../../../../index.md#text)*
+ formatted into a table row with an associated label. The args is any
+ additional tag attributes you want to put into the *input* tag.
+
+ - __::html::varEmpty__ *name*
+
+ This returns 1 if the named variable either does not exist or has the empty
+ string for its value.
+
+ - __::html::while__ *test body*
+
+ This procedure is similar to the built-in Tcl __while__ control structure.
+ Rather than evaluating the body, it returns the subst'ed *body*. Each
+ iteration of the loop causes another string to be concatenated to the result
+ value.
+
+ - __::html::doctype__ *id*
+
+ This procedure can be used to build the standard DOCTYPE declaration string.
+ It will return the standard declaration string for the id, or throw an error
+ if the id is not known. The following id's are defined:
+
+ HTML32
+
+ HTML40
+
+ HTML40T
+
+ HTML40F
+
+ HTML401
+
+ HTML401T
+
+ HTML401F
+
+ XHTML10S
+
+ XHTML10T
+
+ XHTML10F
+
+ XHTML11
+
+ XHTMLB
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *html* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[htmlparse](../htmlparse/htmlparse.md), [ncgi](../ncgi/ncgi.md)
+
+# KEYWORDS
+
+[checkbox](../../../../index.md#checkbox),
+[checkbutton](../../../../index.md#checkbutton),
+[form](../../../../index.md#form), [html](../../../../index.md#html),
+[radiobutton](../../../../index.md#radiobutton),
+[table](../../../../index.md#table)
+
+# CATEGORY
+
+CGI programming
ADDED embedded/md/tcllib/files/modules/htmlparse/htmlparse.md
Index: embedded/md/tcllib/files/modules/htmlparse/htmlparse.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/htmlparse/htmlparse.md
@@ -0,0 +1,255 @@
+
+[//000000001]: # (htmlparse - HTML Parser)
+[//000000002]: # (Generated from file 'htmlparse.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (htmlparse(n) 1.2.2 tcllib "HTML Parser")
+
+# NAME
+
+htmlparse - Procedures to parse HTML strings
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Bugs, Ideas, Feedback](#section2)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.2
+package require struct::stack 1.3
+package require cmdline 1.1
+package require htmlparse ?1.2.2?
+
+[__::htmlparse::parse__ ?-cmd *cmd*? ?-vroot *tag*? ?-split *n*? ?-incvar *var*? ?-queue *q*? *html*](#1)
+[__::htmlparse::debugCallback__ ?*clientdata*? *tag slash param textBehindTheTag*](#2)
+[__::htmlparse::mapEscapes__ *html*](#3)
+[__::htmlparse::2tree__ *html tree*](#4)
+[__::htmlparse::removeVisualFluff__ *tree*](#5)
+[__::htmlparse::removeFormDefs__ *tree*](#6)
+
+# DESCRIPTION
+
+The __htmlparse__ package provides commands that allow libraries and
+applications to parse HTML in a string into a representation of their choice.
+
+The following commands are available:
+
+ - __::htmlparse::parse__ ?-cmd *cmd*? ?-vroot *tag*? ?-split *n*? ?-incvar *var*? ?-queue *q*? *html*
+
+ This command is the basic parser for HTML. It takes an HTML string, parses
+ it and invokes a command prefix for every tag encountered. It is not
+ necessary for the HTML to be valid for this parser to function. It is the
+ responsibility of the command invoked for every tag to check this. Another
+ responsibility of the invoked command is the handling of tag attributes and
+ character entities (escaped characters). The parser provides the
+ un-interpreted tag attributes to the invoked command to aid in the former,
+ and the package at large provides a helper command,
+ __::htmlparse::mapEscapes__, to aid in the handling of the latter. The
+ parser *does* ignore leading DOCTYPE declarations and all valid HTML
+ comments it encounters.
+
+ All information beyond the HTML string itself is specified via options,
+ these are explained below.
+
+ To help understand the options, some more background information about the
+ parser.
+
+ It is capable of detecting incomplete tags in the HTML string given to it.
+ Under normal circumstances this will cause the parser to throw an error, but
+ if the option *-incvar* is used to specify a global (or namespace) variable,
+ the parser will store the incomplete part of the input into this variable
+ instead. This will aid greatly in the handling of incrementally arriving
+ HTML, as the parser will handle whatever it can and defer the handling of
+ the incomplete part until more data has arrived.
+
+ Another feature of the parser are its two possible modes of operation. The
+ normal mode is activated if the option *-queue* is not present on the
+ command line invoking the parser. If it is present, the parser will go into
+ the incremental mode instead.
+
+ The main difference is that a parser in normal mode will immediately invoke
+ the command prefix for each tag it encounters. In incremental mode however
+ the parser will generate a number of scripts which invoke the command prefix
+ for groups of tags in the HTML string and then store these scripts in the
+ specified queue. It is then the responsibility of the caller of the parser
+ to ensure the execution of the scripts in the queue.
+
+ *Note*: The queue object given to the parser has to provide the same
+ interface as the queue defined in tcllib -> struct. This means, for example,
+ that all queues created via that tcllib module can be immediately used here.
+ Still, the queue doesn't have to come from tcllib -> struct as long as the
+ same interface is provided.
+
+ In both modes the parser will return an empty string to the caller.
+
+ The *-split* option may be given to a parser in incremental mode to specify
+ the size of the groups it creates. In other words, -split 5 means that each
+ of the generated scripts will invoke the command prefix for 5 consecutive
+ tags in the HTML string. A parser in normal mode will ignore this option and
+ its value.
+
+ The option *-vroot* specifies a virtual root tag. A parser in normal mode
+ will invoke the command prefix for it immediately before and after it
+ processes the tags in the HTML, thus simulating that the HTML string is
+ enclosed in a combination. In incremental mode however the
+ parser is unable to provide the closing virtual root as it never knows when
+ the input is complete. In this case the first script generated by each
+ invocation of the parser will contain an invocation of the command prefix
+ for the virtual root as its first command. The following options are
+ available:
+
+ * __-cmd__ *cmd*
+
+ The command prefix to invoke for every tag in the HTML string. Defaults
+ to *::htmlparse::debugCallback*.
+
+ * __-vroot__ *tag*
+
+ The virtual root tag to add around the HTML in normal mode. In
+ incremental mode it is the first tag in each chunk processed by the
+ parser, but there will be no closing tags. Defaults to *hmstart*.
+
+ * __-split__ *n*
+
+ The size of the groups produced by an incremental mode parser. Ignored
+ when in normal mode. Defaults to 10. Values <= 0 are not allowed.
+
+ * __-incvar__ *var*
+
+ The name of the variable where to store any incomplete HTML into. This
+ makes most sense for the incremental mode. The parser will throw an
+ error if it sees incomplete HTML and has no place to store it to. This
+ makes sense for the normal mode. Only incomplete tags are detected, not
+ missing tags. Optional, defaults to 'no variable'.
+
+ * *Interface to the command prefix*
+
+ In normal mode the parser will invoke the command prefix with four
+ arguments appended. See __::htmlparse::debugCallback__ for a
+ description.
+
+ In incremental mode, however, the generated scripts will invoke the
+ command prefix with five arguments appended. The last four of these are
+ the same which were mentioned above. The first is a placeholder string
+ (__@win@__) for a clientdata value to be supplied later during the
+ actual execution of the generated scripts. This could be a tk window
+ path, for example. This allows the user of this package to preprocess
+ HTML strings without committing them to a specific window, object,
+ whatever during parsing. This connection can be made later. This also
+ means that it is possible to cache preprocessed HTML. Of course, nothing
+ prevents the user of the parser from replacing the placeholder with an
+ empty string.
+
+ - __::htmlparse::debugCallback__ ?*clientdata*? *tag slash param textBehindTheTag*
+
+ This command is the standard callback used by the parser in
+ __::htmlparse::parse__ if none was specified by the user. It simply dumps
+ its arguments to stdout. This callback can be used for both normal and
+ incremental mode of the calling parser. In other words, it accepts four or
+ five arguments. The last four arguments are described below. The optional
+ fifth argument contains the clientdata value passed to the callback by a
+ parser in incremental mode. All callbacks have to follow the signature of
+ this command in the last four arguments, and callbacks used in incremental
+ parsing have to follow this signature in the last five arguments.
+
+ The first argument, *clientdata*, is optional and present only if this
+ command is invoked by a parser in incremental mode. It contains whatever the
+ user of this package wishes.
+
+ The second argument, *tag*, contains the name of the tag which is currently
+ processed by the parser.
+
+ The third argument, *slash*, is either empty or contains a slash character.
+ It allows the callback to distinguish between opening (slash is empty) and
+ closing tags (slash contains a slash character).
+
+ The fourth argument, *param*, contains the un-interpreted list of parameters
+ to the tag.
+
+ The fifth and last argument, *textBehindTheTag*, contains the text found by
+ the parser behind the tag named in *tag*.
+
+ - __::htmlparse::mapEscapes__ *html*
+
+ This command takes a HTML string, substitutes all escape sequences with
+ their actual characters and then returns the resulting string. HTML strings
+ which do not contain escape sequences are returned unchanged.
+
+ - __::htmlparse::2tree__ *html tree*
+
+ This command is a wrapper around __::htmlparse::parse__ which takes an HTML
+ string (in *html*) and converts it into a tree containing the logical
+ structure of the parsed document. The name of the tree is given to the
+ command as its second argument (*tree*). The command does __not__ generate
+ the tree by itself but expects that the caller provided it with an existing
+ and empty tree. It also expects that the specified tree object follows the
+ same interface as the tree object in tcllib -> struct. It doesn't have to be
+ from tcllib -> struct, but it must provide the same interface.
+
+ The internal callback does some basic checking of HTML validity and tries to
+ recover from the most basic errors. The command returns the contents of its
+ second argument. Side effects are the creation and manipulation of a tree
+ object.
+
+ Each node in the generated tree represent one tag in the input. The name of
+ the tag is stored in the attribute *type* of the node. Any html attributes
+ coming with the tag are stored unmodified in the attribute *data* of the
+ tag. In other words, the command does *not* parse html attributes into their
+ names and values.
+
+ If a tag contains text its node will have children of type *PCDATA*
+ containing this text. The text will be stored in the attribute *data* of
+ these children.
+
+ - __::htmlparse::removeVisualFluff__ *tree*
+
+ This command walks a tree as generated by __::htmlparse::2tree__ and removes
+ all the nodes which represent visual tags and not structural ones. The
+ purpose of the command is to make the tree easier to navigate without
+ getting bogged down in visual information not relevant to the search. Its
+ only argument is the name of the tree to cut down.
+
+ - __::htmlparse::removeFormDefs__ *tree*
+
+ Like __::htmlparse::removeVisualFluff__ this command is here to cut down on
+ the size of the tree as generated by __::htmlparse::2tree__. It removes all
+ nodes representing forms and form elements. Its only argument is the name of
+ the tree to cut down.
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *htmlparse* of the [Tcllib
+Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas
+for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+[struct::tree](../struct/struct_tree.md)
+
+# KEYWORDS
+
+[html](../../../../index.md#html), [parsing](../../../../index.md#parsing),
+[queue](../../../../index.md#queue), [tree](../../../../index.md#tree)
+
+# CATEGORY
+
+Text processing
ADDED embedded/md/tcllib/files/modules/http/autoproxy.md
Index: embedded/md/tcllib/files/modules/http/autoproxy.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/http/autoproxy.md
@@ -0,0 +1,289 @@
+
+[//000000001]: # (autoproxy - HTTP protocol helper modules)
+[//000000002]: # (Generated from file 'autoproxy.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (autoproxy(n) 1.7 tcllib "HTTP protocol helper modules")
+
+# NAME
+
+autoproxy - Automatic HTTP proxy usage and authentication
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [TLS Security Considerations](#section2)
+
+ - [COMMANDS](#section3)
+
+ - [OPTIONS](#section4)
+
+ - [Basic Authentication](#section5)
+
+ - [EXAMPLES](#section6)
+
+ - [REFERENCES](#section7)
+
+ - [BUGS](#section8)
+
+ - [AUTHORS](#section9)
+
+ - [Bugs, Ideas, Feedback](#section10)
+
+ - [See Also](#see-also)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+# SYNOPSIS
+
+package require Tcl 8.5
+package require http ?2.0?
+package require autoproxy ?1.7?
+
+[__::autoproxy::init__](#1)
+[__::autoproxy::cget__ *-option*](#2)
+[__::autoproxy::configure__ ?-option *value*?](#3)
+[__::autoproxy::tls_connect__ *args*](#4)
+[__::autoproxy::tunnel_connect__ *args*](#5)
+[__::autoproxy::tls_socket__ *args*](#6)
+
+# DESCRIPTION
+
+This package attempts to automate the use of HTTP proxy servers in Tcl HTTP
+client code. It tries to initialize the web access settings from system standard
+locations and can be configured to negotiate authentication with the proxy if
+required.
+
+On Unix the standard for identifying the local HTTP proxy server seems to be to
+use the environment variable http_proxy or ftp_proxy and no_proxy to list those
+domains to be excluded from proxying. On Windows we can retrieve the Internet
+Settings values from the registry to obtain pretty much the same information.
+With this information we can setup a suitable filter procedure for the Tcl http
+package and arrange for automatic use of the proxy.
+
+There seem to be a number of ways that the http_proxy environment variable may
+be set up. Either a plain host:port or more commonly a URL and sometimes the URL
+may contain authentication parameters or these may be requested from the user or
+provided via http_proxy_user and http_proxy_pass. This package attempts to deal
+with all these schemes. It will do it's best to get the required parameters from
+the environment or registry and if it fails can be reconfigured.
+
+# TLS Security Considerations
+
+*Note* This section only applies if TLS support is provided by the
+__[TLS](../../../../index.md#tls)__ package. It does not apply when
+__autoproxy__ was configured to use some other package which can provide the
+same (i.e __twapi__), via the __-tls_package__ configuration option.
+
+This package uses the __[TLS](../../../../index.md#tls)__ package to handle the
+security for __https__ urls and other socket connections.
+
+Policy decisions like the set of protocols to support and what ciphers to use
+are not the responsibility of __[TLS](../../../../index.md#tls)__, nor of this
+package itself however. Such decisions are the responsibility of whichever
+application is using the package, and are likely influenced by the set of
+servers the application will talk to as well.
+
+For example, in light of the recent [POODLE
+attack](http://googleonlinesecurity.blogspot.co.uk/2014/10/this-poodle-bites-exploiting-ssl-30.html)
+discovered by Google many servers will disable support for the SSLv3 protocol.
+To handle this change the applications using __[TLS](../../../../index.md#tls)__
+must be patched, and not this package, nor __[TLS](../../../../index.md#tls)__
+itself. Such a patch may be as simple as generally activating __tls1__ support,
+as shown in the example below.
+
+ package require tls
+ tls::init -tls1 1 ;# forcibly activate support for the TLS1 protocol
+
+ ... your own application code ...
+
+# COMMANDS
+
+ - __::autoproxy::init__
+
+ Initialize the autoproxy package from system resources. Under unix this
+ means we look for environment variables. Under windows we look for the same
+ environment variables but also look at the registry settings used by
+ Internet Explorer.
+
+ - __::autoproxy::cget__ *-option*
+
+ Retrieve individual package configuration options. See [OPTIONS](#section4).
+
+ - __::autoproxy::configure__ ?-option *value*?
+
+ Configure the autoproxy package. Calling __configure__ with no options will
+ return a list of all option names and values. See [OPTIONS](#section4).
+
+ - __::autoproxy::tls_connect__ *args*
+
+ Connect to a secure socket through a proxy. HTTP proxy servers permit the
+ use of the CONNECT HTTP command to open a link through the proxy to the
+ target machine. This function hides the details. For use with the http
+ package see __tls_socket__.
+
+ The *args* list may contain any of the options supported by the specific TLS
+ package that is in use but must end with the host and port as the last two
+ items.
+
+ - __::autoproxy::tunnel_connect__ *args*
+
+ Connect to a target host throught a proxy. This uses the same CONNECT HTTP
+ command as the __tls_connect__ but does not promote the link security once
+ the connection is established.
+
+ The *args* list may contain any of the options supported by the specific TLS
+ package that is in use but must end with the host and port as the last two
+ items.
+
+ Note that many proxy servers will permit CONNECT calls to a limited set of
+ ports - typically only port 443 (the secure HTTP port).
+
+ - __::autoproxy::tls_socket__ *args*
+
+ This function is to be used to register a proxy-aware secure socket handler
+ for the https protocol. It may only be used with the Tcl http package and
+ should be registered using the http::register command (see the examples
+ below). The job of actually creating the tunnelled connection is done by the
+ tls_connect command and this may be used when not registering with the http
+ package.
+
+# OPTIONS
+
+ - __-host__ hostname
+
+ - __-proxy_host__ hostname
+
+ Set the proxy hostname. This is normally set up by __init__ but may be
+ configured here as well.
+
+ - __-port__ number
+
+ - __-proxy_port__ number
+
+ Set the proxy port number. This is normally set up by __init__. e.g.
+ __configure__ __-port__ *3128*
+
+ - __-no_proxy__ list
+
+ You may manipulate the __no_proxy__ list that was setup by __init__. The
+ value of this option is a tcl list of strings that are matched against the
+ http request host using the tcl __string match__ command. Therefore glob
+ patterns are permitted. For instance, __configure__ __-no_proxy__
+ **.localdomain*
+
+ - __-authProc__ procedure
+
+ This option may be used to set an application defined procedure to be called
+ when __configure__ __-basic__ is called with either no or insufficient
+ authentication details. This can be used to present a dialog to the user to
+ request the additional information.
+
+ - __-basic__
+
+ Following options are for configuring the Basic authentication scheme
+ parameters. See [Basic Authentication](#section5). To unset the proxy
+ authentication information retained from a previous call of this function
+ either "--" or no additional parameters can be supplied. This will remove
+ the existing authentication information.
+
+ - __-tls_package__ packagename
+
+ This option may be used to configure the Tcl package to use for TLS support.
+ Valid package names are __tls__ (default) and __twapi__.
+
+# Basic Authentication
+
+Basic is the simplest and most commonly use HTTP proxy authentication scheme. It
+is described in (1 section 11) and also in (2). It offers no privacy whatsoever
+and its use should be discouraged in favour of more secure alternatives like
+Digest. To perform Basic authentication the client base64 encodes the username
+and plaintext password separated by a colon. This encoded text is prefixed with
+the word "Basic" and a space.
+
+The following options exists for this scheme:
+
+ - __-username__ name
+
+ The username required to authenticate with the configured proxy.
+
+ - __-password__ password
+
+ The password required for the username specified.
+
+ - __-realm__ realm
+
+ This option is not used by this package but may be used in requesting
+ authentication details from the user.
+
+ - __--__
+
+ The end-of-options indicator may be used alone to unset any authentication
+ details currently enabled.
+
+# EXAMPLES
+
+ package require autoproxy
+ autoproxy::init
+ autoproxy::configure -basic -username ME -password SEKRET
+ set tok [http::geturl http://wiki.tcl.tk/]
+ http::data $tok
+
+ package require http
+ package require tls
+ package require autoproxy
+ autoproxy::init
+ http::register https 443 autoproxy::tls_socket
+ set tok [http::geturl https://www.example.com/]
+
+# REFERENCES
+
+ 1. Berners-Lee, T., Fielding R. and Frystyk, H. "Hypertext Transfer Protocol
+ -- HTTP/1.0", RFC 1945, May 1996,
+ ([http://www.rfc-editor.org/rfc/rfc1945.txt](http://www.rfc-editor.org/rfc/rfc1945.txt))
+
+ 1. Franks, J. et al. "HTTP Authentication: Basic and Digest Access
+ Authentication", RFC 2617, June 1999
+ ([http://www.rfc-editor.org/rfc/rfc2617.txt](http://www.rfc-editor.org/rfc/rfc2617.txt))
+
+# BUGS
+
+At this time only Basic authentication (1) (2) is supported. It is planned to
+add support for Digest (2) and NTLM in the future.
+
+# AUTHORS
+
+Pat Thoyts
+
+# Bugs, Ideas, Feedback
+
+This document, and the package it describes, will undoubtedly contain bugs and
+other problems. Please report such in the category *http :: autoproxy* of the
+[Tcllib Trackers](http://core.tcl.tk/tcllib/reportlist). Please also report any
+ideas for enhancements you may have for either package and/or documentation.
+
+When proposing code changes, please provide *unified diffs*, i.e the output of
+__diff -u__.
+
+Note further that *attachments* are strongly preferred over inlined patches.
+Attachments can be made by going to the __Edit__ form of the ticket immediately
+after its creation, and then using the left-most button in the secondary
+navigation bar.
+
+# SEE ALSO
+
+http(n)
+
+# KEYWORDS
+
+[authentication](../../../../index.md#authentication),
+[http](../../../../index.md#http), [proxy](../../../../index.md#proxy)
+
+# CATEGORY
+
+Networking
ADDED embedded/md/tcllib/files/modules/httpd/httpd.md
Index: embedded/md/tcllib/files/modules/httpd/httpd.md
==================================================================
--- /dev/null
+++ embedded/md/tcllib/files/modules/httpd/httpd.md
@@ -0,0 +1,609 @@
+
+[//000000001]: # (tool - Tcl Web Server)
+[//000000002]: # (Generated from file 'httpd.man' by tcllib/doctools with format 'markdown')
+[//000000003]: # (tool(n) 4.1.1 tcllib "Tcl Web Server")
+
+# NAME
+
+tool - A TclOO and coroutine based web server
+
+# Table Of Contents
+
+ - [Table Of Contents](#toc)
+
+ - [Synopsis](#synopsis)
+
+ - [Description](#section1)
+
+ - [Minimal Example](#section2)
+
+ - [Class ::httpd::server](#section3)
+
+ - [Class ::httpd::reply](#section4)
+
+ - [Reply Method Ensembles](#section5)
+
+ - [Reply Method Ensemble: http_info](#section6)
+
+ - [Reply Method Ensemble: request](#section7)
+
+ - [Reply Method Ensemble: reply](#section8)
+
+ - [Reply Methods](#section9)
+
+ - [Class ::httpd::content](#section10)
+
+ - [Class ::httpd::content.cgi](#section11)
+
+ - [Class ::httpd::content.file](#section12)
+
+ - [Class ::httpd::content.proxy](#section13)
+
+ - [Class ::httpd::content.scgi](#section14)
+
+ - [Class ::httpd::content.websocket](#section15)
+
+ - [SCGI Server Functions](#section16)
+
+ - [Class ::httpd::reply.scgi](#section17)
+
+ - [Class ::httpd::server.scgi](#section18)
+
+ - [AUTHORS](#section19)
+
+ - [Bugs, Ideas, Feedback](#section20)
+
+ - [Keywords](#keywords)
+
+ - [Category](#category)
+
+ - [Copyright](#copyright)
+
+# SYNOPSIS
+
+package require Tcl 8.6
+package require httpd ?4.1.1?
+package require sha1
+package require dicttool
+package require oo::meta
+package require oo::dialect
+package require tool
+package require coroutine
+package require fileutil
+package require fileutil::magic::filetype
+package require websocket
+package require mime
+package require cron
+package require uri
+package require Markdown
+
+[constructor ?port ?port?? ?myaddr ?ipaddr?|all? ?server_string ?string?? ?server_name ?string??](#1)
+[method __add_uri__ *pattern* *dict*](#2)
+[method __connect__ *sock* *ip* *port*](#3)
+[method __Connect__ *uuid* *sock* *ip*](#4)
+[method __[counter](../counter/counter.md)__ *which*](#5)
+[method __CheckTimeout__](#6)
+[method __dispatch__ *header_dict*](#7)
+[method __[log](../log/log.md)__ *args*](#8)
+[method __port_listening__](#9)
+[method __PrefixNormalize__ *prefix*](#10)
+[method __start__](#11)
+[method __stop__](#12)
+[method __template__ *page*](#13)
+[method __TemplateSearch__ *page*](#14)
+[method __Validate_Connection__ *sock* *ip*](#15)
+[method __ENSEMBLE::add__ *field* *element*](#16)
+[method __ENSEMBLE::dump__](#17)
+[method __ENSEMBLE::get__ *field*](#18)
+[method __ENSEMBLE::reset__](#19)
+[method __ENSEMBLE::remove__ *field* *element*](#20)
+[method __ENSEMBLE::replace__ *keyvaluelist*](#21)
+[method __ENSEMBLE::reset__](#22)
+[method __ENSEMBLE::set__ *field* *value*](#23)
+[method __http_info::netstring__](#24)
+[method __request::parse__ *string*](#25)
+[method __reply::output__](#26)
+[method __close__](#27)
+[method __HttpHeaders__ *sock* *?debug?*](#28)
+[method __dispatch__ *newsock* *datastate*](#29)
+[method __[error](../../../../index.md#error)__ *code* *?message?* *?errorInfo?*](#30)
+[method __content__](#31)
+[method __EncodeStatus__ *status*](#32)
+[method FormData](#33)
+[method MimeParse *mimetext*](#34)
+[method __DoOutput__](#35)
+[method PostData *length*](#36)
+[method __puts__ *string*](#37)
+[method __reset__](#38)
+[method __timeOutCheck__](#39)
+[method __[timestamp](../../../../index.md#timestamp)__](#40)
+[method __TransferComplete__ *args*](#41)
+[method __Url_Decode__ *string*](#42)
+[method cgi_info](#43)
+[option __path__](#44)
+[option __[prefix](../../../../index.md#prefix)__](#45)
+[method proxy_info](#46)
+[method scgi_info](#47)
+
+# DESCRIPTION
+
+This module implements a web server, suitable for embedding in an application.
+The server is object oriented, and contains all of the fundamentals needed for a
+full service website.
+
+# Minimal Example
+
+Starting a web service requires starting a class of type __httpd::server__, and
+providing that server with one or more URIs to service, and __httpd::reply__
+derived classes to generate them.
+
+ tool::define ::reply.hello {
+ method content {} {
+ my puts "IRM Dispatch Server"
+ my puts "Hello World!"
+ my puts
+ }
+ }
+ ::docserver::server create HTTPD port 8015 myaddr 127.0.0.1
+ HTTPD add_uri /* [list mixin reply.hello]
+
+# Class ::httpd::server
+
+This class is the root object of the webserver. It is responsible for opening
+the socket and providing the initial connection negotiation.
+
+ - constructor ?port ?port?? ?myaddr ?ipaddr?|all? ?server_string ?string?? ?server_name ?string??
+
+ Build a new server object. ?port? is the port to listen on
+
+ - method __add_uri__ *pattern* *dict*
+
+ Set the hander for a URI pattern. Information given in the *dict* is stored
+ in the data structure the __dispatch__ method uses. If a field called
+ *mixin* is given, that class will be mixed into the reply object immediately
+ after construction.
+
+ - method __connect__ *sock* *ip* *port*
+
+ Reply to an open socket. This method builds a coroutine to manage the
+ remainder of the connection. The coroutine's operations are driven by the
+ __Connect__ method.
+
+ - method __Connect__ *uuid* *sock* *ip*
+
+ This method reads HTTP headers, and then consults the __dispatch__ method to
+ determine if the request is valid, and/or what kind of reply to generate.
+ Under normal cases, an object of class __::http::reply__ is created. Fields
+ the server are looking for in particular are: class: A class to use instead
+ of the server's own *reply_class* mixin: A class to be mixed into the new
+ object after construction. All other fields are passed along to the
+ __http_info__ structure of the reply object. After the class is created and
+ the mixin is mixed in, the server invokes the reply objects __dispatch__
+ method. This action passes control of the socket to the reply object. The
+ reply object manages the rest of the transaction, including closing the
+ socket.
+
+ - method __[counter](../counter/counter.md)__ *which*
+
+ Increment an internal counter.
+
+ - method __CheckTimeout__
+
+ Check open connections for a time out event.
+
+ - method __dispatch__ *header_dict*
+
+ Given a key/value list of information, return a data structure describing
+ how the server should reply.
+
+ - method __[log](../log/log.md)__ *args*
+
+ Log an event. The input for args is free form. This method is intended to be
+ replaced by the user, and is a noop for a stock http::server object.
+
+ - method __port_listening__
+
+ Return the actual port that httpd is listening on.
+
+ - method __PrefixNormalize__ *prefix*
+
+ For the stock version, trim trailing /'s and *'s from a prefix. This method
+ can be replaced by the end user to perform any other transformations needed
+ for the application.
+
+ - method __start__
+
+ Open the socket listener.
+
+ - method __stop__
+
+ Shut off the socket listener, and destroy any pending replies.
+
+ - method __template__ *page*
+
+ Return a template for the string *page*
+
+ - method __TemplateSearch__ *page*
+
+ Perform a search for the template that best matches *page*. This can include
+ local file searches, in-memory structures, or even database lookups. The
+ stock implementation simply looks for files with a .tml or .html extension
+ in the ?doc_root? directory.
+
+ - method __Validate_Connection__ *sock* *ip*
+
+ Given a socket and an ip address, return true if this connection should be
+ terminated, or false if it should be allowed to continue. The stock
+ implementation always returns 0. This is intended for applications to be
+ able to implement black lists and/or provide security based on IP address.
+
+# Class ::httpd::reply
+
+A class which shephards a request through the process of generating a reply. The
+socket associated with the reply is available at all times as the *chan*
+variable. The process of generating a reply begins with an __httpd::server__
+generating a __http::class__ object, mixing in a set of behaviors and then
+invoking the reply object's __dispatch__ method. In normal operations the
+__dispatch__ method:
+
+ 1. Invokes the __reset__ method for the object to populate default headers.
+
+ 1. Invokes the __HttpHeaders__ method to stream the MIME headers out of the
+ socket
+
+ 1. Invokes the __request parse__ method to convert the stream of MIME headers
+ into a dict that can be read via the __request__ method.
+
+ 1. Stores the raw stream of MIME headers in the *rawrequest* variable of the
+ object.
+
+ 1. Invokes the __content__ method for the object, generating an call to the
+ __[error](../../../../index.md#error)__ method if an exception is raised.
+
+ 1. Invokes the __output__ method for the object
+
+# Reply Method Ensembles
+
+The __http::reply__ class and its derivatives maintain several variables as
+dictionaries internally. Access to these dictionaries is managed through a
+dedicated ensemble. The ensemble implements most of the same behaviors as the
+__[dict](../../../../index.md#dict)__ command. Each ensemble implements the
+following methods above, beyond, or modifying standard dicts:
+
+ - method __ENSEMBLE::add__ *field* *element*
+
+ Add *element* to a list stored in *field*, but only if it is not already
+ present om the list.
+
+ - method __ENSEMBLE::dump__
+
+ Return the current contents of the data structure as a key/value list.
+
+ - method __ENSEMBLE::get__ *field*
+
+ Return the value of the field *field*, or an empty string if it does not
+ exist.
+
+ - method __ENSEMBLE::reset__
+
+ Return a key/value list of the default contents for this data structure.
+
+ - method __ENSEMBLE::remove__ *field* *element*
+
+ Remove all instances of *element* from the list stored in *field*.
+
+ - method __ENSEMBLE::replace__ *keyvaluelist*
+
+ Replace the internal dict with the contents of *keyvaluelist*
+
+ - method __ENSEMBLE::reset__
+
+ Replace the internal dict with the default state.
+
+ - method __ENSEMBLE::set__ *field* *value*
+
+ Set the value of *field* to *value*.
+
+# Reply Method Ensemble: http_info
+
+Manages HTTP headers passed in by the server. Ensemble Methods:
+
+ - method __http_info::netstring__
+
+ Return the contents of this data structure as a netstring encoded block.
+
+# Reply Method Ensemble: request
+
+Managed data from MIME headers of the request.
+
+ - method __request::parse__ *string*
+
+ Replace the contents of the data structure with information encoded in a
+ MIME formatted block of text (*string*).
+
+# Reply Method Ensemble: reply
+
+Manage the headers sent in the reply.
+
+ - method __reply::output__
+
+ Return the contents of this data structure as a MIME encoded block
+ appropriate for an HTTP response.
+
+# Reply Methods
+
+ - method __close__
+
+ Terminate the transaction, and close the socket.
+
+ - method __HttpHeaders__ *sock* *?debug?*
+
+ Stream MIME headers from the socket *sock*, stopping at an empty line.
+ Returns the stream as a block of text.
+
+ - method __dispatch__ *newsock* *datastate*
+
+ Take over control of the socket *newsock*, and store that as the *chan*
+ variable for the object. This method runs through all of the steps of
+ reading HTTP headers, generating content, and closing the connection. (See
+ class writetup).
+
+ - method __[error](../../../../index.md#error)__ *code* *?message?* *?errorInfo?*
+
+ Generate an error message of the specified *code*, and display the *message*
+ as the reason for the exception. *errorInfo* is passed in from calls, but
+ how or if it should be displayed is a prerogative of the developer.
+
+ - method __content__
+
+ Generate the content for the reply. This method is intended to be replaced
+ by the mixin. Developers have the option of streaming output to a buffer via
+ the __puts__ method of the reply, or simply populating the *reply_body*
+ variable of the object. The information returned by the __content__ method
+ is not interpreted in any way. If an exception is thrown (via the
+ __[error](../../../../index.md#error)__ command in Tcl, for example) the
+ caller will auto-generate a 500 {Internal Error} message. A typical
+ implementation of __content__ look like:
+
+ tool::define ::test::content.file {
+ superclass ::httpd::content.file
+ # Return a file
+ # Note: this is using the content.file mixin which looks for the reply_file variable
+ # and will auto-compute the Content-Type
+ method content {} {
+ my reset
+ set doc_root [my http_info get doc_root]
+ my variable reply_file
+ set reply_file [file join $doc_root index.html]
+ }
+ }
+ tool::define ::test::content.time {
+ # return the current system time
+ method content {} {
+ my variable reply_body
+ my reply set Content-Type text/plain
+ set reply_body [clock seconds]
+ }
+ }
+ tool::define ::test::content.echo {
+ method content {} {
+ my variable reply_body
+ my reply set Content-Type [my request get CONTENT_TYPE]
+ set reply_body [my PostData [my request get CONTENT_LENGTH]]
+ }
+ }
+ tool::define ::test::content.form_handler {
+ method content {} {
+ set form [my FormData]
+ my reply set Content-Type {text/html; charset=UTF-8}
+ my puts [my html header {My Dynamic Page}]
+ my puts ""
+ my puts "You Sent"
+ my puts " "
+ foreach {f v} $form {
+ my puts "$f | $v | "
+ }
+ my puts "
---|
"
+ my puts "Send some info: "
+ my puts " |