SlideShare a Scribd company logo
2
Most read
Classification Of Compiler
Sandeep Kumar 11500117059
Maharaj Dey 11500117099
Compiler Design
Classification Of Compiler
Role of Operator Precedence Parser
Introduction :
Operator Precedence Parser constructed for operator
precedence grammar. Operator precedence grammar is a
grammar that doesn’t contain epsilon productions and does
not contain two adjacent non-terminals on R.H.S. of any
production. Operator precedence grammar is provided with
precedence rules. Operator Precedence grammar could be
either ambiguous or unambiguous.
Algorithm for construction of Precedence
function :
Generate a function Xa for each grammar terminal a and for the end of the string
symbol.
Partition the symbol in groups so that Xa and Yb are the same groups if a ≐ b.
Generate a directed graph whose nodes are in the groups, for each symbol a and b, do
place an edge from the group of Yb to the group of Xa if a ⋖ b, otherwise if a ⋗ b place
an edge from the group of Xa to that of Yb.
If the constructed graph has a cycle then no procedure functions exist. When there are
no cycles collect the length of the longest paths from the groups of Xa and yb
respectively.
Example –
Let’s take an example to understand the construction of precedence function as
follows.
E -> E + E/E * E/( E )/id
Here, you will see the Operator precedence relation table and Precedence Relations
Graph diagram. Let’s have a look.
Precedence Relations Graph
Columns Representation function :
Columns represent function Ya and Rows represent
function Xa –
It is calculated by taking the longest path from Xid to X$
and Yid to Y$.
fid -> g* -> f+ ->g+ -> f$ gid -> f* -> g* ->f+ -> g+ ->f$
Function table
Pros and Cons:
1.The disadvantage of the operator precedence relation table is that if
there are ‘n’ numbers of symbols then we require a table of n*n to store
them. On other hand, by using the operator function table, to
accommodate n number of symbols we require a table of 2*n. Operator
Precedence Grammar cannot decide the unary minus(lexical analyzer
should handle the unary minus).
2.The advantage of using Operator Precedence Grammar is simple and
enough powerful for expression in programming languages.
Error Recovery in Operator-Precedence Parsing :
• Error Cases –
1. No relation holds between the terminal on the top of the stack and the next
input symbol.
2. A handle is found (reduction step), but there is no production with this handle as
a right side.
• Error recovery –
1. Each empty entry is filled with a pointer to an error routine.
2. Decides the popped handle “looks like” which right-hand side. And tries to
recover from that situation.
• Handling shift/ reduce errors –
To take care of such types of errors we must modify the following.
1. Stack
2. Input
Classification of Compiler

More Related Content

PDF
Assignment6
PPTX
Infix-Postfix expression conversion
PPTX
Stack data structure
PDF
Tricks
PPTX
Evaluation of postfix expression
PPTX
Infix to postfix
PPTX
Unit 3 stack
PPTX
Basic operators in matlab
Assignment6
Infix-Postfix expression conversion
Stack data structure
Tricks
Evaluation of postfix expression
Infix to postfix
Unit 3 stack
Basic operators in matlab

What's hot (19)

PDF
Lesson 5 .1 selection structure
PPTX
Polish
PDF
Applications of stack
PDF
Lesson 5.2 logical operators
PPSX
Stacks Implementation and Examples
PPTX
Infix postfixcoversion
PDF
Functional programming-advantages
PDF
Lesson 4.2 5th and 6th step
PDF
PPTX
Unit I - Evaluation of expression
PPT
Operators in C++
PPTX
DATA STRUCTURE - STACK
PDF
Lesson 3.2 data types for memory location
PDF
Lesson 4.1 completing the problem solving process
PPTX
R Programming: Variables & Data Types
PPT
PDF
Lesson 2 beginning the problem solving process
PPTX
Functions in c++
Lesson 5 .1 selection structure
Polish
Applications of stack
Lesson 5.2 logical operators
Stacks Implementation and Examples
Infix postfixcoversion
Functional programming-advantages
Lesson 4.2 5th and 6th step
Unit I - Evaluation of expression
Operators in C++
DATA STRUCTURE - STACK
Lesson 3.2 data types for memory location
Lesson 4.1 completing the problem solving process
R Programming: Variables & Data Types
Lesson 2 beginning the problem solving process
Functions in c++
Ad

Similar to Classification of Compiler (20)

