0% found this document useful (0 votes)
4 views2 pages

Unit 2 - Part 1

Parsing is the process of transforming data from one format to another, performed by a parser, which is a phase of a compiler. There are two types of parsing: top-down and bottom-up, with further classifications such as recursive descent and LR parsers. The document also discusses techniques like operator precedence parsing and shift-reduce parsing, detailing their mechanisms and components.

Uploaded by

umairknp2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Unit 2 - Part 1

Parsing is the process of transforming data from one format to another, performed by a parser, which is a phase of a compiler. There are two types of parsing: top-down and bottom-up, with further classifications such as recursive descent and LR parsers. The document also discusses techniques like operator precedence parsing and shift-reduce parsing, detailing their mechanisms and components.

Uploaded by

umairknp2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 2

Parsing
The process of transforming the data from one format to another is called Parsing. This process
can be accomplished by the parser.

Parser
The parser is one of the phase of compiler which takes a token of string as input and converts it
into the corresponding Intermediate Representation (IR) with the help of an existing
grammar. The parser is also known as Syntax Analyzer.
There are two types of Parsing:

 The Top-down Parsing


 The Bottom-up Parsing

 Top-down Parsing: When the parser starts constructing the parse tree from the start
symbol and then tries to transform the start symbol to the input, it is called top-down
parsing.. The top-down parsing initiates with the start symbol and ends on the terminals.
Such parsing is also known as predictive parsing.
Top-down parser is classified into 2 types: 1) Recursive descent parser and 2) non-recursive
descent parser.
1. Recursive descent parser is also known as the Brute force parser or the backtracking parser.
It basically generates the parse tree by using brute force and backtracking techniques.
2. Non-recursive descent parser is also known as LL(1) parser or predictive parser or without
backtracking parser or dynamic parser. It uses a parsing table to generate the parse tree
instead of backtracking.
Bottom-Up Parser
Bottom-up Parser is the parser that generates the parse tree for the given input string with the
help of grammar productions by compressing the terminals. It starts from terminals and ends
upon the start symbol. It uses the rightmost derivation in reverse order.
Bottom-up parser is classified into two types:

 LR parser: LR parser is one of the most efficient syntax analysis techniques as it works
with context-free grammar. In LR parsing L stands for the left to right tracing, and R stands
for the right to left tracing.
 LR parser: This is a bottom-up parser that generates the parse tree for the given string by
using unambiguous grammar. It follows the reverse of the rightmost derivation. LR
parser is classified into four types:
 LR(0)
 SLR(1)
 LALR(1)
 CLR(1)
Operator precedence parser: Operator Precedence Parser generates the parse tree from given
grammar and string but it has the condition that two consecutive non-terminals and epsilon will
never appears on the right-hand side of any production. The operator precedence parsing
technique is applied to Operator grammars.
Shift Reduce Parser
Shift-reduce parsing is a popular bottom-up technique used in syntax analysis, where the goal
is to create a parse tree for a given input based on grammar rules. The process works by
reading a stream of tokens (the input), and then working backwards through the grammar rules
to discover how the input can be generated.
1. Input Buffer: This stores the string or sequence of tokens that needs to be parsed.
2. Stack: The parser uses a stack to keep track of which symbols or parts of the parse it has
already processed. As it processes the input, symbols are pushed onto and popped off the
stack.
3. Parsing Table: Similar to a predictive parser, a parsing table helps the parser decide what
action to take next.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy