1. Trang chủ
  2. » Công Nghệ Thông Tin

Tutorial 6

1 3 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 21,48 KB

Nội dung

COMPILER CONSTRUCTION COMPILER CONSTRUCTION Week 13 Tutorial Questions Code Generation 1 Write the equivalent Java program for the following MC program int a,b[3]; float c[4],d; int foo(boolean e,int[.]

COMPILER CONSTRUCTION Week 13 Tutorial Questions Code Generation Write the equivalent Java program for the following MC program: int main() { int a,b[3]; int e[3],f; float c[4],d; for (f = 1; f < 3; f = f +1) int foo(boolean e,int f[]) { e[f] = 0; if (e && (f[1]==0)) foo(true,e); a = 1; repeat else b[0] = a + b[0]; b[1] = a = 2; until (b[0] > 10); return a; return 0; } } Compile and translate to Jasmin code Write the Jasmin code of the above program Given the following grammar: S’ → P P → T id ; P | F F → T id (T id) { D L } F | ∈ D → T id ; D | ∈ L→SL|∈ S→E;|{DL} T → int | float E→T=E|T T→T+U|U U → INTLIT | FLOATLIT| id | id ( E ) | ( E ) Based on the interfaces of SymTable.java, SymEntry.java, Frame.java and Emitter.java, write translation schemes to generate code for: a b c d e f g Jasmin directives: source super class global variable declarations local variable declarations method declarations U T E Eliminating left recursion from T-productions and left factoring E-productions of the above grammar, rewrite translation schemes of 2.f and 2.g

Ngày đăng: 11/04/2023, 11:05

w