1 //****************************************************************
3 //* Instr.h : Header file for the object class hierarchy for *
4 //* the instructions. *
6 //* (c) LITA, university of PAU (France), summer 1993. *
7 //****************************************************************
9 //***************************************
11 //** Objects decribing an instruction **
12 //** inside an abstract tree. **
14 //***************************************
19 Single_Instruction Complex_Instruction
24 := job io signal control object
26 Attach Put Raise Return Wind
29 Detach ReadLn Generator
48 Instruction( String TheStr, Location *TheLoc ) :
49 kind( TheStr ), place( TheLoc )
52 virtual void Print( ostream& );
54 friend ostream& operator << ( ostream& , Instruction );
57 class OneArgInstr : public Instruction
62 OneArgInstr( Expression * , String, Location * );
63 virtual void Print( ostream& );
66 class TwoArgInstr : public Instruction
69 Expression *arg1,*arg2;
71 TwoArgInstr( Expression *, Expression *, String, Location *);
72 virtual void Print( ostream& );
75 class Affectation : public TwoArgInstr
78 Affectation( Expression *, Expression * );
79 void Print( ostream& );
89 class Attach : public OneArgInstr
92 Attach( Expression *, Location * );
95 class Resume : public OneArgInstr
98 Resume( Expression *, Location * );
101 class Detach : public Instruction
104 Detach( Location *TheLoc ) : Instruction( String( "Detach" ), TheLoc ) {}
107 class Terminate : public Instruction
110 Terminate( Location *TheLoc ) : Instruction( String( "Terminate" ), TheLoc ) {}
113 class Stop : public OneArgInstr
116 Stop( Expression *, Location * );
118 void Print( ostream& );
122 //** These class describes the I/O instructions of LOGLAN
124 //** Each Instruction taking a variable argument number
125 //** for example "writeln( output,a,b )"
126 //** is simplified into the following Instructions :
127 //** write( output, a );
128 //** write( output, b );
129 //** writeln( output );
132 class Read : public OneArgInstr
135 Read( Expression *, Location * );
138 class Readln : public Instruction
141 Readln( Location * );
144 class Write : public OneArgInstr
147 Write( Expression *, Location * );
150 class Writeln : public Instruction
153 Writeln( Location * );
156 class Get : public OneArgInstr
159 Expression *TheFile, *TheArg;
160 Get( Expression *, Location * );
163 class Put : public OneArgInstr
166 Expression *TheFile, *TheArg;
167 Put( Expression *, Location * );
171 //** This is the only Instruction concerning signals.
174 class Raise : public OneArgInstr
177 Raise( Expression *TheExpr, Location *TheLoc ) :
178 OneArgInstr( TheExpr, String("Raise"), TheLoc ) {}
182 //** Class container for a set of Instructions. We call it a block.
183 //** Tool class for containing several instructions and manipulate them.
188 Instruction *Instruct;
189 ListOfInstr *NextInst;
191 friend ListOfInstr& operator += ( ListOfInstr& , Instruction * );
192 ListOfInstr( Instruction *TheInstr );
193 void Print( ostream& );
196 class Block : public Instruction
198 ListOfInstr InstrList;
200 Block( Instruction *FirstInstr, Location *TheLoc );
201 friend Block& operator += ( Block& TheBlock, Instruction *TheInstr );
202 void Print( ostream& );
206 //** Class conditionnal If : A class with 2 Blocks conditionnaly executed.
209 class ConditionIf : public Instruction
211 Block *BlockThen, *BlockElse;
212 Expression *Condition;
214 ConditionIf( Expression *, Block *, Block *, Location * );
215 void Print( ostream & );
219 //** Class Loop : A class for hanling loop construction
222 class Loop : public Instruction
226 Loop( Block *TheBlock, String TheName ) :
227 Instruction( TheName, TheBlock->place ), Body( TheBlock ) {};
228 void Print( ostream& );
231 class While : public Loop
233 Expression *Condition;
235 While( Expression *, Block *, Location * );
236 void Print( ostream& );
239 class For : public Loop
242 Expression *CounterInit;
243 Expression *CounterStop;
244 Expression *CounterStep;
246 For( Expression *,Expression *, Expression *, Expression *, Block *,Location * );
247 void Print( ostream& );