Spread Knowledge

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

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

CS606 - Compiler Construction - Lecture Handout 15

User Rating:  / 0

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

Let’s consider the implementation of the C++ classes for the non-terminals. We start with Expr.

bool Expr::isPresent()
{
Term* op1 = new Term(s);
if(!op1->isPresent())
return false;

Read more: CS606 - Compiler Construction - Lecture Handout 15

Page 1 of 464