PPTX
Operator precedance parsing
PPTX
Compiler Deisgn-Varrious parsing methods
PDF
Syntactic analysis in NLP
DOCX
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
PPTX
INTRODUCTION TO C PROGRAMMING - PART 2
PDF
CS6660-COMPILER DESIGN-1368874055-CD NOTES-55-150.pdf
PDF
Java 8
PPTX
Introduction to R for beginners
PPTX
BOTTOM_UP_Parsing techniques_compiler design5.pptx
PPTX
Lexhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
PDF
Compiler Design
PPTX
DOCX
Compiler design important questions
PDF
Ch06
PDF
Control system Lab record
PDF
Compiler_Design_Introduction_Unit_2_IIT.pdf
PDF
Compiler unit 2&3
PPTX
Parsing techniques, notations, methods of parsing in compiler design
PPTX
3. Syntax Analyzer.pptx
Operator precedance parsing
Compiler Deisgn-Varrious parsing methods
Syntactic analysis in NLP
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
INTRODUCTION TO C PROGRAMMING - PART 2
CS6660-COMPILER DESIGN-1368874055-CD NOTES-55-150.pdf
Java 8
Introduction to R for beginners
BOTTOM_UP_Parsing techniques_compiler design5.pptx
Lexhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pptx
Compiler Design
Compiler design important questions
Ch06
Control system Lab record
Compiler_Design_Introduction_Unit_2_IIT.pdf
Compiler unit 2&3
Parsing techniques, notations, methods of parsing in compiler design
3. Syntax Analyzer.pptx
Ad

More from maharajdey (7)

PPTX
FInal Year Project Presentation
PPTX
Medern Symmetric -Key Ciphers (AES, DES)
PPTX
Merge Sort vs Quick Sort presentation
PPTX
A* Algorithm
PPTX
Softwere Testing Aplication Specific Techniques
PPTX
Cloud Service Models
PPTX
Travelling salesman dynamic programming
FInal Year Project Presentation
Medern Symmetric -Key Ciphers (AES, DES)
Merge Sort vs Quick Sort presentation
A* Algorithm
Softwere Testing Aplication Specific Techniques
Cloud Service Models
Travelling salesman dynamic programming

Recently uploaded (20)

PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
composite construction of structures.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
DOCX
573137875-Attendance-Management-System-original
PPT
Project quality management in manufacturing
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
R24 SURVEYING LAB MANUAL for civil enggi
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
composite construction of structures.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Mechanical Engineering MATERIALS Selection
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Operating System & Kernel Study Guide-1 - converted.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Internet of Things (IOT) - A guide to understanding
OOP with Java - Java Introduction (Basics)
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
573137875-Attendance-Management-System-original
Project quality management in manufacturing
Automation-in-Manufacturing-Chapter-Introduction.pdf

Classification of Compiler

  • 1. Classification Of Compiler Sandeep Kumar 11500117059 Maharaj Dey 11500117099 Compiler Design
  • 3. Role of Operator Precedence Parser Introduction : Operator Precedence Parser constructed for operator precedence grammar. Operator precedence grammar is a grammar that doesn’t contain epsilon productions and does not contain two adjacent non-terminals on R.H.S. of any production. Operator precedence grammar is provided with precedence rules. Operator Precedence grammar could be either ambiguous or unambiguous.
  • 4. Algorithm for construction of Precedence function : Generate a function Xa for each grammar terminal a and for the end of the string symbol. Partition the symbol in groups so that Xa and Yb are the same groups if a ≐ b. Generate a directed graph whose nodes are in the groups, for each symbol a and b, do place an edge from the group of Yb to the group of Xa if a ⋖ b, otherwise if a ⋗ b place an edge from the group of Xa to that of Yb. If the constructed graph has a cycle then no procedure functions exist. When there are no cycles collect the length of the longest paths from the groups of Xa and yb respectively.
  • 5. Example – Let’s take an example to understand the construction of precedence function as follows. E -> E + E/E * E/( E )/id Here, you will see the Operator precedence relation table and Precedence Relations Graph diagram. Let’s have a look.
  • 7. Columns Representation function : Columns represent function Ya and Rows represent function Xa – It is calculated by taking the longest path from Xid to X$ and Yid to Y$. fid -> g* -> f+ ->g+ -> f$ gid -> f* -> g* ->f+ -> g+ ->f$ Function table
  • 8. Pros and Cons: 1.The disadvantage of the operator precedence relation table is that if there are ‘n’ numbers of symbols then we require a table of n*n to store them. On other hand, by using the operator function table, to accommodate n number of symbols we require a table of 2*n. Operator Precedence Grammar cannot decide the unary minus(lexical analyzer should handle the unary minus). 2.The advantage of using Operator Precedence Grammar is simple and enough powerful for expression in programming languages.
  • 9. Error Recovery in Operator-Precedence Parsing : • Error Cases – 1. No relation holds between the terminal on the top of the stack and the next input symbol. 2. A handle is found (reduction step), but there is no production with this handle as a right side. • Error recovery – 1. Each empty entry is filled with a pointer to an error routine. 2. Decides the popped handle “looks like” which right-hand side. And tries to recover from that situation. • Handling shift/ reduce errors – To take care of such types of errors we must modify the following. 1. Stack 2. Input