Parsing | Compiler Design - Computer Science Engineering (CSE) PDF Download

Introduction to Parsing

When an input string (source code or a program in some language) is given to a compiler, the compiler processes it in several phases, starting from lexical analysis (scans the input and divides it into tokens) to target code generation.

Syntax Analysis or Parsing is the second phase, i.e. after lexical analysis. It checks the syntactical structure of the given input, i.e. whether the given input is in the correct syntax (of the language in which the input has been written) or not. It does so by building a data structure, called a Parse tree or Syntax tree. The parse tree is constructed by using the pre-defined Grammar of the language and the input string. If the given input string can be produced with the help of the syntax tree (in the derivation process), the input string is found to be in the correct syntax.

The Grammar for a Language consists of Production rules.

Example:
Suppose Production rules for the Grammar of a language are:

 S -> cAd
A -> bc|a
And the input string is “cad”.

Now the parser attempts to construct syntax tree from this grammar for the given input string. It uses the given production rules and applies those as needed to generate the string. To generate string “cad” it uses the rules as shown in the given diagram:

Parsing,Compiler Design,GATE,CSE,ITE

In the step iii above, the production rule A->bc was not a suitable one to apply (because the string produced is “cbcd” not “cad”), here the parser needs to backtrack, and apply the next production rule available with A which is shown in the step iv, and the string “cad” is produced.

Thus, the given input can be produced by the given grammar, therefore the input is correct in syntax.
But back-track was needed to get the correct syntax tree, which is really a complex process to implement.

There can be an easier way to solve this, which we shall see in the next article “Concepts of FIRST and FOLLOW sets in Compiler Design”.

The document Parsing | Compiler Design - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Compiler Design.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
26 videos|66 docs|30 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Parsing - Compiler Design - Computer Science Engineering (CSE)

1. What is Computer Science Engineering (CSE)?
Ans. Computer Science Engineering (CSE) is a field of engineering that combines principles of computer science and engineering to design, develop, and manage computer systems and software. It involves the study of algorithms, data structures, programming languages, computer networks, artificial intelligence, and other related areas.
2. What are the career opportunities in Computer Science Engineering (CSE)?
Ans. Computer Science Engineering offers a wide range of career opportunities. Graduates in CSE can work as software developers, computer programmers, system analysts, database administrators, network engineers, cybersecurity specialists, machine learning engineers, and more. They can find employment in industries such as IT, software development, telecommunications, finance, healthcare, and government sectors.
3. How can one prepare for the Computer Science Engineering (CSE) exam?
Ans. To prepare for the Computer Science Engineering exam, it is important to have a strong foundation in mathematics, programming, and computer science concepts. One should thoroughly study subjects such as data structures, algorithms, computer networks, operating systems, databases, and software engineering. Practice solving sample questions, previous year papers, and take mock tests to improve problem-solving and time management skills.
4. What skills are required to excel in Computer Science Engineering (CSE)?
Ans. To excel in Computer Science Engineering, one should have strong analytical and problem-solving skills. Proficiency in programming languages like Java, C++, Python, and familiarity with software development tools and frameworks is crucial. Good communication skills, teamwork, and adaptability are also important for working effectively in the industry. Continuous learning and staying updated with emerging technologies are essential to succeed in this field.
5. What are some emerging trends in Computer Science Engineering (CSE)?
Ans. Some emerging trends in Computer Science Engineering include artificial intelligence (AI), machine learning (ML), data science, cloud computing, cybersecurity, Internet of Things (IoT), and blockchain technology. These areas are witnessing rapid advancements and offer exciting opportunities for innovation and growth. Keeping up with these trends and gaining expertise in these domains can enhance career prospects in CSE.
26 videos|66 docs|30 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Sample Paper

,

Exam

,

video lectures

,

Extra Questions

,

MCQs

,

ppt

,

Summary

,

practice quizzes

,

shortcuts and tricks

,

mock tests for examination

,

study material

,

Important questions

,

Objective type Questions

,

Previous Year Questions with Solutions

,

Parsing | Compiler Design - Computer Science Engineering (CSE)

,

Free

,

past year papers

,

Parsing | Compiler Design - Computer Science Engineering (CSE)

,

pdf

,

Semester Notes

,

Viva Questions

,

Parsing | Compiler Design - Computer Science Engineering (CSE)

;