编译实验指导书

上传人:z**** 文档编号:77066856 上传时间:2022-04-19 格式:DOC 页数:47 大小:545.50KB
收藏 版权申诉 举报 下载
编译实验指导书_第1页
第1页 / 共47页
编译实验指导书_第2页
第2页 / 共47页
编译实验指导书_第3页
第3页 / 共47页
资源描述:

《编译实验指导书》由会员分享,可在线阅读,更多相关《编译实验指导书(47页珍藏版)》请在装配图网上搜索。

1、编译原理实验指导书 实验一 源程序的输入和预处理 一、实验目的 掌握字符处理的方法,理解设计为独立子程序的好处,为词法分析做好准备。 二、实验内容 首先编制一个源程序的输入过程, 从键盘、 文件或文本框输入若干行语句, 依次存入输 入缓冲区(字符型数据) ;然后编制一个预处理子程序,去掉输入串中的回车符、换行符和 跳格符等编辑性文字;把多个空白符号并为一个;去掉注释。 假定要处理的语言采用自由格式书写,空白符作为分隔符,可以使用注解,用 /*……*/ 或者{……}标识,但注解不能插在单词内部,注解要在一行内结束,若一行结束,没有遇到 注释后面的结束标记,自动认为注释也结束。 三

2、、 实验报告要求 1、 写出编程思路、源代码; 2、 写出上机调试时发现的问题,以及解决的过程; 3、 写出所使用的测试数据; 4、 谈谈体会。 四、 上交 1、实验报告; 2、程序源文件(老师检查) 。 实验二词法分析器(设计性实验) 、实验目的 掌握词法分析的概念,设计方法,熟悉高级语言中词法的定义,词法分析程序的编写。 、实验内容 实现PL/O语言的词法分析器, 输入源程序,并对其进行扫描和分解, 识别出单词符号 PL/O语言词法规则定义如下: 1、唯一的数据类型是整型; ,'/ ' '' ' , ('丿 ' ' 3、标识符以字母开头,后跟字母和 /或

3、数字组成的字符串; 2、算符和界符有:'+ ','-: '* '丿'厂,‘>'丿'>='丿 丿'丿'<=丿 '=','<> '丿 4、关键字作为保留字,如下所示: con st, var, procedure, call, begi n, end, if, the n. while , do, odd 三、实验要求 1、单词符号输出形式为(种别编码,单词符号自身值 ) 种别编码如下: 别 类 词 单 码 编 别 类 词 单 码 编 别 类 词 单 码 编 关键字 st con 1 d 1 1 > V 21 r a

4、V 2 算符和界符 + 2 2 2 3 - 3 /_k 3 2 call 4 * 4 1 \!7 24 ・ g e b 5 / 5 5 2 e 6 > 6 1 6 2 7 = > 7 1 27 8 V 8 符 识 标 8 2 g N w 9 = V 9 I 9 2 o 1 一一 O 2 附加:1、检查是否有误 单词/ ERROR,编码/ 30) 2、词法分析器要求设计成为独立的子程序。 3、测试数据举例: const

5、 m = 7, n = 85; var x, y, z, q, r; procedure multiply; var a, b; begin a := x; b := y; z := 0; while b > 0 do begin if odd b then z := z + a; a := 2 * a; b := b / 2; end end; procedure divide; var w; begin r := x; q := 0; w := y; while w > y do begin q := 2 * q; w := w / 2; if w <= r

6、then begin r := r - w; q := q + 1; end; end end; procedure gcd; var f, g; begin f := x; g := y; while f <> g do begin if f < g then g := g - f; if g < f then f := f - g; end end; begin x := m; y := n; call multiply; x := 25; y := 3; call divide; x := 34; y := 36; call gcd; end. 四、实

7、验报告要求 1、写出编程思路; 2、写出上机调试时发现的问题,以及解决的过程; 3、写出所使用的测试数据及结果; 4、谈谈体会。 五、上交 1、实验报告; 2、程序源文件(老师检查) 实验三 算符优先分析器(综合性实验) 一、实验目的 掌握 FirstVT 和 LastVT 集的算法,算符优先分析表的构造算法及其分析过程,并掌握 中间代码产生过程。 二、实验内容 算术表达式和赋值语句的文法可以是(可以根据需要适当改变) : St i=E Et E+E|E-E|E*E|E/E| (E) |i 根据算符优先分析法, 将赋值语句进行语法语义分析, 翻译成等价的一组基本操

