/*
测试用的程序:
const a=10;
var b,c;
procedure p;
begin
c:=b+a
end;
begin
read(b);
while b#0 do
begin
call p;write(2*c);read(b);
end
end.
*/
#include<stdio.h>
/*#include"pl0.h"*/
#include"string.h"
/*PL/0编译系统C版本头文件pl0.h*/
/*typedef enum{false,true}bool;*/
#define norw 13
#define txmax 100
#define nmax 14
#define al 10
#define amax 2047
#define levmax 3
#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
{
    enum fct f;
    int l;
c语言编译器在线编译闰年
    int a;
};
FILE* fas;
FILE* fa;
FILE* fa1;
FILE* fa2;
bool listswitch;
bool tableswitch;
char ch;
enum symbol sym;
char id[al+1];
int num;
int cc,ll;
int cx;
char line[81];
char a[al+1];
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;
    int val;
    int level;
    int adr;
    int size;
};
struct tablestruct table[txmax];
FILE* fin;
FILE* fout;
char fname[al];
int err;
#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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。