{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw2 - CS 6353 Compiler Construction Homework#2 1 Consider...

This preview shows pages 1–2. Sign up to view the full content.

CS 6353 Compiler Construction, Homework #2 1. Consider the following grammar. Note that the terminals include x, [, ], (, and ). S [ST] | T T (TF) | F F x | ε (a) Compute the First set for all nonterminals in the grammar. (b) Compute the First set for each production (i.e., the right side of the production). (c) Compute the Follow set for all non-terminals in the grammar. (d) Based on the First and Follow sets you obtained in (a), (b), and (c), determine whether the grammar is LL(1). Explain how your decision is made. (e) Build an LL(1) parsing table for the grammar. (f) Parse the string [[x()](((xx))x)]. When there are conflicts, choose the one you know that would work. Show the stack, the input, and the action taken. (g) Build the parse tree while you are parsing. Show your parse tree. 2. Consider the following grammar G. Note that T = {a, b, (, )}. S AB | ab A (a) | ε B (b) | ε (a) Show that G is not LL(1) (b) Build an LL(2) parse table for G. You can skip steps to quickly build the parse table.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}