Debian Codegraph @

gcc/testsuite/gm2/pim/pass/tinyvarient6.mod

raw
1 (* Copyright (C) 2015 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA. *)
18
19 MODULE tinyvarient6 ; (*!m2pim*)
20
21
22 CONST
23 MaxCodeHunkLength = 4 ;
24
25 TYPE
26 Name = CARDINAL ;
27
28 ElementType = (idel, tokel, litel) ;
29
30 m2condition = (m2none, m2if, m2elsif, m2while) ;
31
32 TraverseResult = (unknown, true, false) ;
33
34 ProductionDesc = POINTER TO productiondesc ;
35
36 IdentDesc = POINTER TO identdesc ; (* forward fodder for p2c *)
37 identdesc = RECORD
38 definition: ProductionDesc ; (* where this idents production is defined *)
39 name : Name ;
40 line : CARDINAL ;
41 END ;
42
43 SetDesc = POINTER TO setdesc ;
44 setdesc = RECORD
45 next : SetDesc ;
46 CASE type: ElementType OF
47
48 idel : ident : IdentDesc |
49 tokel,
50 litel : string: Name
51
52 END
53 END ;
54
55 (* note that epsilon refers to whether we can satisfy this component part
56 of a sentance without consuming a token. Reachend indicates we can get
57 to the end of the sentance without consuming a token.
58
59 For expression, statement, productions, terms: the epsilon value should
60 equal the reachend value but for factors the two may differ.
61 *)
62
63 FollowDesc = POINTER TO followdesc ;
64 followdesc = RECORD
65 calcfollow : BOOLEAN ; (* have we solved the follow set yet? *)
66 follow : SetDesc ; (* the follow set *)
67 reachend : TraverseResult ; (* can we see the end of the sentance (due to multiple epsilons) *)
68 epsilon : TraverseResult ; (* potentially no token may be consumed within this component of the sentance *)
69 line : CARDINAL ;
70 END ;
71
72 TermDesc = POINTER TO termdesc ;
73
74 ExpressionDesc = POINTER TO expressiondesc ;
75 expressiondesc = RECORD
76 term : TermDesc ;
77 followinfo: FollowDesc ;
78 line : CARDINAL ;
79 END ;
80
81 StatementDesc = POINTER TO statementdesc ;
82 statementdesc = RECORD
83 ident : IdentDesc ;
84 expr : ExpressionDesc ;
85 followinfo : FollowDesc ;
86 line : CARDINAL ;
87 END ;
88
89 CodeHunk = POINTER TO codehunk ;
90 codehunk = RECORD
91 codetext : ARRAY [0..MaxCodeHunkLength] OF CHAR ;
92 next : CodeHunk ;
93 END ;
94
95 CodeDesc = POINTER TO codedesc ;
96 codedesc = RECORD
97 code : CodeHunk ;
98 indent : CARDINAL ; (* column of the first % *)
99 line : CARDINAL ;
100 END ;
101
102 FactorType = (id, lit, sub, opt, mult, m2) ;
103
104 FactorDesc = POINTER TO factordesc ;
105 factordesc = RECORD
106 followinfo: FollowDesc ;
107 next : FactorDesc ; (* chain of successive factors *)
108 line : CARDINAL ;
109 pushed : FactorDesc ; (* chain of pushed code factors *)
110 CASE type: FactorType OF
111
112 id : ident : IdentDesc |
113 lit : string: Name |
114 sub,
115 opt,
116 mult: expr : ExpressionDesc |
117 m2 : code : CodeDesc ;
118
119 END
120 END ;
121
122 termdesc = RECORD
123 factor : FactorDesc ;
124 next : TermDesc ; (* chain of alternative terms *)
125 followinfo: FollowDesc ;
126 line : CARDINAL ;
127 END ;
128
129 productiondesc = RECORD
130 next : ProductionDesc ; (* the chain of productions *)
131 statement : StatementDesc ;
132 first : SetDesc ; (* the first set *)
133 firstsolved : BOOLEAN ;
134 followinfo : FollowDesc ;
135 line : CARDINAL ;
136 description : Name ;
137 END ;
138
139 DoProcedure = PROCEDURE (ProductionDesc) ;
140
141 VAR
142 f: FactorDesc ;
143 BEGIN
144 f^.type := m2
145 END tinyvarient6.