![]() |
Library for storage of TeX documents |
Introduction Screenshots Mailing Lists and IRC Alternative Browsers Special Thanks
FAQ
Download binaries Platforms Compiling Mnemonic Other useful software
Core Message modules Library modules Object modules Coding Guidelines Browse Source Using CVS
Website questions to: |
The texdoc library contains objects for the storage of parsed TeX documents. Just like lib-dom, a document is stored in a nested form, with TeX groups (usually opened and closed with `{' and `}' respectively) stored in a tree-like structure. In contrast to the representation in TeX itself, lib-texdoc stores an entire document in memory. Mode changing commands, like for instance `$', result in the construction of nodes of a specific type,
\begin{...} and \end{...}
commands. In normal TeX these are handled by the LaTeX format
file, in lib-texdoc it is possible to have them scanned by
a C++ parser and stored in latex_node s.
Some nodes appearing in TeX lists are not represented in lib-texdoc as they are concerned with typeset output rather than input, and do therefore not belong in a library that encodes input. (NOTE: not all of the above nodes should remain in the library).
TeX knows about many parameters that determine the structure of
a document. The actual values of those parameters can be changed
at any point in the input and will subsequently influence scanning
and parsing of the remainder of the input. The texdoc library
keeps track of these variables by storing the modifications as
boundaries of nested blocks are crossed. The objects that take
care of this are defined in Do we have to have native scanning of macros with optional parameters in lib-texdoc? Probably we will. The easiest way to do that is to define additional catcodes `open_optional' and `close_optional'. See `tests/latex_test.tex' for an example.
Macros are stored in the form of token lists, defined in
Most documents start out with some symbols in an implicit hbox,
so these are stored as children of an hlist_node. Opening special
nodes by using a TeX primitive, eg.
It is up to the parser to scan for special non-primitive grouping
commands, for instance Note: we basically want a way to represent the catcode-independent version of a document, together with the TeX primitives like \hbox, \vbox, and the LaTeX `primitives' like `\section' as well as `\begin{...}/\end{...}' constructs. In addition, we want to keep track of macro definitions, whether these are single or multiple character ones. Not only do we have to be able to store macros, we should also be able to evaluate them.some text \catcode`\@11 \def@#1#2{foo #1 bar #2} \catcode`\@12 other \catcode While scanning all funky catcode things just result in the parser using different input characters to map to TeX primitives. The parser can get access to the catcode information to do this. The resulting document does not have to be scanned from the beginning onwards as all catcode have been expanded.
How should we handle macro expansion? If we store the actual call
of the macro but do not expand, we may be messing up the catcodes.
So it seems necessary to always expand definitions while scanning,
not just upon request. We could still keep a Something similar is required to store the text that describes the definition of a macro. |