Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

COMPILER MCQS

Lexical analysis is performed by:ParserScannerCode GeneratorAssemblerB) ScannerScanner breaks source code into tokens.
Which phase checks syntax errors?Lexical AnalysisSyntax AnalysisSemantic AnalysisCode GenerationB) Syntax AnalysisSyntax analysis uses parsing to check grammar of code.
Intermediate code generation helps in:Machine independenceSyntax checkingTokenizationError reportingA) Machine independenceIntermediate code makes it easier to target multiple architectures.
Which parser is used in compilers for parsing expressions?Recursive DescentShift-ReduceOperator PrecedenceAll of the aboveD) All of the aboveCompilers can use different parsing techniques based on grammar.
Symbol table is used to store:KeywordsIdentifiers and their attributesOpcodesSource codeB) Identifiers and their attributesSymbol table keeps track of variables, functions, and their info.
Which of the following is the first phase of a compiler?Code GenerationLexical AnalysisSyntax AnalysisSemantic AnalysisB) Lexical AnalysisLexical analysis scans source code and converts it into tokens.
Intermediate code generation is done to:Directly produce machine codeImprove code readabilityMake compiler retargetable for different machinesPerform debuggingC) Make compiler retargetable for different machinesIntermediate code is platform-independent and simplifies code generation for multiple architectures.
A symbol table in a compiler stores:Machine instructionsInformation about variables, functions, objectsAssembly codeData flow graphB) Information about variables, functions, objectsSymbol table keeps identifiers and their attributes for semantic analysis and code generation.
Which parsing method uses a stack and works bottom-up?LL ParsingLR ParsingRecursive DescentTop-Down ParsingB) LR ParsingLR parsing is a bottom-up method that uses a stack and shift-reduce technique.
Peephole optimization is applied on:High-level codeIntermediate representationTarget assembly codeSyntax treeC) Target assembly codePeephole optimization improves machine code by replacing inefficient instruction sequences.
Syntax tree is generated during:Lexical AnalysisSemantic AnalysisSyntax AnalysisCode OptimizationC) Syntax AnalysisSyntax analysis (parsing) converts tokens into a parse tree representing grammatical structure.
Which phase detects type mismatch errors?Code GenerationLexical AnalysisSemantic AnalysisOptimizationC) Semantic AnalysisSemantic analysis ensures type correctness and logical consistency.
A compiler that produces machine-independent code is called:Cross CompilerNative CompilerOne-Pass CompilerBootstrapping CompilerA) Cross CompilerCross compilers generate code for a platform different from the host machine.
Which of these is NOT a compiler optimization technique?Constant FoldingDead Code EliminationStrength ReductionTokenizationD) TokenizationTokenization is a lexical analysis step, not an optimization technique.
Parsing table is used in:Lexical AnalysisParsingCode GenerationSymbol Table ManagementB) ParsingParsing table guides the parser to build syntax trees based on grammar rules.

Start Practicing Today — Free, No Registration, Thousands of MCQs for PPSC, NTS, FPSC & More!

X
Scroll to Top