21cef1dd1882ec8fcdda0033f05821e6f67a538c
1 #include <reader.h>
2 #include <alien.h>
4 #include <string>
5 #include <assert.h>
9 Reader::Reader(std::istream &rider): d_rider(rider), d_cancelled(false), d_readAlien(false), d_typeList(),
13 SHORTCHAR out;
16 }
20 }
23 CHAR buf;
29 CHAR out;
33 }
34 }
46 }
47 }
48 }
51 BYTE out;
54 }
57 SHORTINT buf;
63 SHORTINT out;
67 }
68 }
71 INTEGER buf;
77 INTEGER out;
81 }
82 }
87 }
88 }
95 }
99 }
105 }
107 }
112 //std::cout << "NIL STORE" << std::endl;
115 //std::cout << "LINK STORE" << std::endl;
118 //std::cout << "NEWLINK STORE" << std::endl;
121 //std::cout << "STORE STORE" << std::endl;
124 //std::cout << "ELEM STORE" << std::endl;
127 //std::cout << std::hex << (unsigned int)kind << std::endl;
129 }
130 }
131 // PROCEDURE (VAR rd: Reader) ReadStore* (OUT x: Store), NEW;
132 // VAR a: Alien; t: Kernel.Type;
133 // len, pos, pos1, id, comment, next, down, downPos, nextTypeId, nextElemId, nextStoreId: INTEGER;
134 // kind: SHORTCHAR; path: TypePath; type: TypeName;
135 // save: ReaderState;
144 }
146 }
147 // IF kind = nil THEN
148 // rd.ReadInt(comment); rd.ReadInt(next);
149 // rd.st.end := rd.Pos();
150 // IF (next > 0) OR ((next = 0) & ODD(comment)) THEN rd.st.next := rd.st.end + next ELSE rd.st.next := 0 END;
151 // x := NIL
154 }
155 // ELSIF kind = link THEN
156 // rd.ReadInt(id); rd.ReadInt(comment); rd.ReadInt(next);
157 // rd.st.end := rd.Pos();
158 // IF (next > 0) OR ((next = 0) & ODD(comment)) THEN rd.st.next := rd.st.end + next ELSE rd.st.next := 0 END;
159 // x := ThisStore(rd.eDict, id)
162 }
163 // ELSIF kind = newlink THEN
164 // rd.ReadInt(id); rd.ReadInt(comment); rd.ReadInt(next);
165 // rd.st.end := rd.Pos();
166 // IF (next > 0) OR ((next = 0) & ODD(comment)) THEN rd.st.next := rd.st.end + next ELSE rd.st.next := 0 END;
167 // x := ThisStore(rd.sDict, id)
172 //std::cout << path.toString() << std::endl;
184 }
188 }
196 }
197 }
201 }
209 }
221 }
225 // rd.cause := inconsistentType; AlienTypeReport(rd.cause, type);
227 }
228 }
234 // join(d_store, x)
235 //std::cout << "Man, should have written join(.,.)" << std::endl;
236 }
241 }
249 // join(d_store, alien)
250 //std::cout << "Man, should have written join(.,.)" << std::endl;
251 }
256 }
264 // we've just read the alien, so reset the state
269 }
272 }
279 //std::cout << "Alien Piece" << std::endl;
286 //std::cout << "Alien Store" << std::endl;
291 }
292 }
293 }
299 }
301 }
304 TypePath path;
306 SHORTCHAR *buf = new SHORTCHAR[64]; // TypeName has a maximum of length 64 (including terminator).
313 // IF path[i] # elemTName THEN INC(i) END;
315 }
327 }
331 // IF path[i] # elemTName THEN INC(i) END
333 }
336 }
338 }
345 }
347 }