next up previous contents
Next: 2.4.3.1 The Expansion of Up: Expansion of Macro COSY Previous: 2.4.2.2 The Expansion of

New Expander for Macro COSY Programs

Unlike the old expander, the new expander deals with trees instead of strings. At first, we will create concrete syntax trees which correspond to the given Macro COSY grammar. Then, we will parse the Macro COSY program represented as a string into a syntax tree. Finally, the expander expands the Macro COSY program from its corresponding syntax tree into another syntax tree which is in the form of a Basic COSY syntax tree, and then, converts this resulting syntax tree into a string which is in the form of a Basic COSY program. Now, let's use rule M1 as an example to see how the old expander and new expander work (For more information, please see Appendix).

The following figure shows how the old expander works:

                      Productions
                                                     specifies
M1. <mprogram> = "program" <mprogrambody> "endprogram  ----->

          Sets of strings(1)                       Sets of strings(2)
                               old expand
             MPROGRAM          ---------->          EBPROGRAM
                |                                       |
{"program"} o MPBODY o {"endprogram"}   {"program"} o EBBODY o {"end"}

where the string which is inside tex2html_wrap_inline5136 denotes a set of strings, the operator o denotes string set concatenation,

       o : string set * string set -> string set

uppercase names denote sets of strings, for example,

displaymath6677

From the above figure we can see that the rule M1 can be specified as sets of strings(the column of ``Sets of strings(1)''). The old expander can expand these sets of strings into other set of strings which is the form of basic COSY program (the column of ``Sets of strings(2)'').

The following figure shows how the new expander works:

                      Productions
                                                     specifies
M1. <mprogram> = "program" <mprogrambody> "endprogram  ----->

concrete data structure                 concrete data structure
or tree for mprogram                    or tree for ebprogram
                        new expand
      Program           ---------->            Program
         |                                        |
  <mprogrambody>                           <ebprogrambody>

where the non-terminal symbol inside tex2html_wrap_inline6681 denotes a subtree, for instance,
<mprogrambody> denotes the macro program body subtree, etc., the prefix m stands for macro, eb stands for expanded basic.

From the above figure we can see that the rule M1 can be specified as a tree (the column of concrete data structure or tree for mprogram). The new expander can expand the tree to another tree which is in the form of a basic COSY program (the column of concrete data structure or tree for ebprogram).

Because of lack of time and in order to test the result, the program we designed expands the Macro COSY program from its corresponding syntax tree into a string directly, and the string is in the form of the Basic COSY program.

In this section, we only discuss the expander. We will discuss the syntax tree and parser later.




next up previous contents
Next: 2.4.3.1 The Expansion of Up: Expansion of Macro COSY Previous: 2.4.2.2 The Expansion of

Peter Lauer
Mon Jul 22 17:29:46 EDT 1996