Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
- Symbols used (if any) have their usual meanings.
Q.1 Answer any seven questions of the following:
Which of the following is the most powerful parser?
A top down parser generates
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar: $ S \rightarrow xxW $ {print "1"}, $ S \rightarrow y $ {print "2"}, $ S \rightarrow Sz $ {print "3"}. What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules?
Three-address code involves
Handle pruning forms the basis of
Left factoring guarantees
Consider a grammar $ A \rightarrow aS_1 | aS_2 $. The left factored grammar produced from the grammar is
Synthesized attributes are calculated
The method which merges the bodies of two loops is
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Q.2 Solve both questions :
Explain the working of each phase of compiler in detail with an example.
What is an activation record? Explain how they are used to access various local and global variables.
Q.3 Solve all questions :
What are the advantages of LALR parsing over SLR and CLR methods?
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
What is shift-reduce conflict?
Q.4 Solve both questions :
Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated
parse tree for the expression $ (3+4)*(5+6) $:
$ L \rightarrow E $ ; $ L.val = E.val $
$ E \rightarrow T $ ; $ E.val = T.val $
$ E \rightarrow E_1 + T $ ; $ E.val = E_1.val + T.val $
$ T \rightarrow F $ ; $ T.val = F.val $
$ T \rightarrow T_1 * F $ ; $ T.val = T_1.val * F.val $
$ F \rightarrow (E) $ ; $ F.val = E.val $
$ F \rightarrow digit $ ; $ F.val = digit.lexval $
Find the FIRST and FOLLOW from the following production:
$ S \rightarrow aBDh $
$ B \rightarrow cC $
$ C \rightarrow bC | \epsilon $
$ D \rightarrow EF $
$ E \rightarrow g | \epsilon $
$ F \rightarrow f | \epsilon $
Q.5 Solve both questions :
Construct the predictive parsing table for the following grammar:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
$ C \rightarrow cg $
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement: $ a = (a*b+c)\wedge(b+c)*b+c $
Q.6 Solve all questions :
What is handle? Consider the grammar: $ E \rightarrow E+E | E*E | id $. Find the handles of the right sentential forms of the reduction for the string $ id_1 + id_2 * id_3 $.
When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not: $ A \rightarrow AA | (A) | a $
Discuss about operator precedence parser.
Q.7 Solve both questions :
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Consider the following grammar: $ E \rightarrow E+T | T $, $ T \rightarrow T*F | F $, $ F \rightarrow id $. Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.
Q.8 Solve both questions :
Consider the following grammar: $ S \rightarrow CC $, $ C \rightarrow cC | d $. Find the LR(1) set of items.
Translate the expression $ a=(a+b)*(c+d)+(a+b+c) $ into (i) Quadruple (ii) Triple (iii) Indirect triple.
Q.9 Write short notes on any two of the following:
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
- Symbols used (if any) have their usual meanings.
Q.1 Answer any seven questions of the following:
Which of the following is the most powerful parser?
A top down parser generates
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar: {print "1"}, $ S \rightarrow y S \rightarrow Sz $ {print "3"}. What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules?
Three-address code involves
Handle pruning forms the basis of
Left factoring guarantees
Consider a grammar . The left factored grammar produced from the grammar is
Synthesized attributes are calculated
The method which merges the bodies of two loops is
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Q.2 Solve both questions :
Explain the working of each phase of compiler in detail with an example.
What is an activation record? Explain how they are used to access various local and global variables.
Q.3 Solve all questions :
What are the advantages of LALR parsing over SLR and CLR methods?
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
What is shift-reduce conflict?
Q.4 Solve both questions :
Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated
parse tree for the expression :
; $ L.val = E.val $
; $ E.val = T.val $
; $ E.val = E_1.val + T.val $
; $ T.val = F.val $
; $ T.val = T_1.val * F.val $
; $ F.val = E.val $
;
Find the FIRST and FOLLOW from the following production:
$ S \rightarrow aBDh $
$ B \rightarrow cC $
$ C \rightarrow bC | \epsilon $
$ D \rightarrow EF $
$ E \rightarrow g | \epsilon $
Q.5 Solve both questions :
Construct the predictive parsing table for the following grammar:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
Q.6 Solve all questions :
What is handle? Consider the grammar: . Find the handles of the right sentential forms of the reduction for the string .
When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not:
Discuss about operator precedence parser.
Q.7 Solve both questions :
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Consider the following grammar: , , . Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.
Q.8 Solve both questions :
Consider the following grammar: , . Find the LR(1) set of items.
Translate the expression into (i) Quadruple (ii) Triple (iii) Indirect triple.
Q.9 Write short notes on any two of the following:
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer for any seven of the following :
Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type $ A \rightarrow \epsilon $ and $ A \rightarrow a $) to parse a string with n tokens?
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
Consider the grammar shown below : $ S \rightarrow CC $, $ C \rightarrow cC | d $. The grammar is
The lexical analyzer takes _____ as input and produces a stream of _____ as output.
In a compiler, when is the keywords of a language are recognized?
How many tokens are there in the following C statement?
printf("j=%d, & j=%x", j, & j)
How is the parsing precedence relation defined?
Given the following expression grammar : $ E \rightarrow E*F | F+E | F $, $ F \rightarrow F-F | id $. Which of the following is true?
Shift reduce parsers are
Q.2 Solve both questions :
Write a lexical analyzer program to identify strings, sequences, comments, reserved words and identifiers.
Explain about the sources and criterions of code optimization as machine dependent and independent types.
Q.3 Solve both questions :
Construct the non-recursive predictive parse table for the given grammar and check the acceptance
of input string "abfcg":
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
$ C \rightarrow cg $
What is the relationship with lexical analyzer, regular expressions and transition diagram? Give an example.
Q.4 Solve both questions :
Explain the type system in type checker. Write the syntax directed definition for type checker.
What is activation record? Explain its usage in stack allocation strategy. How is it different from heap allocation?
Q.5 Solve both questions :
Draw and explain the runtime memory organization static storage allocation strategy with pros and cons.
Differentiate inherited and synthesized attributes with an example.
Q.6 Solve both questions :
Define dataflow analysis. List out the procedures to analyze the data flow of structured programs.
Draw a block diagram of phases of a compiler and indicate the main functions of each phase.
Q.7 Solve both questions :
What is intermediate code? Translate the expression $ (a+b)/(c+d)*(a+b/c)-d $ into quadruples, triples and indirect triples.
Explain reducible and non-reducible flow graphs with an example each.
Q.8 Solve both questions :
What is machine-dependent optimization? Explain how peephole techniques function in this.
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement: $ a=(a*b+c)\wedge(b+c)*b+c $
Q.9 Explain the following with suitable example :
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer for any seven of the following :
Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order.
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type and $ A \rightarrow a $) to parse a string with n tokens?
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
Consider the grammar shown below : , . The grammar is
The lexical analyzer takes _____ as input and produces a stream of _____ as output.
In a compiler, when is the keywords of a language are recognized?
How many tokens are there in the following C statement?
printf("j=%d, & j=%x", j, & j)
How is the parsing precedence relation defined?
Given the following expression grammar : , $ F \rightarrow F-F | id $. Which of the following is true?
Shift reduce parsers are
Q.2 Solve both questions :
Write a lexical analyzer program to identify strings, sequences, comments, reserved words and identifiers.
Explain about the sources and criterions of code optimization as machine dependent and independent types.
Q.3 Solve both questions :
Construct the non-recursive predictive parse table for the given grammar and check the acceptance
of input string "abfcg":
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
What is the relationship with lexical analyzer, regular expressions and transition diagram? Give an example.
Q.4 Solve both questions :
Explain the type system in type checker. Write the syntax directed definition for type checker.
What is activation record? Explain its usage in stack allocation strategy. How is it different from heap allocation?
Q.5 Solve both questions :
Draw and explain the runtime memory organization static storage allocation strategy with pros and cons.
Differentiate inherited and synthesized attributes with an example.
Q.6 Solve both questions :
Define dataflow analysis. List out the procedures to analyze the data flow of structured programs.
Draw a block diagram of phases of a compiler and indicate the main functions of each phase.
Q.7 Solve both questions :
What is intermediate code? Translate the expression into quadruples, triples and indirect triples.
Explain reducible and non-reducible flow graphs with an example each.
Q.8 Solve both questions :
What is machine-dependent optimization? Explain how peephole techniques function in this.
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
Q.9 Explain the following with suitable example :
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven):
When is the type checking usually done?
Which one of the following statements is true?
In a compiler, _____ checks every character of the source text.
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
In an absolute loading scheme, which loader function is accomplished by programmer?
_____ is a top-down parser.
The languages that need heap allocation in the runtime environment are those that
In compilers, generation of intermediate code based on an abstract machine model is useful because
To convert an arbitrary CFG to an LL(1) grammar
The method which merges the bodies of two loops is
Q.2 Solve both questions :
What is an activation record? Explain how they are used to access various local and global variables.
What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?
Q.3 Solve both questions :
What is left recursion? Eliminate the left recursion from the following grammar:
$ E \rightarrow E+T | T $
$ T \rightarrow T*F | F $
$ F \rightarrow (E) | id $
What is the use of a symbol table? How are the identifiers stored in the symbol table?
Q.4 Solve both questions :
What is the pass of a compiler? Explain how the single- and multi-pass compilers work.
Explain architecture and algorithm for the non-recursive predictive parser.
Q.5 Solve both questions :
Check whether the following grammar is CLR or not:
$ S \rightarrow Aa | bBa | Ba | bAc $
$ A \rightarrow c $
$ B \rightarrow d $
What is the syntax directed translation and why are they important?
Q.6 Solve both questions :
Explain different phases of compiler.
Explain how type checking and error reporting are performed
in compiler.
Draw syntax tree and DAG for the statement:
$ a=(a*b+c)\wedge(b+c)*b+c $
Q.7 Solve both questions :
Explain various targets for code optimization with examples.
How are CPU registers allocated while creating machine code?
Q.8 Solve both questions :
Check whether the following grammar is LL(1) grammar or not:
$ S \rightarrow iEtSA | a $
$ A \rightarrow eS | \epsilon $
$ E \rightarrow b $
Design the FIRST SET and FOLLOW SET for the grammar.
Q.9 Solve both questions :
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Explain any two of the following:
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer of the following (any seven):
When is the type checking usually done?
Which one of the following statements is true?
In a compiler, _____ checks every character of the source text.
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
In an absolute loading scheme, which loader function is accomplished by programmer?
_____ is a top-down parser.
The languages that need heap allocation in the runtime environment are those that
In compilers, generation of intermediate code based on an abstract machine model is useful because
To convert an arbitrary CFG to an LL(1) grammar
The method which merges the bodies of two loops is
Q.2 Solve both questions :
What is an activation record? Explain how they are used to access various local and global variables.
What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?
Q.3 Solve both questions :
What is left recursion? Eliminate the left recursion from the following grammar:
$ E \rightarrow E+T | T $
$ T \rightarrow T*F | F $
$ F \rightarrow (E) | id $
What is the use of a symbol table? How are the identifiers stored in the symbol table?
Q.4 Solve both questions :
What is the pass of a compiler? Explain how the single- and multi-pass compilers work.
Explain architecture and algorithm for the non-recursive predictive parser.
Q.5 Solve both questions :
Check whether the following grammar is CLR or not:
$ S \rightarrow Aa | bBa | Ba | bAc $
$ A \rightarrow c $
$ B \rightarrow d $
What is the syntax directed translation and why are they important?
Q.6 Solve both questions :
Explain different phases of compiler.
Explain how type checking and error reporting are performed
in compiler.
Draw syntax tree and DAG for the statement:
$ a=(a*b+c)\wedge(b+c)*b+c $
Q.7 Solve both questions :
Explain various targets for code optimization with examples.
How are CPU registers allocated while creating machine code?
Q.8 Solve both questions :
Check whether the following grammar is LL(1) grammar or not:
$ S \rightarrow iEtSA | a $
$ A \rightarrow eS | \epsilon $
$ E \rightarrow b $
Design the FIRST SET and FOLLOW SET for the grammar.
Q.9 Solve both questions :
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Explain any two of the following:
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer for any seven of the following:
What is the number of tokens in the following C statement? printf("I=%d and I=%x",I and I)
Consider the following two statements: P: Every regular grammar is LL(1). Q: Every regular set has LR(1) grammar. Which of the following is true?
What is the similarity between LR, LALR and SLR?
Consider the following grammar: $ S \rightarrow aSbS | bSaS | \epsilon $. How many different parse trees are possible for string ababab?
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar: $ S \rightarrow xxW $ {PRINT "1"}, $ S \rightarrow y $ {print "2"}, $ S \rightarrow Sz $ {print "3"}. What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules?
The most powerful parser is
In some programming languages, an identifier is permitted to be a letter followed by any number of letters or digits. If L and D denote the sets of letters and digits respectively, which of the following expressions defines an identifier?
In operator precedence parsing, precedence relations are defined
A bottom-up parser generates
A grammar that produces more than one parse tree for some sentence is called
Q.2 Solve both questions :
What do you understand by left recursion and left factoring? How are these eliminated? Explain with the help of suitable example.
What do you understand by bootstrapping? Explain with the help of suitable example.
Q.3 Solve all questions :
How can addressing modes be used for reducing the memory access time?
What are activation records? Explain its purpose in compilers.
What are the optimization techniques applied on procedures calls? Explain with an example.
Q.4 Solve both questions :
Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated
parse tree for the expression $ (3+4)*(5+6) $:
$ L \rightarrow E $ ; $ L.val = E.val $
$ E \rightarrow T $ ; $ E.val = T.val $
$ E \rightarrow E_1+T $ ; $ E.val = E_1.val+T.val $
$ T \rightarrow F $ ; $ T.val = F.val $
$ T \rightarrow T_1*F $ ; $ T.val = T_1.val*F.val $
$ F \rightarrow (E) $ ; $ F.val = E.val $
$ F \rightarrow digit $ ; $ F.val = digit.lexval $
Construct a Syntax-Directed Translation scheme that translates arithmetic expressions from infix into postfix notation. Your solution should include the context-free grammar, the semantic attributes for each of the grammar symbols, and semantic rules. Show the application of your scheme to the input "3*4+5*2".
Q.5 Solve all questions :
What is the advantage of using machine independent intermediate representation during translation process?
Explain, with example, what three address codes are. Give some common three address statements.
Find the three address codes of the following program. There are four bytes per word:
Sum = 0
For(i = 1; i <= 20; i++)
Sum = Sum + a[i] + b[i];
Q.6 Solve all questions :
Find the CNF (Chomsky Normal Form) for the following CFG:
$ S \rightarrow ABA $
$ A \rightarrow aA | \epsilon $
$ B \rightarrow bB | \epsilon $
Eliminate null productions from the following CFG:
$ S \rightarrow Xa $
$ X \rightarrow aX | bX | \epsilon $
Convert the following grammar to GNF :
$ A_1 \rightarrow A_2A_3 $
$ A_2 \rightarrow A_3A_1 | b $
$ A_3 \rightarrow A_1A_2 | a $
Q.7 Solve all questions :
What are the advantages of LALR parsing over SLR and CLR methods?
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
What is shift-reduce conflict?
Q.8 Solve this question :
What are intermediate codes in compilers? Why is it needed in compiler design? Discuss different types of intermediate codes generated by intermediate code generation phase.
Q.9 Solve both questions :
What is parsing? What is the difference between Top-down parsing, Bottom-up parsing and Predictive parsing?
Explain the working of each phase of compiler in detail with an example.
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Q.1 Choose the correct answer for any seven of the following:
What is the number of tokens in the following C statement? printf("I=%d and I=%x",I and I)
Consider the following two statements: P: Every regular grammar is LL(1). Q: Every regular set has LR(1) grammar. Which of the following is true?
What is the similarity between LR, LALR and SLR?
Consider the following grammar: $ S \rightarrow aSbS | bSaS | \epsilon $. How many different parse trees are possible for string ababab?
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar: $ S \rightarrow xxW $ {PRINT "1"}, $ S \rightarrow y $ {print "2"}, $ S \rightarrow Sz $ {print "3"}. What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules?
The most powerful parser is
In some programming languages, an identifier is permitted to be a letter followed by any number of letters or digits. If L and D denote the sets of letters and digits respectively, which of the following expressions defines an identifier?
In operator precedence parsing, precedence relations are defined
A bottom-up parser generates
A grammar that produces more than one parse tree for some sentence is called
Q.2 Solve both questions :
What do you understand by left recursion and left factoring? How are these eliminated? Explain with the help of suitable example.
What do you understand by bootstrapping? Explain with the help of suitable example.
Q.3 Solve all questions :
How can addressing modes be used for reducing the memory access time?
What are activation records? Explain its purpose in compilers.
What are the optimization techniques applied on procedures calls? Explain with an example.
Q.4 Solve both questions :
Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated
parse tree for the expression $ (3+4)*(5+6) $:
$ L \rightarrow E $ ; $ L.val = E.val $
$ E \rightarrow T $ ; $ E.val = T.val $
$ E \rightarrow E_1+T $ ; $ E.val = E_1.val+T.val $
$ T \rightarrow F $ ; $ T.val = F.val $
$ T \rightarrow T_1*F $ ; $ T.val = T_1.val*F.val $
$ F \rightarrow (E) $ ; $ F.val = E.val $
$ F \rightarrow digit $ ; $ F.val = digit.lexval $
Construct a Syntax-Directed Translation scheme that translates arithmetic expressions from infix into postfix notation. Your solution should include the context-free grammar, the semantic attributes for each of the grammar symbols, and semantic rules. Show the application of your scheme to the input "3*4+5*2".
Q.5 Solve all questions :
What is the advantage of using machine independent intermediate representation during translation process?
Explain, with example, what three address codes are. Give some common three address statements.
Find the three address codes of the following program. There are four bytes per word:
Sum = 0
For(i = 1; i <= 20; i++)
Sum = Sum + a[i] + b[i];
Q.6 Solve all questions :
Find the CNF (Chomsky Normal Form) for the following CFG:
$ S \rightarrow ABA $
$ A \rightarrow aA | \epsilon $
$ B \rightarrow bB | \epsilon $
Eliminate null productions from the following CFG:
$ S \rightarrow Xa $
$ X \rightarrow aX | bX | \epsilon $
Convert the following grammar to GNF :
$ A_1 \rightarrow A_2A_3 $
$ A_2 \rightarrow A_3A_1 | b $
$ A_3 \rightarrow A_1A_2 | a $
Q.7 Solve all questions :
What are the advantages of LALR parsing over SLR and CLR methods?
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
What is shift-reduce conflict?
Q.8 Solve this question :
What are intermediate codes in compilers? Why is it needed in compiler design? Discuss different types of intermediate codes generated by intermediate code generation phase.
Q.9 Solve both questions :
What is parsing? What is the difference between Top-down parsing, Bottom-up parsing and Predictive parsing?
Explain the working of each phase of compiler in detail with an example.
Instructions:
- There are Nine Questions in this Paper.
- Attempt Five questions in all.
- Question No. 1 is Compulsory.
- The marks are indicated in the right-hand margin.
Q.1 Answer any seven questions:
A grammar that produces more than one parse tree for some sentence is said to be
What is not the phase of a compiler?
Given a grammar $ G=(\{E\}, \{id, +\}, P, E) $; where P is given by $ E \rightarrow E+E | id $. Then FOLLOW(E) will contain
Which of the following expressions has no l-value?
Consider the statement "fi (x>=10)", where 'if' has been misspelled. The error is detected by the compiler in the phase
Which of the following is not a loop optimization?
If x is a terminal then FIRST(x) is
Consider following grammar $ S \rightarrow cAd $, $ A \rightarrow ab | a $. For input string cad, how many times the recursive descent parser will backtrack?
The optional access link in the activation record is used for
Suppose two productions are there: $ A \rightarrow \alpha $ and $ A \rightarrow \beta $. The recursive descent parsing without backtracking requires:
Q.2 Solve this question :
Construct DFA for $ (ab^* | ba^*) $ and minimize the number of states of the above constructed DFA.
Q.3 Solve both questions :
A grammar is given below:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
$ C \rightarrow g $
Find the FIRST and FOLLOW set.
Construct a predictive parsing table for the grammar given above.
Q.4 Solve this question :
What is a symbol table? Why is it needed in compiler design? Explain different components of a symbol table with an example.
Q.5 Solve both questions :
Consider the following program fragment:
prod = 0;
i = 1;
do {
prod = prod + a[i] * b[i];
i = i + 1;
} while (i <= 20);
Generate the three-address code for the above program fragment.
Determine the basic blocks for the computed three-address code.
Q.6 Solve this question :
What is DAG? What is the use of DAG in compiler construction? Construct a DAG for the following
statements:
$ Z = X - Y + X * Y $
$ U = V / W + X + V $
Q.7 Solve both questions :
Explain peephole optimization in detail.
Suppose a basic block is formed from the C assignment statements:
$ x = a + b + c + d + e + f; $
$ y = a + c + e; $
(a) Give the three-address statements (only one addition per statement) for this block.
(b) Use the associative and commutative laws to modify the block to use the fewest possible
number of instructions, assuming both $ x $ and $ y $ are live on exit from the block.
Q.8 Solve all questions :
Given the grammar $ G = (S, \{S, A, B\}, \{a, b, c, d\}, P) $ with set of productions $ P $ below compute;
</p><p>a. LR(1) sets of items.</p>
b. Compute the corresponding parsing table for the corresponding shift-reduce parse engine.
c. Show the actions of the parsing engine as well as the contents of the symbol and state stacks for the input string $ w = \text{"bdac"} $.
d. Is this grammar LALR(1)? Justify.
$ S \rightarrow Aa | bAc | Bc | bBa $
$ A \rightarrow d $
$ B \rightarrow d $
Do not forget to augment the grammar with the production $ S' \rightarrow S $.
Q.9 Write short note on (any two) of the following:
Instructions:
- There are Nine Questions in this Paper.
- Attempt Five questions in all.
- Question No. 1 is Compulsory.
- The marks are indicated in the right-hand margin.
Q.1 Answer any seven questions:
A grammar that produces more than one parse tree for some sentence is said to be
What is not the phase of a compiler?
Given a grammar $ G=(\\{E\\}, \\{id, +\\}, P, E) $; where P is given by $ E \rightarrow E+E | id $. Then FOLLOW(E) will contain
Which of the following expressions has no l-value?
Consider the statement "fi (x>=10)", where 'if' has been misspelled. The error is detected by the compiler in the phase
Which of the following is not a loop optimization?
If x is a terminal then FIRST(x) is
Consider following grammar $ S \rightarrow cAd $, $ A \rightarrow ab | a $. For input string cad, how many times the recursive descent parser will backtrack?
The optional access link in the activation record is used for
Suppose two productions are there: $ A \rightarrow \alpha $ and $ A \rightarrow \beta $. The recursive descent parsing without backtracking requires:
Q.2 Solve this question :
Construct DFA for $ (ab^* | ba^*) $ and minimize the number of states of the above constructed DFA.
Q.3 Solve both questions :
A grammar is given below:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
$ C \rightarrow g $
Find the FIRST and FOLLOW set.
Construct a predictive parsing table for the grammar given above.
Q.4 Solve this question :
What is a symbol table? Why is it needed in compiler design? Explain different components of a symbol table with an example.
Q.5 Solve both questions :
Consider the following program fragment:
prod = 0;
i = 1;
do {
prod = prod + a[i] * b[i];
i = i + 1;
} while (i <= 20);
Generate the three-address code for the above program fragment.
Determine the basic blocks for the computed three-address code.
Q.6 Solve this question :
What is DAG? What is the use of DAG in compiler construction? Construct a DAG for the following
statements:
$ Z = X - Y + X * Y $
$ U = V / W + X + V $
Q.7 Solve both questions :
Explain peephole optimization in detail.
Suppose a basic block is formed from the C assignment statements:
$ x = a + b + c + d + e + f; $
$ y = a + c + e; $
(a) Give the three-address statements (only one addition per statement) for this block.
(b) Use the associative and commutative laws to modify the block to use the fewest possible
number of instructions, assuming both $ x $ and $ y $ are live on exit from the block.
Q.8 Solve all questions :
Given the grammar $ G = (S, \\{S, A, B\\}, \\{a, b, c, d\\}, P) $ with set of productions $ P $ below compute;
</p><p>a. LR(1) sets of items.</p>
b. Compute the corresponding parsing table for the corresponding shift-reduce parse engine.
c. Show the actions of the parsing engine as well as the contents of the symbol and state stacks for the input string $ w = \text{"bdac"} $.
d. Is this grammar LALR(1)? Justify.
$ S \rightarrow Aa | bAc | Bc | bBa $
$ A \rightarrow d $
$ B \rightarrow d $
Do not forget to augment the grammar with the production $ S' \rightarrow S $.