Theory Of Computation And Compiler Design Set 3

On This Page

This set of Theory of Computation and Compiler Design Multiple Choice Questions & Answers (MCQs) focuses on Theory Of Computation And Compiler Design Set 3

Q1 | In a compiler, keywords of a language are recognized during
Q2 | The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?
Q3 | Consider the following statements:(I) The output of a lexical analyzer is groups of characters.(II) Total number of tokens in printf("i=%d, &i=%x", i, &i); are 11.(III) Symbol table can be implementation by using array and hash table but not tree.Which of the following statement(s) is/are correct?
Q4 | Which one of the following statements is FALSE?
Q5 | A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}. T1: a?(b?c)*a T2: b?(a?c)*b T3: c?(b?a)*c Note that ‘x?’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix. If the string bbaacabc is processes by the analyzer, which one of the following is the sequence of tokens it outputs?
Q6 | Consider the following statements related to compiler construction :I. Lexical Analysis is specified by context-free grammars and implemented by pushdown automata.II. Syntax Analysis is specified by regular expressions and implemented by finite-state machine. Which of the above statement(s) is/are correct?
Q7 | Which of the following statement(s) regarding a linker software is/are true?I. A function of a linker is to combine several object modules into a single load module.II. A function of a linker is to replace absolute references in an object module by symbolic references to locations in other modules.
Q8 | From the given data below : a b b a a b b a a b which one of the following is not aword in the dictionary created by LZ-coding (the initial words are a, b)?
Q9 | The number of tokens in the following C statement is printf("i=%d, &i=%x",i&i);
Q10 | In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction?
Q11 | Debugger is a program that
Q12 | Consider the following two sets of LR(1) items of an LR(1) grammar.X -> c.X, c/dX -> .cX, c/dX -> .d, c/dX -> c.X, $X -> .cX, $X -> .d, $Which of the following statements related to merging of the two sets in thecorresponding LALR parser is/are FALSE?1. Cannot be merged since look aheads are different.2. Can be merged but will result in S-R conflict.3. Can be merged but will result in R-R conflict.4. Cannot be merged since goto on c will lead to two different sets.
Q13 | The grammar S ? aSa | bS | c is
Q14 | Which of the following statements are TRUE?I. There exist parsing algorithms for some programming languages whose complexities are less than O(n3).II. A programming language which allows recursion can be implemented with static storage allocation.III. No L-attributed definition can be evaluated in the framework of bottom-up parsing.IV. Code improving transformations can be performed at both source language and intermediate code level.
Q15 | Which of the following describes a handle (as applicable to LR-parsing) appropriately?
Q16 | An LALR(1) parser for a grammar G can have shift-reduce (S-R) conflicts if andonly if
Q17 | Consider the following two statements:P: Every regular grammar is LL(1)Q: Every regular set has a LR(1) grammarWhich of the following is TRUE?
Q18 | Consider the following grammar.S -> S * ES -> EE -> F + EE -> FF -> idConsider the following LR(0) items corresponding to the grammar above.(i) S -> S * .E(ii) E -> F. + E(iii) E -> F + .EGiven the items above, which two of them will appear in the same set in the canonicalsets-of-items for the grammar?
Q19 | A canonical set of items is given belowS --> L. > RQ --> R.On input symbol < the set has
Q20 | Consider the grammar defined by the following production rules, with twooperators ? and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdWhich one of the following is TRUE?
Q21 | Consider the following grammar:S ? FRR ? S | ?F ? idIn the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $]respectively.
Q22 | Consider the following translation scheme. S ? ER R ? *E{print("*");}R | ? E? F + E {print("+");} | F F ? (S) | id {print(id.value);} Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input '2 * 3 + 4', this translation scheme prints
Q23 | The grammar A ? AA | (A) | ? is not suitable for predictive-parsing because thegrammar is
Q24 | Consider the grammar S ? (S) | a Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good
Q25 | Consider the following expression grammar. The seman-tic rules for expressioncalculation are stated next to each grammar production.E ? number E.val = number. val| E '+' E E(1).val = E(2).val + E(3).val| E '×' E E(1).val = E(2).val × E(3).valThe above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1)parser generator) for parsing and evaluating arithmetic expressions. Which one of thefollowing is true about the action of yacc for the given grammar?