www.pudn.com > pl0.zip > pcode.h
// pcode.h: interface for the pcode class. // ////////////////////////////////////////////////////////////////////// #ifndef __PCODE_H #define __PCODE_H #include#include #include #define CODE_MAX 200 #define STACK_MAX 500 using namespace std; typedef enum { LIT, OPR, LOD, STO, CAL, INT, JMP, JPC ,RED ,WRT} fct; typedef struct Ccode { fct f; //操作码 int l; //层次差 int a; //位移量 } CCode; class pcode { friend class Grammar; private: CCode code[CODE_MAX]; //目标代码 int cx; //下标指针 int b; //运行时栈指针 int s[STACK_MAX]; //运行栈 public: pcode(); void Gen(fct f,int l,int a); void Interpret(); void PrintCode(); void OutToFile(string &name); int base(int l); }; #endif // pcode.h