SlideShare a Scribd company logo
1 of 19
Supreme
Knowledge
Foundation Group
of Institutions
Name : Ayan Das
Subject : Compiler Design
Paper Code : PCC-CS501
Department : Computer Science and Engineering
University Roll No: 25300121057
Year : 3rd Year
• Parse : It means to resolve (a sentence) into its component parts and
describe their syntactic roles or simply it is an act of parsing a string or a
text.
• Tree: A tree may be a widely used abstract data type that simulates a
hierarchical tree structure, with a root value and sub-trees of youngsters
with a parent node, represented as a group of linked nodes.
Topic :Parsing and Parse Tree
• Parse tree is the graphical representation of symbol. The symbol can be terminal
or non-terminal.
• In parsing, the string is derived using the start symbol. The root of the parse tree
is that start symbol.
• It is the graphical representation of symbol that can be terminals or non-
terminals.
• Parse tree follows the precedence of operators. The deepest sub-tree traversed
first. So, the operator in the parent node has less precedence over the operator in
the sub-tree.
Parse Tree
•All leaf nodes have to be terminals.
• All interior nodes have to be non-terminals.
• In-order traversal gives original input string.
Rules To Draw Parse Tree
• Example 1: Let us take an example of Grammar (Production Rules).
• The input string is “sab”, then the Parse Tree is:
Examples Of Parse Tree
• Example-2: Let us take another example of Grammar (Production Rules).
• The input string is “acbd”,
then the Parse Tree is as follows:
Examples Of Parse Tree
• It helps in making syntax analysis by reflecting the syntax of the
input language.
• It uses an in-memory representation of the input with a structure that
conforms to the grammar.
• The advantages of using parse trees rather than semantic actions:
you’ll make multiple passes over the info without having to re-parse
the input.
Use Of Parse Tree
• A grammar is said to be ambiguous if there exists more than one leftmost
derivation or more than one rightmost derivative or more than one parse
tree for the given input string. If the grammar is not ambiguous then it is
called unambiguous.
Ambiguity
• Example 1:
• For the string aabb, the above grammar generates two parse trees:
• If the grammar has ambiguity then it is not good for a compiler construction. No method can
automatically detect and remove the ambiguity but you can remove ambiguity by re-writing the
whole grammar without ambiguity.
Examples Of Ambiguity
• Derivations mean replacing a given string’s non-terminal by the right-hand side of
the production rule. The sequence of applications of rules that makes the
completed string of terminals from the starting symbol is known as derivation. The
parse tree is the pictorial representation of derivations. Therefore, it is also known
as derivation trees. The derivation tree is independent of the other in which
productions are used.
• A parse tree is an ordered tree in which nodes are labeled with the left side of the
productions and in which the children of a node define its equivalent right parse
tree also known as syntax tree, generation tree, or production tree.
Derivation Tree
Types Of Derivation Tree
• Example 1:
• Solution:
• Yield = Left to Right Ordering of Leaves = aa bb aa
Derivation Tree Example
• The process of deriving a string by expanding the
leftmost non-terminal at each step is called as leftmost
derivation.
• The geometrical representation of leftmost derivation is
called as a leftmost derivation tree.
Leftmost Derivation Tree
• Example 1:
• Solution:
• Leftmost Derivation
• Let us consider a string w = aaabbabbba
• Now, let us derive the string w using leftmost derivation.
Leftmost Derivation Tree
Leftmost Derivation Tree
• The process of deriving a string by expanding the
rightmost non-terminal at each step is called
as rightmost derivation.
• The geometrical representation of rightmost
derivation is called as a rightmost derivation
tree.
Rightmost Derivation Tree
• Example 1:
• Solution:
• Rightmost Derivation
• Let us consider a string w = aaabbabbba
• Now, let us derive the string w using rightmost derivation.
Rightmost Derivation Tree
Rightmost Derivation Tree
Ayan Das_25300121057.pptx

More Related Content

Similar to Ayan Das_25300121057.pptx

relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptx
NirajG3
 

Similar to Ayan Das_25300121057.pptx (20)

Unit III.ppt
Unit III.pptUnit III.ppt
Unit III.ppt
 
Xpath1
Xpath1Xpath1
Xpath1
 
NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar
 
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
Unit-V.pptx DVD is a great way to get sbi and more jobs available review and ...
 
B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 
Farhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructureFarhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructure
 
Xpath.ppt
Xpath.pptXpath.ppt
Xpath.ppt
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
02_Xpath.pdf
02_Xpath.pdf02_Xpath.pdf
02_Xpath.pdf
 
ntroduction to Algorithm 2.pptx
ntroduction to Algorithm 2.pptxntroduction to Algorithm 2.pptx
ntroduction to Algorithm 2.pptx
 
Recursive Descent Parsing
Recursive Descent Parsing  Recursive Descent Parsing
Recursive Descent Parsing
 
relationalDatabaseModel.pptx
relationalDatabaseModel.pptxrelationalDatabaseModel.pptx
relationalDatabaseModel.pptx
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Decision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptxDecision Tree Classification Algorithm.pptx
Decision Tree Classification Algorithm.pptx
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
 
Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3Learn Ruby 2011 - Session 3
Learn Ruby 2011 - Session 3
 
Lecture 22_Trees - II.pptx
Lecture 22_Trees - II.pptxLecture 22_Trees - II.pptx
Lecture 22_Trees - II.pptx
 
Tree Introduction.pptx
Tree Introduction.pptxTree Introduction.pptx
Tree Introduction.pptx
 

