hw2 - L=a n b n c n = ɛ abc aabbcc aaabbbccc … is not...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COP4020 Spring 2012 Homework Assignment 2 (semantic analysis and attribute grammars) 1. (50 points) Augment the following grammar of the language of nested parenthesis with semantic rules to count the number of matching parenthesis: < parens > ( < parens > ) < parens > ε The synthesized attribute parens .num should hold the nesting depth of the parenthesis. (25 points) Draw a decorated parse tree for the input ((())) . Show the parens .num attribute values in the tree nodes. (25 points) 2. (50 points) Basic results from automata theory tell us that the language
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: L=a n b n c n ={ ɛ , abc, aabbcc, aaabbbccc, …} is not context free. It can be captured however, using an attribute grammar. Give an underlying context free grammar and a set of attribute rules that associates a Boolean attribute ok with the root R of each parse tree such that R.ok = true if and only if the input string is in L (25 points). Draw the decorated parse trees for inputs aabcc and aabbcc (25 points)....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online