东南大学编译原理期末复习.pptVIP

  • 165
  • 0
  • 约5.17千字
  • 约 51页
  • 2017-07-02 发布于浙江
  • 举报
东南大学编译原理期末复习

Review 6.Important knowledge points Chapter 5 Attribute Annotated parsing tree Construct an annotated parsing tree for an expression (S-attribute) Syntax-directed definition S-attribute Grammar and evaluation of S-attribute Construct semantic rules for a S-attribute grammar Please construct an annotated parse tree for the input string 111.0111 where the syntax-directed definition is as following: Productions Semantic Rules S?L1.L2 {S.val=L1.val+L2.val/2L2.len} S?L {S.val=L.val} L?L1B {L.val=L1.val*2+B.val, L.len=L1.len+1} L?B {L.val=B.val,L.len=1} B?0 {B.val=0} B?1 {B.val=1} Review 6.Important knowledge points Chapter 6 Type Type expression Construct a type expression for a declaration Review 6.Important knowledge points Chapter 7 Stack-based storage allocation Activation Record Form C language program Recursive function Pascal language program Display Construct a maximum stack map for a C recursive program We assume that the storage organization and the form of activation record used in C language program run-time stack storage allocation are as above. Please construct the run-time stack map when it gets the maximum size for the following C program. The C program is as the following: #include stdio.h int x,y,z; int main() { x=35; y=40; z=f(x,y); } int f(int m, int n) { if (nm) { int t; t=f(n,m); return t } else if (n==0) return m; else { int t1,t2; t1=m % n; //remainder of m/n t2=f(n,t1); return t2 } } Notes: 1) Here we assume that the caller’s sp of Main function is the start address of global variable data area, and the returned address in the activation record of a function (including Main function) is filled by the operating system automatically, you might not care it. 2) The initial value of variable X and Y are 35 and 40 respectively, the start address of stack used in the program is K. Review 1.Structure of the cou

文档评论(0)

1亿VIP精品文档

相关文档