+1 vote

1 Answer

+1 vote
by (user.guest)
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
Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that