8、作, 每 一基本操作用四元式表示。 三、实验过程和指导 1、构造 FirstVT 和 LastVT 集合 给定一个上下文无关文法,根据算法设计一个程序,求文法中每个非终结符的 FirstVT 集和 LastVT 集。 算符描述如下: /*求 FirstVT 集的算法 */ PROCEDURE insert(P,a); IF not F[P,a] then begin f[p,a] = true; (P,a) 进栈 end; Procedure FirstVT; Begin for 对每个非终结符 P 和终结符 a do F[P,a] = false for对每个形

9、如 Pt a…或 Pt Qa…的产生式 do Insert(P,a) while stack 非空 begin 栈顶项出栈,记为 (Q,a) for 对每条形如 Pt Q…的产生式 do insert(P,a) end; end. 2、构造算符优先分析表 依据文法和求出的相应 FirstVT 和 LastVT 集生成算符优先分析表。 算法描述如下: for 每个形如 P->X1X2 … Xn 的产生式 do for i =1 to n-1 do begin if Xi 和 Xi+1 都是终结符 then Xi = Xi+1 if i<= n-2, Xi 和 Xi

10、+2 是终结符 , 但 Xi+1 为非终结符 then Xi = Xi+2 if Xi 为终结符 , Xi+1 为非终结符 then for FirstVT 中的每个元素 a do Xi < a ; if Xi 为非终结符 , Xi+1 为终结符 then for LastVT 中的每个元素 a do a > Xi+1 ; end; 3、构造算符优先分析和中间代码产生过程。 四、输入数据和输出数据 若输入文法: E->E+T | T T->T*F | F F-> (E) | i + ( i E 的 firstVT 1 1 1 1 E

11、的 firstVT 1 I l E 的 firstVT 1 1 输出的优先关系表如下: + * 1 ( ) n + > * > > i ■*-u. ( V v ) 二〉 ^2 若输入的语句是 a:=b+c*(e-a) 则输出: (-,e,a,T1) (*,c,T1,T2) (+,b,T2,T3) (:=,T3,_,a) 实验四 PL/O编译器的分析和理解 一、 实验目的 通过阅读

12、PL/0编译器,理解整个编译过程,掌握编译每一阶段的实现方法; 并加深对理论知识的认识。 二、 实验要求 阅读PL/0编译器,完成以下任务: 1、 画出整个程序流程图及各编译阶段处理的流程图; 2、 写出每一编译阶段实现中用到的主要理论,及对该理论的理解; 3、 写出你的心得和体会。 4、 就上述部分写出实验报告,A4纸(10页以内)。(初步这样定) 三、 实验提示 3、语句序列 语句序列 begin 4、语句 *1 “ 一 A ・ 表达式 ide nt J

13、 fc r i L call J ide nt j r 7 L end j 5、条件 6、表达式 7、项 8、因子 (二)语法分析 这里采用递归下降的方法来设计PL/O编译器。以下我们给出该

14、语言的FIRST 和FOLLOW集合。 非终结符(S) FIRST(S) FOLLOW(S) 程序体 const var procedure ide nt call if begi n while 语句 : ide nt call begi n if while .;end 条件 odd + - ( ide nt nu mber the n do 表达式 + - ( ide nt nu mber .;)R end then do 项 ide nt nu mber ( .;)R + - end the n do 因子 ide nt nu mber (

15、 .;)R + - * / end then do 注:表中R代表六个关系运算符 (三)PL/O处理机的指令集 根据PL/O语言的要求,它包括以下的指令: (1) LIT (2) LOD (3) STO (4) CAL (5) INT (6)JMP, JPC (7) OPR /*将常数置于栈顶*/ /*将变量值置于栈顶*/ /*将栈顶的值赋与某变量*/ /*用于过程调用的指令*/ /*在数据栈中分配存贮空间*/ /*用于if, while语句的条件或无条件控制转移指令 */ /* 一组算术或逻辑运算指令 */ F L A 其中,f,

16、 I, a的含义见下表: F L a INT 常 量 LIT 常 量 LOD 层次差 数据地址 STO 层次差 数据地址 CAL 层次差 程序地址 JMP 程序地址 JPC 程序地址 OPR 运算类别 四) PL/0 语言编译器源程序 PL/0 语言编译器源程序包括如下 C 程序文件, PL0.h、PL0.c、set.h 和 set.c。 ********** PL0.h *********** #include #define NRW 11 // number of reserved wo

17、rds #define TXMAX 500 // length of identifier table #define MAXNUMLEN 14 // maximum number of digits in numbers #define NSYM 10 // maximum number of symbols in array ssym and csym #define MAXIDLEN 10 // length of identifiers #define MAXADDRESS 32767 #define MAXLEVEL 32 #define CXMAX 500

18、 // maximum address // maximum depth of nesting block // size of code array #define MAXSYM 30 // maximum number of symbols #define STACKSIZE 1000 // maximum storage enum symtype { SYM_NULL, SYM_IDENTIFIER, SYM_NUMBER, SYM_PLUS, SYM_MINUS, SYM_TIMES, SYM_SLASH, SYM_ODD, SYM_EQU, SYM_N

19、EQ, SYM_LES, SYM_LEQ, SYM_GTR, SYM_GEQ, SYM_LPAREN, SYM_RPAREN, SYM_COMMA, SYM_SEMICOLON, SYM_PERIOD, SYM_BECOMES, SYM_BEGIN, SYM_END, SYM_IF, SYM_THEN, SYM_WHILE, SYM_DO, SYM_CALL, SYM_CONST, SYM_VAR, SYM_PROCEDURE }; enum idtype { ID_CONSTANT, ID_V ARIABLE, ID_PROCEDURE }; enum opcod

