Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 29
Q881:
What does the '•' symbol in an LR(1) item represent?
A. Parsing position in production
B. End of input
C. Start of input
D. Next token to scan
Correct Answer:
A
Chapter: 30
Q882:
Parser generators exist for which types of grammars?
A. LL(1) and LALR(1)
B. LR(0) and SLR
C. SLR and CLR
D. LL(1) and LR(0)
Correct Answer:
A
Chapter: 30
Q883:
Which parser generator is an example of LALR(1) parser?
A. YACC
B. ANTLR
C. JavaCC
D. Flex
Correct Answer:
A
Chapter: 30
Q884:
ANTLR is an example of which type of parser generator?
A. LL(1)
B. LALR(1)
C. Recursive Descent
D. LR(1)
Correct Answer:
A
Chapter: 30
Q885:
JavaCC uses which parsing technique?
A. Recursive Descent
B. LALR(1)
C. LL(1)
D. Operator Precedence
Correct Answer:
A
Chapter: 30
Q886:
YACC stands for:
A. Yet Another Compiler Compiler
B. Yet Another Code Compiler
C. Your Advanced Compiler
D. Young Advanced Compiler
Correct Answer:
A
Chapter: 30
Q887:
YACC appeared first in which year?
A. 1975
B. 1980
C. 1990
D. 1965
Correct Answer:
A
Chapter: 30
Q888:
The companion application to YACC that helps in lexical analysis is called:
A. Lex
B. ANTLR
C. Flex
D. JavaCC
Correct Answer:
A
Chapter: 30
Q889:
The input file for YACC is typically divided into how many sections?
A. 3
B. 2
C. 4
D. 1
Correct Answer:
A
Chapter: 30
Q890:
The section between %% and %% in YACC input file contains:
A. Rules
B. Definitions
C. C/C++ functions
D. Lexical specifications
Correct Answer:
A
Chapter: 30
Q891:
In YACC, the %token directive is used to:
A. Define tokens
B. Define grammar rules
C. Write C code
D. Include libraries
Correct Answer:
A
Chapter: 30
Q892:
In the example YACC file for calculator, which tokens are defined?
A. NUMBER, LPAREN, RPAREN, PLUS, MINUS, TIMES, DIVIDE
B. IF, ELSE, WHILE
C. INT, FLOAT, CHAR
D. ADD, SUB, MUL, DIV
Correct Answer:
A
Chapter: 30
Q893:
The Flex input file usually includes which header file generated by YACC?
A. y.tab.h
B. y.lex.h
C. yacc.tab.h
D. parser.h
Correct Answer:
A
Chapter: 30
Q894:
In Flex, the regular expression [0-9]+ matches:
A. A number
B. An identifier
C. A keyword
D. A symbol
Correct Answer:
A
Chapter: 30
Q895:
The Flex rule {digit}+ {return NUMBER;} means:
A. Return token NUMBER for digits
B. Skip digits
C. Return PLUS token
D. Return error
Correct Answer:
A
Chapter: 30
Q896:
What is the file generated by YACC that contains parsing tables and parser code?
A. y.tab.c
B. lex.yy.c
C. yacc.c
D. flex.c
Correct Answer:
A
Chapter: 30
Q897:
What is the file generated by Lex or Flex containing the lexical analyzer?
A. lex.yy.c
B. y.tab.c
C. lexer.c
D. y.lex.c
Correct Answer:
A
Chapter: 30
Q898:
The process of combining YACC and Lex to build a compiler produces which executable?
A. expr.exe
B. yacc.exe
C. lex.exe
D. parser.exe
Correct Answer:
A
Chapter: 30
Q899:
The YACC rule "expr : expr PLUS expr ;" describes what kind of grammar production?
A. Recursive production
B. Terminal production
C. Lexical production
D. Non-recursive production
Correct Answer:
A
Chapter: 30
Q900:
In the YACC input file, C/C++ functions are written in which section?
A. After second %%
B. Before first %%
C. Between first and second %%
D. Nowhere
Correct Answer:
A