Compiler Design
2023105601
B.Tech. 6th Semester Examination, 2023
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:
Ask AI
Q1.1
Which of the following is the most powerful parser?
Ask AI
Q1.2
A top down parser generates
Ask AI
Q1.3
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?
Ask AI
Q1.4
Three-address code involves
Ask AI
Q1.5
Handle pruning forms the basis of
Ask AI
Q1.6
Left factoring guarantees
Ask AI
Q1.7
Consider a grammar $ A \rightarrow aS_1 | aS_2 $. The left factored grammar produced from the grammar is
Ask AI
Q1.8
Synthesized attributes are calculated
Ask AI
Q1.9
The method which merges the bodies of two loops is
Ask AI
Q1.10
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Explain the working of each phase of compiler in detail with an example.
Ask AI
Q2.2
What is an activation record? Explain how they are used to access various local and global variables.
Ask AI
Q.3 Solve all questions :
Ask AI
Q3.1
What are the advantages of LALR parsing over SLR and CLR methods?
Ask AI
Q3.2
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
Ask AI
Q3.3
What is shift-reduce conflict?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
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 $Ask AI
Q4.2
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 $Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Construct the predictive parsing table for the following grammar:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
$ C \rightarrow cg $Ask AI
Q5.2
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 $
Ask AI
Q.6 Solve all questions :
Ask AI
Q6.1
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 $.
Ask AI
Q6.2
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 $
Ask AI
Q6.3
Discuss about operator precedence parser.
Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Ask AI
Q7.2
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.
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
Consider the following grammar: $ S \rightarrow CC $, $ C \rightarrow cC | d $. Find the LR(1) set of items.
Ask AI
Q8.2
Translate the expression $ a=(a+b)*(c+d)+(a+b+c) $ into (i) Quadruple (ii) Triple (iii) Indirect triple.
Ask AI
Q.9 Write short notes on any two of the following:
Ask AI
Q9.1
Ask AI
2023V2105601
B.Tech. 6th Semester Examination, 2023
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:
Ask AI
Q1.1
Which of the following is the most powerful parser?
Ask AI
Q1.2
A top down parser generates
Ask AI
Q1.3
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?
Ask AI
Q1.4
Three-address code involves
Ask AI
Q1.5
Handle pruning forms the basis of
Ask AI
Q1.6
Left factoring guarantees
Ask AI
Q1.7
Consider a grammar . The left factored grammar produced from the grammar is
Ask AI
Q1.8
Synthesized attributes are calculated
Ask AI
Q1.9
The method which merges the bodies of two loops is
Ask AI
Q1.10
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Explain the working of each phase of compiler in detail with an example.
Ask AI
Q2.2
What is an activation record? Explain how they are used to access various local and global variables.
Ask AI
Q.3 Solve all questions :
Ask AI
Q3.1
What are the advantages of LALR parsing over SLR and CLR methods?
Ask AI
Q3.2
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
Ask AI
Q3.3
What is shift-reduce conflict?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
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 $
;Ask AI
Q4.2
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 $
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Construct the predictive parsing table for the following grammar:
$ S \rightarrow A $
$ A \rightarrow aB | Ad $
$ B \rightarrow bBC | f $
Ask AI
Q5.2
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
Ask AI
Q.6 Solve all questions :
Ask AI
Q6.1
What is handle? Consider the grammar: . Find the handles of the right sentential forms of the reduction for the string .
Ask AI
Q6.2
When a grammar is called ambiguous? Is there any technique to remove ambiguity? Justify whether the grammar is ambiguous or not:
Ask AI
Q6.3
Discuss about operator precedence parser.
Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Ask AI
Q7.2
Consider the following grammar: , , . Draw a SLR state transition diagram for the above grammar. Also draw the SLR parse table.
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
Consider the following grammar: , . Find the LR(1) set of items.
Ask AI
Q8.2
Translate the expression into (i) Quadruple (ii) Triple (iii) Indirect triple.
Ask AI
Q.9 Write short notes on any two of the following:
Ask AI
Q9.1
Ask AI
2022105601
B.Tech. 6th Semester Examination, 2022
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 :
Ask AI
Q1.1
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.
Ask AI
Q1.2
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?
Ask AI
Q1.3
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
Ask AI
Q1.4
Consider the grammar shown below : $ S \rightarrow CC $, $ C \rightarrow cC | d $. The grammar is
Ask AI
Q1.5
The lexical analyzer takes _____ as input and produces a stream of _____ as output.
Ask AI
Q1.6
In a compiler, when is the keywords of a language are recognized?
Ask AI
Q1.7
How many tokens are there in the following C statement?
printf("j=%d, & j=%x", j, & j)Ask AI
Q1.8
How is the parsing precedence relation defined?
Ask AI
Q1.9
Given the following expression grammar : $ E \rightarrow E*F | F+E | F $, $ F \rightarrow F-F | id $. Which of the following is true?
Ask AI
Q1.10
Shift reduce parsers are
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Write a lexical analyzer program to identify strings, sequences, comments, reserved words and identifiers.
Ask AI
Q2.2
Explain about the sources and criterions of code optimization as machine dependent and independent types.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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 $Ask AI
Q3.2
What is the relationship with lexical analyzer, regular expressions and transition diagram? Give an example.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Explain the type system in type checker. Write the syntax directed definition for type checker.
Ask AI
Q4.2
What is activation record? Explain its usage in stack allocation strategy. How is it different from heap allocation?
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Draw and explain the runtime memory organization static storage allocation strategy with pros and cons.
Ask AI
Q5.2
Differentiate inherited and synthesized attributes with an example.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Define dataflow analysis. List out the procedures to analyze the data flow of structured programs.
Ask AI
Q6.2
Draw a block diagram of phases of a compiler and indicate the main functions of each phase.
Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
What is intermediate code? Translate the expression $ (a+b)/(c+d)*(a+b/c)-d $ into quadruples, triples and indirect triples.
Ask AI
Q7.2
Explain reducible and non-reducible flow graphs with an example each.
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
What is machine-dependent optimization? Explain how peephole techniques function in this.
Ask AI
Q8.2
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 $
Ask AI
Q.9 Explain the following with suitable example :
Ask AI
Q9.1
Ask AI
2022V2105601
B.Tech. 6th Semester Examination, 2022
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 :
Ask AI
Q1.1
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.
Ask AI
Q1.2
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?
Ask AI
Q1.3
In a bottom-up evaluation of a syntax directed definition, inherited attributes can
Ask AI
Q1.4
Consider the grammar shown below : , . The grammar is
Ask AI
Q1.5
The lexical analyzer takes _____ as input and produces a stream of _____ as output.
Ask AI
Q1.6
In a compiler, when is the keywords of a language are recognized?
Ask AI
Q1.7
How many tokens are there in the following C statement?
printf("j=%d, & j=%x", j, & j)Ask AI
Q1.8
How is the parsing precedence relation defined?
Ask AI
Q1.9
Given the following expression grammar : , $ F \rightarrow F-F | id $. Which of the following is true?
Ask AI
Q1.10
Shift reduce parsers are
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
Write a lexical analyzer program to identify strings, sequences, comments, reserved words and identifiers.
Ask AI
Q2.2
Explain about the sources and criterions of code optimization as machine dependent and independent types.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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 $
Ask AI
Q3.2
What is the relationship with lexical analyzer, regular expressions and transition diagram? Give an example.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
Explain the type system in type checker. Write the syntax directed definition for type checker.
Ask AI
Q4.2
What is activation record? Explain its usage in stack allocation strategy. How is it different from heap allocation?
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Draw and explain the runtime memory organization static storage allocation strategy with pros and cons.
Ask AI
Q5.2
Differentiate inherited and synthesized attributes with an example.
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Define dataflow analysis. List out the procedures to analyze the data flow of structured programs.
Ask AI
Q6.2
Draw a block diagram of phases of a compiler and indicate the main functions of each phase.
Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
What is intermediate code? Translate the expression into quadruples, triples and indirect triples.
Ask AI
Q7.2
Explain reducible and non-reducible flow graphs with an example each.
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
What is machine-dependent optimization? Explain how peephole techniques function in this.
Ask AI
Q8.2
Explain how type checking and error reporting are performed in compiler. Draw syntax tree and DAG for the statement:
Ask AI
Q.9 Explain the following with suitable example :
Ask AI
Q9.1
Ask AI
2019051516
B.Tech. 5th Semester Examination, 2019
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):
Ask AI
Q1.1
When is the type checking usually done?
Ask AI
Q1.2
Which one of the following statements is true?
Ask AI
Q1.3
In a compiler, _____ checks every character of the source text.
Ask AI
Q1.4
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Ask AI
Q1.5
In an absolute loading scheme, which loader function is accomplished by programmer?
Ask AI
Q1.6
_____ is a top-down parser.
Ask AI
Q1.7
The languages that need heap allocation in the runtime environment are those that
Ask AI
Q1.8
In compilers, generation of intermediate code based on an abstract machine model is useful because
Ask AI
Q1.9
To convert an arbitrary CFG to an LL(1) grammar
Ask AI
Q1.10
The method which merges the bodies of two loops is
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
What is an activation record? Explain how they are used to access various local and global variables.
Ask AI
Q2.2
What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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 $Ask AI
Q3.2
What is the use of a symbol table? How are the identifiers stored in the symbol table?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
What is the pass of a compiler? Explain how the single- and multi-pass compilers work.
Ask AI
Q4.2
Explain architecture and algorithm for the non-recursive predictive parser.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Check whether the following grammar is CLR or not:
$ S \rightarrow Aa | bBa | Ba | bAc $
$ A \rightarrow c $
$ B \rightarrow d $Ask AI
Q5.2
What is the syntax directed translation and why are they important?
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Explain different phases of compiler.
Ask AI
Q6.2
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 $Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Explain various targets for code optimization with examples.
Ask AI
Q7.2
How are CPU registers allocated while creating machine code?
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
Check whether the following grammar is LL(1) grammar or not:
$ S \rightarrow iEtSA | a $
$ A \rightarrow eS | \epsilon $
$ E \rightarrow b $Ask AI
Q8.2
Design the FIRST SET and FOLLOW SET for the grammar.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Ask AI
Q9.2
Explain any two of the following:
Ask AI
2019V4051516
B.Tech. 5th Semester Examination, 2019
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):
Ask AI
Q1.1
When is the type checking usually done?
Ask AI
Q1.2
Which one of the following statements is true?
Ask AI
Q1.3
In a compiler, _____ checks every character of the source text.
Ask AI
Q1.4
For a grammar G, shift reduce (S-R) conflicts are present in LALR(1) parser, if and only if
Ask AI
Q1.5
In an absolute loading scheme, which loader function is accomplished by programmer?
Ask AI
Q1.6
_____ is a top-down parser.
Ask AI
Q1.7
The languages that need heap allocation in the runtime environment are those that
Ask AI
Q1.8
In compilers, generation of intermediate code based on an abstract machine model is useful because
Ask AI
Q1.9
To convert an arbitrary CFG to an LL(1) grammar
Ask AI
Q1.10
The method which merges the bodies of two loops is
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
What is an activation record? Explain how they are used to access various local and global variables.
Ask AI
Q2.2
What is bottom-up parsing? Discuss shift reduce parsing technique in brief. What is a handle?
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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 $Ask AI
Q3.2
What is the use of a symbol table? How are the identifiers stored in the symbol table?
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
What is the pass of a compiler? Explain how the single- and multi-pass compilers work.
Ask AI
Q4.2
Explain architecture and algorithm for the non-recursive predictive parser.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
Check whether the following grammar is CLR or not:
$ S \rightarrow Aa | bBa | Ba | bAc $
$ A \rightarrow c $
$ B \rightarrow d $Ask AI
Q5.2
What is the syntax directed translation and why are they important?
Ask AI
Q.6 Solve both questions :
Ask AI
Q6.1
Explain different phases of compiler.
Ask AI
Q6.2
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 $Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Explain various targets for code optimization with examples.
Ask AI
Q7.2
How are CPU registers allocated while creating machine code?
Ask AI
Q.8 Solve both questions :
Ask AI
Q8.1
Check whether the following grammar is LL(1) grammar or not:
$ S \rightarrow iEtSA | a $
$ A \rightarrow eS | \epsilon $
$ E \rightarrow b $Ask AI
Q8.2
Design the FIRST SET and FOLLOW SET for the grammar.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
Differentiate between S-attribute SDT and L-attribute SDT with suitable examples.
Ask AI
Q9.2
Explain any two of the following:
Ask AI
2018051616
B.Tech. 6th Semester Examination, 2018
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:
Ask AI
Q1.1
What is the number of tokens in the following C statement? printf("I=%d and I=%x",I and I)
Ask AI
Q1.2
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?
Ask AI
Q1.3
What is the similarity between LR, LALR and SLR?
Ask AI
Q1.4
Consider the following grammar: $ S \rightarrow aSbS | bSaS | \epsilon $. How many different parse trees are possible for string ababab?
Ask AI
Q1.5
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?
Ask AI
Q1.6
The most powerful parser is
Ask AI
Q1.7
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?
Ask AI
Q1.8
In operator precedence parsing, precedence relations are defined
Ask AI
Q1.9
A bottom-up parser generates
Ask AI
Q1.10
A grammar that produces more than one parse tree for some sentence is called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
What do you understand by left recursion and left factoring? How are these eliminated? Explain with the help of suitable example.
Ask AI
Q2.2
What do you understand by bootstrapping? Explain with the help of suitable example.
Ask AI
Q.3 Solve all questions :
Ask AI
Q3.1
How can addressing modes be used for reducing the memory access time?
Ask AI
Q3.2
What are activation records? Explain its purpose in compilers.
Ask AI
Q3.3
What are the optimization techniques applied on procedures calls? Explain with an example.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
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 $Ask AI
Q4.2
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".
Ask AI
Q.5 Solve all questions :
Ask AI
Q5.1
What is the advantage of using machine independent intermediate representation during translation process?
Ask AI
Q5.2
Explain, with example, what three address codes are. Give some common three address statements.
Ask AI
Q5.3
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];Ask AI
Q.6 Solve all questions :
Ask AI
Q6.1
Find the CNF (Chomsky Normal Form) for the following CFG:
$ S \rightarrow ABA $
$ A \rightarrow aA | \epsilon $
$ B \rightarrow bB | \epsilon $Ask AI
Q6.2
Eliminate null productions from the following CFG:
$ S \rightarrow Xa $
$ X \rightarrow aX | bX | \epsilon $Ask AI
Q6.3
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 $Ask AI
Q.7 Solve all questions :
Ask AI
Q7.1
What are the advantages of LALR parsing over SLR and CLR methods?
Ask AI
Q7.2
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
Ask AI
Q7.3
What is shift-reduce conflict?
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
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.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
What is parsing? What is the difference between Top-down parsing, Bottom-up parsing and Predictive parsing?
Ask AI
Q9.2
Explain the working of each phase of compiler in detail with an example.
Ask AI
2018V4051616
B.Tech. 6th Semester Examination, 2018
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:
Ask AI
Q1.1
What is the number of tokens in the following C statement? printf("I=%d and I=%x",I and I)
Ask AI
Q1.2
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?
Ask AI
Q1.3
What is the similarity between LR, LALR and SLR?
Ask AI
Q1.4
Consider the following grammar: $ S \rightarrow aSbS | bSaS | \epsilon $. How many different parse trees are possible for string ababab?
Ask AI
Q1.5
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?
Ask AI
Q1.6
The most powerful parser is
Ask AI
Q1.7
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?
Ask AI
Q1.8
In operator precedence parsing, precedence relations are defined
Ask AI
Q1.9
A bottom-up parser generates
Ask AI
Q1.10
A grammar that produces more than one parse tree for some sentence is called
Ask AI
Q.2 Solve both questions :
Ask AI
Q2.1
What do you understand by left recursion and left factoring? How are these eliminated? Explain with the help of suitable example.
Ask AI
Q2.2
What do you understand by bootstrapping? Explain with the help of suitable example.
Ask AI
Q.3 Solve all questions :
Ask AI
Q3.1
How can addressing modes be used for reducing the memory access time?
Ask AI
Q3.2
What are activation records? Explain its purpose in compilers.
Ask AI
Q3.3
What are the optimization techniques applied on procedures calls? Explain with an example.
Ask AI
Q.4 Solve both questions :
Ask AI
Q4.1
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 $Ask AI
Q4.2
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".
Ask AI
Q.5 Solve all questions :
Ask AI
Q5.1
What is the advantage of using machine independent intermediate representation during translation process?
Ask AI
Q5.2
Explain, with example, what three address codes are. Give some common three address statements.
Ask AI
Q5.3
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];Ask AI
Q.6 Solve all questions :
Ask AI
Q6.1
Find the CNF (Chomsky Normal Form) for the following CFG:
$ S \rightarrow ABA $
$ A \rightarrow aA | \epsilon $
$ B \rightarrow bB | \epsilon $Ask AI
Q6.2
Eliminate null productions from the following CFG:
$ S \rightarrow Xa $
$ X \rightarrow aX | bX | \epsilon $Ask AI
Q6.3
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 $Ask AI
Q.7 Solve all questions :
Ask AI
Q7.1
What are the advantages of LALR parsing over SLR and CLR methods?
Ask AI
Q7.2
Write the algorithm to compute FIRST and FOLLOW for a given grammar.
Ask AI
Q7.3
What is shift-reduce conflict?
Ask AI
Q.8 Solve this question :
Ask AI
Q8.1
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.
Ask AI
Q.9 Solve both questions :
Ask AI
Q9.1
What is parsing? What is the difference between Top-down parsing, Bottom-up parsing and Predictive parsing?
Ask AI
Q9.2
Explain the working of each phase of compiler in detail with an example.
Ask AI
2017051616
B.Tech. 6th Semester Examination, 2017
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:
Ask AI
Q1.1
A grammar that produces more than one parse tree for some sentence is said to be
Ask AI
Q1.2
What is not the phase of a compiler?
Ask AI
Q1.3
Given a grammar $ G=(\{E\}, \{id, +\}, P, E) $; where P is given by $ E \rightarrow E+E | id $. Then FOLLOW(E) will contain
Ask AI
Q1.4
Which of the following expressions has no l-value?
Ask AI
Q1.5
Consider the statement "fi (x>=10)", where 'if' has been misspelled. The error is detected by the compiler in the phase
Ask AI
Q1.6
Which of the following is not a loop optimization?
Ask AI
Q1.7
If x is a terminal then FIRST(x) is
Ask AI
Q1.8
Consider following grammar $ S \rightarrow cAd $, $ A \rightarrow ab | a $. For input string cad, how many times the recursive descent parser will backtrack?
Ask AI
Q1.9
The optional access link in the activation record is used for
Ask AI
Q1.10
Suppose two productions are there: $ A \rightarrow \alpha $ and $ A \rightarrow \beta $. The recursive descent parsing without backtracking requires:
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Construct DFA for $ (ab^* | ba^*) $ and minimize the number of states of the above constructed DFA.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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.Ask AI
Q3.2
Construct a predictive parsing table for the grammar given above.
Ask AI
Q.4 Solve this question :
Ask AI
Q4.1
What is a symbol table? Why is it needed in compiler design? Explain different components of a symbol table with an example.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
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.Ask AI
Q5.2
Determine the basic blocks for the computed three-address code.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
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 $Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Explain peephole optimization in detail.
Ask AI
Q7.2
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.Ask AI
Q.8 Solve all questions :
Ask AI
Q8.1
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 $.Ask AI
Q.9 Write short note on (any two) of the following:
Ask AI
Q9.1
Ask AI
2017V4051616
B.Tech. 6th Semester Examination, 2017
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:
Ask AI
Q1.1
A grammar that produces more than one parse tree for some sentence is said to be
Ask AI
Q1.2
What is not the phase of a compiler?
Ask AI
Q1.3
Given a grammar $ G=(\\{E\\}, \\{id, +\\}, P, E) $; where P is given by $ E \rightarrow E+E | id $. Then FOLLOW(E) will contain
Ask AI
Q1.4
Which of the following expressions has no l-value?
Ask AI
Q1.5
Consider the statement "fi (x>=10)", where 'if' has been misspelled. The error is detected by the compiler in the phase
Ask AI
Q1.6
Which of the following is not a loop optimization?
Ask AI
Q1.7
If x is a terminal then FIRST(x) is
Ask AI
Q1.8
Consider following grammar $ S \rightarrow cAd $, $ A \rightarrow ab | a $. For input string cad, how many times the recursive descent parser will backtrack?
Ask AI
Q1.9
The optional access link in the activation record is used for
Ask AI
Q1.10
Suppose two productions are there: $ A \rightarrow \alpha $ and $ A \rightarrow \beta $. The recursive descent parsing without backtracking requires:
Ask AI
Q.2 Solve this question :
Ask AI
Q2.1
Construct DFA for $ (ab^* | ba^*) $ and minimize the number of states of the above constructed DFA.
Ask AI
Q.3 Solve both questions :
Ask AI
Q3.1
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.Ask AI
Q3.2
Construct a predictive parsing table for the grammar given above.
Ask AI
Q.4 Solve this question :
Ask AI
Q4.1
What is a symbol table? Why is it needed in compiler design? Explain different components of a symbol table with an example.
Ask AI
Q.5 Solve both questions :
Ask AI
Q5.1
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.Ask AI
Q5.2
Determine the basic blocks for the computed three-address code.
Ask AI
Q.6 Solve this question :
Ask AI
Q6.1
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 $Ask AI
Q.7 Solve both questions :
Ask AI
Q7.1
Explain peephole optimization in detail.
Ask AI
Q7.2
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.Ask AI
Q.8 Solve all questions :
Ask AI
Q8.1
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 $.Ask AI