Welcome![Sign In][Sign Up]
Location:
Search - pl0.e

Search list

[ELanguagepl/0

Description: /*PL/0编译系统C版本头文件pl0.h*/ /* typedef enum { false, true } bool; */ #define norw 13 /*关键字个数*/ #define txmax 100 /*名字表容量*/ #define nmax 14 /*number的最大位数*/ #define al 10 /*符号的最大长度*/ #define amax 2047 /*地址上界*/ #define levmax 3 /*最大允许过程嵌套声明层数[0,levmax]*/ #define cxmax 200 /*最多的虚拟机代码数*/ /*符号*/ enum symbol{ nul, ident, number, plus, minus, times, slash, oddsym, eql, neq, lss, leq, gtr, geq, lparen, rparen, comma, semicolon, period, becomes, beginsym, endsym, ifsym, thensym, whilesym, writesym, readsym, dosym, callsym, constsym, varsym, procsym, }; #define symnum 32 /*名字表中的类型*/ enum object{ constant, variable, procedur, }; /*虚拟机代码*/ enum fct{ lit, opr, lod, sto, cal, inte, jmp, jpc, }; #define fctnum 8 /*虚拟机结构代码*/ struct instruction { /*454*/ enum fct f; // 虚拟机代码指令 int l; //引用层与声明层的层次差 int a; //根据f的不同而不同 }; FILE * fas; //输出名字表 FILE * fa; //输出虚拟机代码 FILE * fa1; //输出源文件及其各行对应的首地址 FILE * fa2; //输出结果 bool listswitch; //显示虚拟机代码与否 bool tableswitch; //显示名字与否 char ch; //获取字符的缓冲区,getch使用 enum symbol sym; //当前的符号 char id[al+1]; //当前ident,多出的一个字节用于存放0 int num; //当前number int cc,ll; //getch使用的计数器,cc表示当前字符(ch)的位置 int cx; //虚拟机代码指针,取值范围[0,cxmax-1] char line[81]; //读取行缓冲区 char a[al+1]; //临时符号,多出的一个字节用于存放0 struct instruction code[cxmax]; //存放虚拟机代码的数组 char word[norw][al]; //保留字 enum symbol wsym[norw]; //保留字对应的符号值 enum symbol ssym[256]; //单字符的符号值 char mnemonic[fctnum][5]; //虚拟机代码指令名称 bool declbegsys[symnum]; //表示声明开始的符号集合 bool statbegsys[symnum]; //表示语句开始的符号集合 bool facbegsys[symnum]; //表示因子开始的符号集合 //名字表结构 struct tablestruct { char name[al]; //名字 enum object kind; //类型:const,var,array or procedure int val; //数值,仅const使用 int level; //所须层,仅const不能用 int adr; //地址,仅const不能用 int size; //需要分配的数据空间,仅procedure使用 }; struct tablestruct table[txmax]; //名字表 FILE * fin; FILE * fout; char fname[al]; int err; //错误计数器 //当函数中发生fatal error时,返回-1告知调用它的函数,最终退出程序 #define getsymdo if(-1==getsym()) return -1 #define getchdo if(-1==getch()) return -1 #define testdo(a,b,c) if(-1==test(a,b,c)) return -1 #define gendo(a,b,c) if(-1==gen(a,b,c)) return -1 #define expressiondo(a,b,c) if(-1==expression(a,b,c)) return -1 #define factordo(a,b,c) if(-1==factor(a,b,c)) return -1 #define termdo(a,b,c) if(-1==term(a,b,c)) return -1 #define conditiondo(a,b,c) if(-1==condition(a,b,c)) return -1 #define statementdo(a,b,c) if(-1==statement(a,b,c)) return -1 #define constdeclarationdo(a,b,c) if(-1==constdeclaration(a,b,c)) return -1 #define vardeclarationdo(a,b,c) if(-1==vardeclaration(a,b,c)) return -1 void error(int n); int getsym(); int getch(); void init(); int gen(enum fct x,int y ,int z); int test(bool *s1,bool *s2,int n); int inset(int e,bool *s); int addset(bool *str,bool * s1,bool * s2,int n); int subset(bool *str,bool * s1,bool * s2,int n); int mulset(bool *str,bool * s1,bool * s2,int n); int block(int lev,int tx,bool * fsys); void interpret(); int factor(bool * fsys,int * ptx,int lev); int term(bool * fsys,int * ptx,int lev); int condition(bool * fsys,int * ptx,int lev); int expression(bool * fsys,int * ptx,int lev); int statement(bool * fsys,int * ptx,int lev); void listcode(int cx0); int vardeclaration(int *ptr, int lev,int *ptx); int constdeclaration(int *ptr, int lev,int *ptx); int position(char * idt,int tx); void enter(enum object k,int * ptx,int lev, int * pdx); int base(int l,int * s,int b)
Platform: | Size: 25139 | Author: xqq771084591 | Hits:

[ELanguagepl0withc

Description: 它是VC++6.0下面的一个项目,该目录包括PL/0编译器的源代码。 PL0/debug下面是已经编译成功的PL/0编译器:PL0.exe。该小编译器可以处理一些简单的 利用PL/0语言书写的程序。例如,PL0/debug下面的test.PL0就是一个简单的 PL/0 程序。 运行PL0.exe, 并把test.pl0提供给PL0.exe,处理结果将保存在test.out 中。 注:test.pl0 和 test.out 可以用Notepad(记事本)软件打开。 -VC it is below 6.0 of a project, the directory includes PL/0 compiler source code. PL0/debug Below are already successful compile PL/0 compiler : PL0.exe. The small compiler can handle some simple use of PL/0 language written procedures. For example, the test.PL0 PL0/debug Below is a simple PL/0 procedures. PL0.exe operation, and to provide test.pl0 PL0.exe. the results will be kept in test.out China. Note : test.pl0 and test.out can use Notepad (notebook) software open.
Platform: | Size: 202752 | Author: coca | Hits:

CodeBus www.codebus.net