20、e { LIT, OPR, LOD, STO, CAL, INT, JMP, JPC }; enum oprcode { OPR_RET, OPR_NEG, OPR_ADD, OPR_MIN, OPR_MUL, OPR_DIV, OPR_ODD, OPR_EQU, OPR_NEQ, OPR_LES, OPR_LEQ, OPR_GTR, OPR_GEQ }; typedef struct { int f; // function code int l; // level int a; // displacement address } instruction; ////

21、////////////////////////////////////////////////////////////////// char* err_msg[] = { /* 0 */ Illi J /* 1 */ "Found ':=' when expecting '='.", /* 2 */ "There must be a number to follow '='.", /* 3 */ "There must be an '=' to follow the identifier.", /* 4 */ "There must be an ident

22、ifier to follow 'const', 'var', or 'procedure'. /* 5 */ "Missing ',' or ';'.", /* 6 */ "Incorrect procedure name.", /* 7 */ "Statement expected.", /* 8 */ "Follow the statement is an incorrect symbol.", /* 9 */ "'.' expected.", /* 10 */ "';' expected.", /* 11 */ "Undeclared identifier.

23、", /* 12 */ "Illegal assignment.", /* 13 */ "':=' expected.", /* 14 */ "There must be an identifier to follow the 'call'.", /* 15 */ "A constant or variable can not be called.", /* 16 */ "'then' expected.", /* 17 */ "';' or 'end' expected.", /* 18 */ "'do' expected.", /* 19 */ "Incor

24、rect symbol.", /* 20 */ "Relative operators expected.", /* 21 */ "Procedure identifier can not be in an expression.", /* 22 */ "Missing ')'.", /* 23 */ "The symbol can not be followed by a factor.", /* 24 */ "The symbol can not be as the beginning of an expression.", /* 25 */ "The number

25、 is too great.", /* 26 */ Illi J /* 27 */ Illi J /* 28 */ Illi J /* 29 */ Illi J /* 30 */ Illi J /* 31 */ Illi J /* 32 */ "There are too many levels." }; ////////////////////////////////////////////////////////////////////// char ch; // last character read int sym; // last

26、 symbol read char id[MAXIDLEN + 1]; // last identifier read int num; // last number read int cc; // character count int ll; // line length int kk; int err; int cx; // index of current instruction to be generated. int level = 0; int tx = 0; char line[80]; instruction c

27、ode[CXMAX]; char* word[NRW + 1] = { "", /* place holder */ "begin", "call", "const", "do", "end","if", "odd", "procedure", "then", "var", "while" }; int wsym[NRW + 1] = { SYM_NULL, SYM_BEGIN, SYM_CALL, SYM_CONST, SYM_DO, SYM_END, SYM_IF, SYM_ODD, SYM_PROCEDURE, SYM_THEN, SYM_V AR, SYM_WHIL

28、E }; int ssym[NSYM + 1] = { SYM_NULL, SYM_PLUS, SYM_MINUS, SYM_TIMES, SYM_SLASH, SYM_LPAREN, SYM_RPAREN, SYM_EQU, SYM_COMMA, SYM_PERIOD, SYM_SEMICOLON }; char csym[NSYM + 1] = { ' ', '+', '-', '*', '/', '(', ')', '=', ',', '.', ';' }; #define MAXINS 8 char* mnemonic[MAXINS] = { "LIT",

29、"OPR", "LOD", "STO", "CAL", "INT", "JMP", "JPC" }; typedef struct { char name[MAXIDLEN + 1]; int kind; int value; } comtab; comtab table[TXMAX]; typedef struct { char name[MAXIDLEN + 1]; int kind; short level; short address; } mask; FILE* infile; // EOF PL0.h #ifndef SET_H #define S

