Hire Our Expert Programmer & Technical Writer To Do Your Capstone Project
+1 vote
in Compilers & Operating Systems by

1 Answer

+1 vote
selected by (user.guest)
Best answer


There are a number of reasons why the analysis portion of a compiler is normally separated into lexical analysis and parsing (syntax analysis) phases. 

1. Simplicity of design is the most important consideration: The separation of Lexical and Syntactic analysis often allows us to simplify at least one of these tasks. For example, a parser that had to deal with comments and whitespace as syntactic units would be considerably more complex than one that can assume comments and whitespace have already been removed by the lexical analyzer. 

2. Compiler efficiency is improved: A separate lexical analyzer allows us to apply specialized techniques that serve only the lexical task, not the job of parsing. In addition, specialized buffering techniques for reading input characters can speed up the compiler significantly. 

3. Compiler portability is enhanced: Input-device-specific peculiarities can be restricted to the lexical analyzer.

Related questions

+1 vote
1 answer
asked Aug 25 in Compilers & Operating Systems by (user.guest)
Welcome to CPENTalk.com

Disclaimer: Every user is solely responsible for anything that he/she posts or uploads on CPENTalk.