Choose the best description of what a lexical analyzer (lexer) does in a compiler.
Think about the first step after reading raw source code characters.
The lexical analyzer reads raw characters and groups them into meaningful tokens like keywords, identifiers, and symbols. This is the first step in the compilation process.
Select the tool that automatically creates a parser based on a formal grammar.
This tool works closely with lexical analyzers and uses grammar rules to build syntax trees.
Yacc (Yet Another Compiler Compiler) takes grammar definitions and generates a parser that can analyze the syntax of source code.
Analyze the roles of Lex and Yacc and choose the statement that correctly distinguishes them.
Consider which tool handles characters and which handles grammar rules.
Lex is used to create lexical analyzers that tokenize input, while Yacc generates parsers that analyze the token sequence according to grammar rules.
Choose the option that correctly explains what intermediate code generators do.
Think about a step that helps make compilers portable and easier to optimize.
Intermediate code generators produce code that is not tied to any specific machine. This code can be optimized and later translated into machine code for different platforms.
Choose the most accurate reason why parser generators are preferred over hand-written parsers.
Consider how automation affects development time and error rates.
Parser generators like Yacc take formal grammar as input and automatically produce parsers, which reduces manual coding errors and makes the compiler easier to maintain and update.