Docsity

compiler design subject, Lecture notes of Compiler Design

Partial preview of the text

Download compiler design subject and more Lecture notes Compiler Design in PDF only on Docsity!

Module 2 – Syntax Analysis

Bottom Up Parsing

Parsing Methods

Parsin g Top down parsing Bottom up parsing (Shift reduce) Back tracking Parsing without backtracking (predictive Parsing) LR parsing Operator precedence LALR

CLR

SLR

Recursi ve descen t

LL(1)

Handle & Handle pruning

EE+

E

EE*

E

Eid

String:

id1+id2*id

Rightmost Derivation

E

E+E

E+E*E

E+E*id

E+id2*id

id1+id2*id

Shift reduce parser

• The shift reduce parser performs following basic operations:

1. Shift : Moving of the symbols from input buffer onto the stack, this

action is called shift.

2. Reduce : If handle appears on the top of the stack then reduction of it by

appropriate rule is done. This action is called reduce action.

3. Accept : If stack contains start symbol only and input buffer is empty at

the same time then that action is called accept.

4. Error : A situation in which parser cannot either shift or reduce the

symbols, it cannot even perform accept action then it is called error

action.