30、ET_H typedef struct snode { int elem; struct snode* next; } snode, *symset; symset phi, declbegsys, statbegsys, facbegsys, relset; symset createset(int data, .../* SYM_NULL */); void destroyset(symset s); symset uniteset(symset s1, symset s2); int inset(int elem, symset s); #endif // EOF

31、set.h #include #include #include #include "set.h" symset uniteset(symset s1, symset s2) { symset s; snode* p; s = p = (snode*) malloc(sizeof(snode)); while (s1 && s2) { p->next = (snode*) malloc(sizeof(snode)); p = p->next; if (s1->elem < s2->elem) { p->

32、elem = s1->elem; s1 = s1->next; } else { p->elem = s2->elem; s2 = s2->next; } } while (s1) { p->next = (snode*) malloc(sizeof(snode)); p = p->next; p->elem = s1->elem; s1 = s1->next; } while (s2) { p->next = (snode*) malloc(sizeof(snode)); p = p->next; p->elem = s2->elem; s2 = s2->nex

33、t; p->next = NULL; return s; } // uniteset void setinsert(symset s, int elem) { snode* p = s; snode* q; while (p->next && p->next->elem < elem) { p = p->next; } q = (snode*) malloc(sizeof(snode)); q->elem = elem; q->next = p->next; p->next = q; } // setinsert symset createset(int elem,

34、.../* SYM_NULL */) { va_list list; symset s; s = (snode*) malloc(sizeof(snode)); s->next = NULL; va_start(list, elem); while (elem) { setinsert(s, elem); elem = va_arg(list, int); } va_end(list); return s; } // createset void destroyset(symset s) { snode* p; while (s) { p = s; s =

35、s->next; free(p); } } // destroyset int inset(int elem, symset s) { s = s->next; while (s && s->elem < elem) s = s->next; if (s && s->elem == elem) return 1; else return 0; } // inset // EOF set.c // pl0 compiler source code #include #include #include

36、 #include #include "set.h" #include "pl0.h" ////////////////////////////////////////////////////////////////////// // print error message. void error(n) { int i; printf(" "); for (i = 1; i <= cc - 1; i++) printf(" "); prin tf("A\n"); printf("Error %3d: %s\n", n, err_msg[n]); err

37、++; } // error ////////////////////////////////////////////////////////////////////// void getch(void) { if (cc == ll) { if (feof(infile)) { printf("\nPROGRAM INCOMPLETE\n"); exit(1); } ll = cc = 0; printf("%5d ", cx); while (!feof(infile) && (ch = getc(infile))!='\n') { printf("%c", ch)

38、; line[++ll] = ch; } // while printf("\n"); line[++ll] = ' '; } ch = line[++cc]; } // getch ////////////////////////////////////////////////////////////////////// // gets a symbol from input stream. void getsym(void) { int i, k; char a[MAXIDLEN + 1]; while (ch == ' ') getch(); if (isalp

