This document contains a practice test for a compiler construction course. It includes 3 questions that assess understanding of compiler components and processes, context-free grammars, and parsing techniques like recursive descent parsing. Question 1 asks the student to diagram compiler components and fill in a table describing the input, processing tool, output, and example for each component. Question 2 involves generating strings from a context-free grammar and drawing parse trees. Question 3 defines recursive descent parsing and asks the student to generate strings from grammars and find ambiguous parses.
This document contains a practice test for a compiler construction course. It includes 3 questions that assess understanding of compiler components and processes, context-free grammars, and parsing techniques like recursive descent parsing. Question 1 asks the student to diagram compiler components and fill in a table describing the input, processing tool, output, and example for each component. Question 2 involves generating strings from a context-free grammar and drawing parse trees. Question 3 defines recursive descent parsing and asks the student to generate strings from grammars and find ambiguous parses.
This document contains a practice test for a compiler construction course. It includes 3 questions that assess understanding of compiler components and processes, context-free grammars, and parsing techniques like recursive descent parsing. Question 1 asks the student to diagram compiler components and fill in a table describing the input, processing tool, output, and example for each component. Question 2 involves generating strings from a context-free grammar and drawing parse trees. Question 3 defines recursive descent parsing and asks the student to generate strings from grammars and find ambiguous parses.
Consider the context-free grammar: S -> SS+ | SS* | a
a) Show how the string aa+a* can be generated by this grammar.
b) Construct a parse tree for this string. c) Copy and complete the table
Grammar Type Language Production rule Application in
compiler for programming languages Type 0 Type 1 Type 2 Type 3
Question 3
a) In your own words, describe a ‘recursive descent parser’
b) Consider the context-free grammar production rule (P: S-->S-|SS*|a), show how the string a-a*-a* can be generated. c) Consider the context-free grammar production rule (P: S-->aSbS|bSaS|E), show that this grammar is ambiguous by finding an example string of terminals a and b that results in two or more parse trees. Also show that the grammar is ambiguous by finding the 2 different parse trees that exist for string w = abab