Spread Knowledge

Virtual University of Pakistan Video Lectures, Handouts, PPT, Quizzes, Assignments & Papers

CS606 - Compiler Construction - Lecture Handout 41

User Rating:  / 0

Related Content: CS606 - VU Lectures, Handouts, PPT Slides, Assignments, Quizzes, Papers & Books of Compiler Construction

Flow-of-Control Statements

We now use backpatching to translate flow-of-control statements in one pass. We will use the same list-handling procedures as before.

S → if E then S
| if E then S else S
| while E do S
| begin L end
| A
L → L ; S

Read more: CS606 - Compiler Construction - Lecture Handout 41

CS606 - Compiler Construction - Lecture Handout 34

User Rating:  / 0

Related Content: CS606 - VU Lectures, Handouts, PPT Slides, Assignments, Quizzes, Papers & Books of Compiler Construction

Let’s go through an example of using YACC to implement the ad-hoc scheme for an arithmetic calculator.

The YACC file for a calculator grammar is as follows:

%token NUMBER LPAREN RPAREN
%token PLUS MINUS TIMES DIVIDE
%%

Read more: CS606 - Compiler Construction - Lecture Handout 34