Syntax Parsing IT & Software Notes | EduRev

IT & Software : Syntax Parsing IT & Software Notes | EduRev

 Page 1


Parsing and Context-Free 
Grammars 
Page 2


Parsing and Context-Free 
Grammars 
Parsing and CFGs 
? Parsing, or syntax analysis, is the task of 
determining the syntax, or structure, of a 
program. 
? Syntax is described by context-free 
grammar (CFG) rules. 
? There are 2 general methods of parsing, 
called  top down parsing and bottom-up 
parsing.  
Page 3


Parsing and Context-Free 
Grammars 
Parsing and CFGs 
? Parsing, or syntax analysis, is the task of 
determining the syntax, or structure, of a 
program. 
? Syntax is described by context-free 
grammar (CFG) rules. 
? There are 2 general methods of parsing, 
called  top down parsing and bottom-up 
parsing.  
Parsing 
? The parser may be viewed as a function whose 
input is a sequence of tokens and whose output is 
a parse tree. 
? The sequence of tokens results from calls to the 
scanner. 
Parser 
whilestmt 
cond body 
 … ) 10   <   x   (   while 
Page 4


Parsing and Context-Free 
Grammars 
Parsing and CFGs 
? Parsing, or syntax analysis, is the task of 
determining the syntax, or structure, of a 
program. 
? Syntax is described by context-free 
grammar (CFG) rules. 
? There are 2 general methods of parsing, 
called  top down parsing and bottom-up 
parsing.  
Parsing 
? The parser may be viewed as a function whose 
input is a sequence of tokens and whose output is 
a parse tree. 
? The sequence of tokens results from calls to the 
scanner. 
Parser 
whilestmt 
cond body 
 … ) 10   <   x   (   while 
Parsing and Syntax Trees 
? The parser may or may not construct an 
explicit syntax tree.  
? In a single-pass compiler, all subsequent 
phases are incorporated into the parser. 
The parsing steps comprise an implicit 
syntax tree. In this case, the call to the 
parser may look like this: 
  parse(); 
Page 5


Parsing and Context-Free 
Grammars 
Parsing and CFGs 
? Parsing, or syntax analysis, is the task of 
determining the syntax, or structure, of a 
program. 
? Syntax is described by context-free 
grammar (CFG) rules. 
? There are 2 general methods of parsing, 
called  top down parsing and bottom-up 
parsing.  
Parsing 
? The parser may be viewed as a function whose 
input is a sequence of tokens and whose output is 
a parse tree. 
? The sequence of tokens results from calls to the 
scanner. 
Parser 
whilestmt 
cond body 
 … ) 10   <   x   (   while 
Parsing and Syntax Trees 
? The parser may or may not construct an 
explicit syntax tree.  
? In a single-pass compiler, all subsequent 
phases are incorporated into the parser. 
The parsing steps comprise an implicit 
syntax tree. In this case, the call to the 
parser may look like this: 
  parse(); 
Parsing and Syntax Trees 
? In a multi-pass compiler, the parser builds a 
syntax tree which is used as input by the 
subsequent passes. In this case, the call to 
the parser may look like this: 
 
  syntaxTree = parse();  
Read More
Offer running on EduRev: Apply code STAYHOME200 to get INR 200 off on our premium plan EduRev Infinity!

Related Searches

Objective type Questions

,

Important questions

,

video lectures

,

Semester Notes

,

MCQs

,

ppt

,

Syntax Parsing IT & Software Notes | EduRev

,

Free

,

Sample Paper

,

practice quizzes

,

Extra Questions

,

Exam

,

study material

,

Syntax Parsing IT & Software Notes | EduRev

,

pdf

,

Syntax Parsing IT & Software Notes | EduRev

,

Viva Questions

,

shortcuts and tricks

,

mock tests for examination

,

Previous Year Questions with Solutions

,

Summary

,

past year papers

;