previous next contents
The Depot4 standard library consists of a set of modules that are useful in defining translators. They
offer services, which for efficiency or convenience, may be better implemented in the host language.
This is the Output on Protocol module.
- Procedures
- WrStr
- Write String - one SYM argument
- WrInt
- Write Integer - one argument expression of type INTEGER
- WrLn
- Write Line - no argument
- ERROR
- writes error meassage - one INTEGER argument, which is the error number
error numbers bigger than 999 are assumed to be fatal errors, i.e. computation is aborted,
the actual error message is defined by argument - 1000
- WARNING
- issues a warning, argument is the warning number (integer)
If loaded, procedures ERROR and WARNING of Dp4OP are modified such, that instead of the numbers
a text is printed. Dp4Messages contains all this texts and a few access procedures.
Although someone may be surprised, it turned out to be more portable to have a module compiled on
different platforms than to read just from some text file.
To change some or all texts, edit the source and recompile it.
This module offers a simple symbol management. Together with flexible arrays (FLEX) it supports the
construction of symbol tables in Ml4 (without any pointer handling).
- Interface
- List
- Type for lists
- New(List)
- Initialization, has to be called explicitly
- Extend(List, SYM)
- Append symbol to list
- Unite(List, SYM)
- Append symbol only if not in list
- Idx(List, SYM):INTEGER
- Last index of symbol in list (=0 means symbol is not in list)
- Item(List, INTEGER):TXT
- return symbol with index i as object of type TXT
- len(List): INTEGER
- current number of symbols in list
- Cut(List, INTEGER)
- delete all symbols following the given index; to implement a stack together with len
- Sort(List, INTEGER, INTEGER)
- Sort symbols between both indices
- Exchng(List, INTEGER, INTEGER)
- Exchange symbols with the given indices (to implement own sorting)
The index range of lists starts with one (thus corresponding to FLEX).
This module collects some useful functions which were needed by system itself but may also
be useful in other projects. There may be slight differences among different Depot4
implementations, e.g. in Depot4/Oberon, they were proper procedures with a
VAR parameter instead of the return value.
At least, this module contains these functions:
- Interface
- Date():SYM
- current date in a default format
- getPrefix(SYM):SYM
- returns the prefix of a symbol value, i.e.,
if an identifier contains a small letter or
digit followed by a capital letter, all the part before the first such capital is regarded as prefix
(E.g.
Dp4 is the prefix of Dp4ExAmPlE1.)
if there is none, as in DP4X, an empty string is returned
- getSuffix(SYM):SYM
- returns the symbol value without its prefix,
if there is no prefix the argument is returned
- toUpperC(SYM):SYM
- converts all letters into their uppercase equivalents
- toLowerC(SYM):SYM
- converts all letters into their lowercase equivalents
- up1letter(SYM):SYM
- makes the first character an uppercase letter (if it is a letter)
This module is heavily dependent from the implementation language and its the runtime system, and thus
specified in Appendix D.
previous next contents
© J. Lampe 1997-2002
juergen_lampe@firemail.de
(14-Mar-2002)