code.h

来自「PL/0编译器」· C头文件 代码 · 共 42 行

H
42
字号
//code,h
//代码生成类

#pragma once
#ifndef __CCODE_H
#define __CCODE_H

#include "Symtax.h"

#define CODE_SIZE	200
#define RUN_STACK_SIZE	500		//运行栈的容量

enum fct {lit,opr,lod,sto,cal,tint,jmp,jpc};

struct instruction
{
	fct f;						//命令代码
	int l;						//层差
	int a;						//转移地址
};

class CCode
{
public:
	CCode(CPl0*p);
	~CCode(void);

	void Gen(fct f,int l,int a);//代码生成函数
	void ListCode();			//列出目标代码
	void Interpret();			//解释器函数

//private:
	instruction code[CODE_SIZE];//代码栈
	int cx;						//代码指针

	int b;						//程序基地址指针
	int s[RUN_STACK_SIZE];		//数据栈
private:
	int base(int l);
	CPl0 *pl;
};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?