39、ha(ch)) { // symbol is a reserved word or an identifier. k = 0; do { if (k < MAXIDLEN) a[k++] = ch; getch(); } while (isalpha(ch) || isdigit(ch)); a[k] = 0; strcpy(id, a); word[0] = id; i = NRW; while (strcmp(id, word[i--])); if (++i) sym = wsym[i]; // symbol is a reserved word else sym

40、 = SYM_IDENTIFIER; // symbol is an identifier } else if (isdigit(ch)) { // symbol is a number. k = num = 0; sym = SYM_NUMBER; do { num = num * 10 + ch - '0'; k++; getch(); while (isdigit(ch)); if (k > MAXNUMLEN) error(25); // The number is too great. } else if (ch == ':') { getch();

41、if (ch == '=') { sym = SYM_BECOMES; // := getch(); } else { sym = SYM_NULL; // illegal? } } else if (ch == '>') { getch(); if (ch == '=') { sym = SYM_GEQ; // >= getch(); } else { sym = SYM_GTR; // > } } else if (ch == '<') { getch(); if (ch == '=') { sym = SYM_LEQ; // <= getch

42、(); } else if (ch == '>') { sym = SYM_NEQ; // <> getch(); } else sym = SYM_LES; // < } } else { // other tokens i = NSYM; csym[0] = ch; while (csym[i--] != ch); if (++i) { sym = ssym[i]; getch(); } else { printf("Fatal Error: Unknown character.\n"); exit(1); } } } // getsym

43、 ////////////////////////////////////////////////////////////////////// // generates (assembles) an instruction. void gen(int x, int y, int z) { if (cx > CXMAX) { printf("Fatal Error: Program too long.\n"); exit(1); } code[cx].f = x; code[cx].l = y; code[cx++].a = z; } // gen //////////////

44、//////////////////////////////////////////////////////// // tests if error occurs and skips all symbols that do not belongs to s1 or s2. void test(symset s1, symset s2, int n) { symset s; if (! inset(sym, s1)) { error(n); s = uniteset(s1, s2); while(! inset(sym, s)) getsym(); destroyset(s);

45、 } } // test ////////////////////////////////////////////////////////////////////// int dx; // data allocation index // enter object(constant, variable or procedre) into table. void enter(int kind) { mask* mk; tx++; strcpy(table[tx].name, id); table[tx].kind = kind; switch (kind) { case

