Tutorial 5

1 0 0
Tutorial 5

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

Thông tin tài liệu

COMPILER CONSTRUCTION COMPILER CONSTRUCTION Week 11 Tutorial Questions Symbol Tables, Type Checking and Jasmin Code 1 Write method insert(SymEntry sym) for a linear symbol table 2 Write type expressio[.]

COMPILER CONSTRUCTION Week 11 Tutorial Questions Symbol Tables, Type Checking and Jasmin Code Write method insert(SymEntry sym) for a linear symbol table Write type expressions for the folowing types a An array of pointers to floats, where the array index ranges from to 100 b A two-dimensional array of integers whose rows are indexed from to and whose columns are indexed from -10 to 10 Given the following grammar: P→DF D → T id ; D | ∈ F → T id (T id) { D L } F | ∈ L→SL|∈ S → id = E ; | { D L } T → int | float E → INTLIT | FLOATLIT | id | id (E) Write translation schemes: a to keep track of scope (using enterScope, exitScope) b to detect an undeclared variable c to detect a redeclared variable d to detect an undeclared function e to detect a redeclared function f to detect a reference to a variable as a function g to detect a reference to a function as a variable h to detect a type mismatch Given the following grammar that generates a function: F → T id (D) { S } D → T id D | ∈ T → int | boolean S → id (L) L→EL|∈ E → INTLIT | BOOLLIT Write translation schemes to throw: a TooManyArgException b TooFewArgException c TypeMismatchException Write Jasmin code of the following expression: c = (a + b[a] ) * 10.2F where c is a float variable, a is an integer variable and b is an array of integers

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

Tài liệu cùng người dùng

Tài liệu liên quan