previous next contents
(Read "Dp4Xyz" as "Dp4.Xyz" for the Java version.)
- Kernel:
- contain the basic functionality of the parser and basic text handling
Dp4Base, Dp4Chars- Technical support:
- runtime loading, global variable management, FLEX implementation
Dp4Tools, Dp4Translator- Logging:
- error messages, warnings, other output
Dp4OP, Dp4Messages- Abstract input/output
- definition of a basic class for stream source resp. target objects
Dp4Streams- Concrete input/output
- this may vary with respect to the implementation platform
to expect at least: Dp4DocFiles (in essence, a simple wrapper), Dp4StrBuf (internal character stream buffer)- Other
- defining an own configuration, symbol management
Dp4Config, Dp4AccTab, Dp4List- Extensions
- useful functions but not essential for the principal application
Dp4xTrace, Dp4xCheck, Dp4xCount, Dp4xSTree
In principle, Depot4 is a software very similar to an ordinary compiler. And as any compiler it can be used in different ways:
Translate is applied at Ml4
productions. It produces a host language program
unit and, subsequentially, invokes the host language compiler on it. That's why error messages may
be originate from different sources: the Ml4
translator and the host language compiler.
The big number of possible faults is already caught by the translator. The most likely reasons
for errors reported by the compiler are the use of host language keywords (such as do
)
as identifiers (may be caught in a future version) and parameter/type mismatch with imported objects.
Use is intended for application of generated translators. It expects a source (file, marked text,
etc.) to process and the name of a production, which will be called first (root production).
There are some possibilities to influence such runs. Dp4Base offers a set of 16 flags that control how much
information will be sent to the log. Further, significance of letter case may be switched on or off. There is also
support for tracing, the invocation of productions, and checking against unbounded (left) recursion.
Module Dp4Config
contains the code for a default
configuration and users are explicitly invited to establish their own favorite settings there.
Step 1: Depot4 is designed as an extensible program without restricting its input. That's achieved
by several mapping layers. Every source consists of a sequence of objects of (abstract) type Dp4Base.Token
. So it is possible to combine different types of input objects (mostly but not restricted to different
document files or defined parts of them) into one source. By default, there is
one standard subtype StreamToken
, which is in turn the parent type for all stream-like
types, e.g., files, text areas, etc.
The default implementation modules for stream tokens (Dp4Files etc.) offer convenient procedures for
the construction of appropriate objects.
Step 2: The core action is the calling of the translator. This is done by
calling the translate
procedure from Dp4Tools
. It takes the source
object as first parameter and the name of the root (string!) as second one. The result is a status (TRUE=
input accepted vs. FALSE= parse failed) and (in the case of success) an internal representation of the
generated target.
In more detail, a translation's runtime environment (e.g. the local substitution stacks) is contained in
a Dp4Translator
object. The runtime handles an implicit default translator object so there
is no need to bother about this as long as there is no threading involved. In case of (possibly) more
than one active translation thread it is recommended to have a dedicated translator object for each
thread.
Step 3: The generated target is represented as an acyclic directed graph (ADG). Interpretation is a left-right, depth-first walk through this graph. Thereby the interpreter decides how to handle the different node types. By default there are only string nodes (containing a string of ASCII characters) and source nodes (containing the source and the start and end position of the source stretch to copy). The default interpreter just combines them into a stream of characters.
Dp4.trgts myTarget= Dp4.Tools.translate(Dp4.Files.IFile("Source.Ml4"), "MyRoot");
if (Dp4.Tools.isOk()) {
Dp4.Streams.Tar2Strm(myTarget.trg1, Dp4.FileTrg.New("TARGET.T1")); // store it to a file
} else {
// report an error
}
Dp4Base.Token
).
They offer just the minimal functionality, which is needed by the parser, i.e., a sequential reader can be
reset to the beginning, save and reestablish its position, write its position, and be closed.Dp4Stream.Token
is derived from Dp4Base.Token
for this purpose.
Streams are abstract, they must be implemented by specialization. There is at least an implementation of
Dp4DocFiles
for ASCII file input/output. For further stream definitions consult the
host language related documentation.
Dp4Base.Source
Dp4Base.concTkn
Dp4Base.Token
on
a source
Dp4Streams.StrmSrc
Dp4Streams.New
Dp4Base.Token
object from a stream
Dp4Stream.Token
. Module
Dp4Files
has already a constructor IFile
, which builds a source
object from a file name string.
Dp4Streams.Tar2Strm(TAR, Dp4Streams.OutStream)
writes a target
onto the desired stream. (see 5.2.2)
previous next contents