46、ID_CONSTANT: if (num > MAXADDRESS) { error(25); // The number is too great. num = 0; } table[tx].value = num; break; case ID_VARIABLE: mk = (mask*) &table[tx]; mk->level = level; mk->address = dx++; break; case ID_PROCEDURE: mk = (mask*) &table[tx]; mk->level = level; break; } // switch }

47、// enter ////////////////////////////////////////////////////////////////////// // locates identifier in symbol table. int position(char* id) int i; strcpy(table[0].name, id); i = tx + 1; while (strcmp(table[--i].name, id) != 0); return i; } // position ////////////////////////////////////

48、////////////////////////////////// void constdeclaration() { if (sym == SYM_IDENTIFIER) { getsym(); if (sym == SYM_EQU || sym == SYM_BECOMES) { if (sym == SYM_BECOMES) error(1); // Found ':=' when expecting '='. getsym(); if (sym == SYM_NUMBER) { enter(ID_CONSTANT); getsym(); } else {

49、 error(2); // There must be a number to follow '='. } } else { error(3); // There must be an '=' to follow the identifier. } } error(4); // There must be an identifier to follow 'const', 'var', or 'procedure'. } // constdeclaration ///////////////////////////////////////////////////////////

50、/////////// void vardeclaration(void) { if (sym == SYM_IDENTIFIER) { enter(ID_V ARIABLE); getsym(); } else { error(4); // There must be an identifier to follow 'const', 'var', or 'procedure'. } } // vardeclaration ////////////////////////////////////////////////////////////////////// v

51、oid listcode(int from, int to) { int i; printf("\n"); for (i = from; i < to; i++) { printf("%5d %s\t%d\t%d\n", i, mnemonic[code[i].f], code[i].l, code[i].a); } printf("\n"); } // listcode ////////////////////////////////////////////////////////////////////// void factor(symset fsys) { v

52、oid expression(); int i; symset set; test(facbegsys, fsys, 24); // The symbol can not be as the beginning of an expression. while (inset(sym, facbegsys)) { if (sym == SYM_IDENTIFIER) { if ((i = position(id)) == 0) { error(11); // Undeclared identifier. } else { switch (table[i].kind)

53、{ mask* mk; case ID_CONSTANT: gen(LIT, 0, table[i].value); break; case ID_VARIABLE: mk = (mask*) &table[i]; gen(LOD, level - mk->level, mk->address); break; case ID_PROCEDURE: error(21); // Procedure identifier can not be in an expression. break; } // switch } getsym(); } else if (sym == S

54、YM_NUMBER) { if (num > MAXADDRESS) { error(25); // The number is too great. num = 0; } gen(LIT, 0, num); getsym(); } else if (sym == SYM_LPAREN) { getsym(); set = uniteset(createset(SYM_RPAREN, SYM_NULL), fsys); expression(set); destroyset(set); if (sym == SYM_RPAREN) { getsym(); } e

55、lse { error(22); // Missing ')'. } } test(fsys, createset(SYM_LPAREN, SYM_NULL), 23); } // while } // factor ////////////////////////////////////////////////////////////////////// void term(symset fsys) { int mulop; symset set; set = uniteset(fsys, createset(SYM_TIMES, SYM_SLASH, SYM_NULL

56、)); factor(set); while (sym == SYM_TIMES || sym == SYM_SLASH) { mulop = sym; getsym(); factor(set); if (mulop == SYM_TIMES) { gen(OPR, 0, OPR_MUL); } else { gen(OPR, 0, OPR_DIV); } } // while destroyset(set); } // term //////////////////////////////////////////////////////////////////

57、//// void expression(symset fsys) { int addop; symset set; set = uniteset(fsys, createset(SYM_PLUS, SYM_MINUS, SYM_NULL)); if (sym == SYM_PLUS || sym == SYM_MINUS) { addop = sym; getsym(); term(set); if (addop == SYM_MINUS) { gen(OPR, 0, OPR_NEG); } } else { term(set); } while (sy

58、m == SYM_PLUS || sym == SYM_MINUS) { addop = sym; getsym(); term(set); if (addop == SYM_PLUS) { gen(OPR, 0, OPR_ADD); } else { gen(OPR, 0, OPR_MIN); } } // while destroyset(set); } // expression ////////////////////////////////////////////////////////////////////// void condition(symset f

59、sys) { int relop; symset set; if (sym == SYM_ODD) { getsym(); expression(fsys); gen(OPR, 0, 6); } else { set = uniteset(relset, fsys); expression(set); destroyset(set); if (! inset(sym, relset)) { error(20); } else { relop = sym; getsym(); expression(fsys); switch (relop) { case SYM

60、_EQU: gen(OPR, 0, OPR_EQU); break; case SYM_NEQ: gen(OPR, 0, OPR_NEQ); break; case SYM_LES: gen(OPR, 0, OPR_LES); break; case SYM_GEQ: gen(OPR, 0, OPR_GEQ); break; case SYM_GTR: gen(OPR, 0, OPR_GTR); break; case SYM_LEQ: gen(OPR, 0, OPR_LEQ); break; } // switch } // else } // else } /

61、/ condition ////////////////////////////////////////////////////////////////////// void statement(symset fsys) { int i, cx1, cx2; symset set1, set; if (sym == SYM_IDENTIFIER) { // variable assignment mask* mk; if (! (i = position(id))) { error(11); // Undeclared identifier. } else if (t

62、able[i].kind != ID_V ARIABLE) { error(12); // Illegal assignment. i = 0; } getsym(); if (sym == SYM_BECOMES) { getsym(); } else { error(13); // ':=' expected. } expression(fsys); mk = (mask*) &table[i]; if (i) { gen(STO, level - mk->level, mk->address); } } else if (sym == SYM_CAL

63、L) { // procedure call getsym(); if (sym != SYM_IDENTIFIER) { error(14); // There must be an identifier to follow the 'call'. } else { if (! (i = position(id))) { error(11); // Undeclared identifier. } else if (table[i].kind == ID_PROCEDURE) { mask* mk; mk = (mask*) &table[i]; gen(CAL,

64、level - mk->level, mk->address); } else { error(15); // A constant or variable can not be called. } getsym(); } } else if (sym == SYM_IF) { // if statement getsym(); set1 = createset(SYM_THEN, SYM_DO, SYM_NULL); set = uniteset(set1, fsys); condition(set); destroyset(set1); destroyset(set);

65、 if (sym == SYM_THEN) { getsym(); } else { error(16); // 'then' expected. } cx1 = cx; gen(JPC, 0, 0); statement(fsys); code[cx1].a = cx; } else if (sym == SYM_BEGIN) { // block getsym(); set1 = createset(SYM_SEMICOLON, SYM_END, SYM_NULL); set = uniteset(set1, fsys); statement(set);

66、 while (sym == SYM_SEMICOLON || inset(sym, statbegsys)) { if (sym == SYM_SEMICOLON) { getsym(); } else { error(10); } statement(set); } // while destroyset(set1); destroyset(set); if (sym == SYM_END) { getsym(); } else { } else if (sym == SYM_WHILE) { // while statement cx1 = cx; getsym(); set1 = createset(SYM_DO, SYM_NULL); set = uniteset(set1, fsys); condition(set); destroyset(set1); destroyset(set); cx2 = cx; gen(JPC, 0, 0); if (sym == SYM_DO) { getsym(); } els

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

相关资源

更多
正为您匹配相似的精品文档
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!