+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 508 views
+3 votes
1 answer 1.9k views
+1 vote
1 answer 279 views
asked May 24, 2021 in Compilers & Operating Systems by anonymous
0 votes
1 answer 89 views
+1 vote
1 answer 41 views
+1 vote
1 answer 277 views
+2 votes
1 answer 2.1k views
+2 votes
1 answer 6.8k views
+2 votes
1 answer 599 views
0 votes
1 answer 10 views
Welcome to CPENTalk.com
Solution-oriented students of computer engineering on one platform to get you that