Metaprogramming Text Processor

Basic Syntax


output :=  MTP (input)
input :=  escape-init escape-term { text }
escape-init :=  "defined by being the first character of input"
escape-term :=  "defined by being the second character of input"

text :=  target-text  |  meta-text
target-text :=  "any stream of characters including whitespace and excluding escape-init and escape-term"
meta-text :=  escape-init [ meta-statement ] escape-term

meta-whitespace :=  whitespace  |  meta-comment  "may occur anyplace within a meta-statement except within a name"
whitespace :=  "space, tab, and end-of-line characters"
meta-comment :=  '{' "any text" '}'  "recognizes nested meta-comments"

The purpose of MTP processing is to output its input, replacing any references to metaprograms with their target-level equivalent meanings. Input to MTP consists of text at two levels: target-level and meta-level. Target-level text is any text that might be found in an instance work product. Meta-level text consists of MTP constructs that define how to produce tailored target-level text where parts of different instance work products have different content.

The tool presumes that all input is target-level until it encounters embedded meta-level text. Embedding is signaled by the occurrence of an escape character pair surrounding a text sequence. Text following embedded meta-level text is again taken as target-level text until another embedding or the end of input text is found. When input consists of target-level text, output is identical to input; when input consists of meta-level text, output is tranformed from input according to the meaning of contained meta-level constructs.

Embedded text also occurs within meta-level text. At specific positions within meta-level constructs, target-level text is expected. Embedding, using the same escape characters, is used to indicate the beginning and end of the target-level text. This target-level text may also contain embedded meta-level constructs. This use of embedding is shown more fully in descriptions of the meta-level constructs.

Escape characters

There are two escape characters, the escape-init character which signals the beginning of embedded text and the escape-term character which indicates the end of embedded text. These always occur as a pair. Characters must be used that occur neither in normal target-level nor in meta-level text. For flexibility, the choice of these two characters is not hardcoded. Instead, the first line of an MTP input file must contain the two characters to be used. For example, if the first line of input is "<>", the escape-init character is "<" and the escape-term character is ">". When MTP encounters an escape-init in its input, it treats all text up to the matching escape-term character as embedded text.

Target-level text

Target-level text is simply text that looks exactly as it should in the sort of work product that is to be generated. Target-level text occurs both at the top-level of an Adaptable Component and as embedded text within meta-level text. Often, the target-level text needed to create initial versions of an Adaptable Component come directly from existing instance work products.

Meta-level text

Meta-level text occurs as embedded text within target-level text and must conform to the syntax of meta-level constructs as defined in this document.

Meta-level comments

Within meta-level text, there is the option of including text that will be ignored by the MTP tool. Text enclosed in braces is discarded without further analysis or processing. Note that braces in target-level text have no special significance for MTP and are output as normal characters.

Notes

.
When MTP produces error messages, these are directed to the standard Java error output window for your environment. Web browsers generally require you to open a Java console in order for you to see these messages. Be sure to check this window whenever you attempt an MTP execution.
.



PHS