More from Ayan974999

More from Ayan974999 (11)

States of a Process in Operating Systems
States of a Process in Operating SystemsStates of a Process in Operating Systems
States of a Process in Operating Systems
 
Firewalls and proxies are both use for security
Firewalls and proxies are both use for securityFirewalls and proxies are both use for security
Firewalls and proxies are both use for security
 
The International Space Station (ISS) is the largest space station to have ev...
The International Space Station (ISS) is the largest space station to have ev...The International Space Station (ISS) is the largest space station to have ev...
The International Space Station (ISS) is the largest space station to have ev...
 
Name.pptx
Name.pptxName.pptx
Name.pptx
 
AYAN DAS_57_SOFT COMPUTING.pptx
AYAN DAS_57_SOFT COMPUTING.pptxAYAN DAS_57_SOFT COMPUTING.pptx
AYAN DAS_57_SOFT COMPUTING.pptx
 
software engineering.pptx
software engineering.pptxsoftware engineering.pptx
software engineering.pptx
 
Computer Network.pptx
Computer Network.pptxComputer Network.pptx
Computer Network.pptx
 
Numerical Methods.pptx
Numerical Methods.pptxNumerical Methods.pptx
Numerical Methods.pptx
 
Gantt Chart.pptx
Gantt Chart.pptxGantt Chart.pptx
Gantt Chart.pptx
 
Ayan Das_25300121057.pptx
Ayan Das_25300121057.pptxAyan Das_25300121057.pptx
Ayan Das_25300121057.pptx
 
Ayan Das_25300121057.pptx
Ayan Das_25300121057.pptxAyan Das_25300121057.pptx
Ayan Das_25300121057.pptx
 

Recently uploaded

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 

Recently uploaded (20)

Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 

Ayan Das_25300121057.pptx

  • 1. Supreme Knowledge Foundation Group of Institutions Name : Ayan Das Subject : Compiler Design Paper Code : PCC-CS501 Department : Computer Science and Engineering University Roll No: 25300121057 Year : 3rd Year
  • 2. • Parse : It means to resolve (a sentence) into its component parts and describe their syntactic roles or simply it is an act of parsing a string or a text. • Tree: A tree may be a widely used abstract data type that simulates a hierarchical tree structure, with a root value and sub-trees of youngsters with a parent node, represented as a group of linked nodes. Topic :Parsing and Parse Tree
  • 3. • Parse tree is the graphical representation of symbol. The symbol can be terminal or non-terminal. • In parsing, the string is derived using the start symbol. The root of the parse tree is that start symbol. • It is the graphical representation of symbol that can be terminals or non- terminals. • Parse tree follows the precedence of operators. The deepest sub-tree traversed first. So, the operator in the parent node has less precedence over the operator in the sub-tree. Parse Tree
  • 4. •All leaf nodes have to be terminals. • All interior nodes have to be non-terminals. • In-order traversal gives original input string. Rules To Draw Parse Tree
  • 5. • Example 1: Let us take an example of Grammar (Production Rules). • The input string is “sab”, then the Parse Tree is: Examples Of Parse Tree
  • 6. • Example-2: Let us take another example of Grammar (Production Rules). • The input string is “acbd”, then the Parse Tree is as follows: Examples Of Parse Tree
  • 7. • It helps in making syntax analysis by reflecting the syntax of the input language. • It uses an in-memory representation of the input with a structure that conforms to the grammar. • The advantages of using parse trees rather than semantic actions: you’ll make multiple passes over the info without having to re-parse the input. Use Of Parse Tree
  • 8. • A grammar is said to be ambiguous if there exists more than one leftmost derivation or more than one rightmost derivative or more than one parse tree for the given input string. If the grammar is not ambiguous then it is called unambiguous. Ambiguity
  • 9. • Example 1: • For the string aabb, the above grammar generates two parse trees: • If the grammar has ambiguity then it is not good for a compiler construction. No method can automatically detect and remove the ambiguity but you can remove ambiguity by re-writing the whole grammar without ambiguity. Examples Of Ambiguity
  • 10. • Derivations mean replacing a given string’s non-terminal by the right-hand side of the production rule. The sequence of applications of rules that makes the completed string of terminals from the starting symbol is known as derivation. The parse tree is the pictorial representation of derivations. Therefore, it is also known as derivation trees. The derivation tree is independent of the other in which productions are used. • A parse tree is an ordered tree in which nodes are labeled with the left side of the productions and in which the children of a node define its equivalent right parse tree also known as syntax tree, generation tree, or production tree. Derivation Tree
  • 12. • Example 1: • Solution: • Yield = Left to Right Ordering of Leaves = aa bb aa Derivation Tree Example
  • 13. • The process of deriving a string by expanding the leftmost non-terminal at each step is called as leftmost derivation. • The geometrical representation of leftmost derivation is called as a leftmost derivation tree. Leftmost Derivation Tree
  • 14. • Example 1: • Solution: • Leftmost Derivation • Let us consider a string w = aaabbabbba • Now, let us derive the string w using leftmost derivation. Leftmost Derivation Tree
  • 16. • The process of deriving a string by expanding the rightmost non-terminal at each step is called as rightmost derivation. • The geometrical representation of rightmost derivation is called as a rightmost derivation tree. Rightmost Derivation Tree
  • 17. • Example 1: • Solution: • Rightmost Derivation • Let us consider a string w = aaabbabbba • Now, let us derive the string w using rightmost derivation. Rightmost Derivation Tree