aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2/mc/README
blob: ec1933dfc39c0869f8895ae4884eec53ec8af0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
In this directory is the source to the bootstrap tool mc.  The tool
converts PIM4 Modula-2 into C or C++ and it implements some of the GNU
Modula-2 extensions.  It uses the same lexical and grammar as GNU
Modula-2, but restricts some of the features.

Local modules are not supported and constant aggregate types are not
supported (with the exception of SET constant aggregate types).  It
has the ability to translate Modula-2 into C/C++, it uses the same
name space convension as GNU Modula-2 and it issues source file
directives in the target language which match the original source.

The tool mc uses multiple passes primarily to keep the implementation
simple.  The function of each pass is defined here:

Pass 1
   define module symbols (def, imp, program, local) and find their source
   files if appropriate.
   parse definition modules and any extended opaque implementation module
   and the implementation/program module.
   define root decls for all CONST, TYPE, PROCEDURE, VAR, symbols
   (the left hand side for all declarations).
   push and pop scope symbols as the source is parsed.
   populate the export lists for the def modules

Pass 2
   parse definition modules and any extended opaque implementation module
   and the implementation/program module.
     complete declaration of the right hand side of TYPE:
       equivalence:  TYPE foo = bar ;
       equivalence:  TYPE foo = bar.x ;
       enumerations: TYPE foo = (a, b, c) ;
     completely define enumeration types and place them into
     a per module list of enumerations.

Pass 3
   parse definition modules and any extended opaque implementation module
   and the implementation/program module.
      process the import lists for the def
      introducing the symbol from another modules export list.
        remembering to populate the enum and all fields if they are imported.
      mark any opaque type (in the definition module).
      create placeholders for expression and constexpression
        and put these into a list.
      complete const/type/var/procedure declarations (using
        expression placeholders).

Pass 4
   parse definition modules and any extended opaque implementation module
   and the implementation/program module.
     build expressions and constexpressions
     and attach them to their placeholders.
   at this point all definition module symbols are completely finished.
   at this point const/types should be completely declared for the
   implementation/program module

Pass 5
   only parse the implementation or program module
   build a tree for all procedure and main init code.
   build expressions and constexpressions
   and attach them to their placeholders.

for each exported symbol, s
   topological sort and define s

topological sort and define init code