0% found this document useful (0 votes)
45 views

CS314 Fall 2014 Assignment 2 Due Wednesday, September 24, 11:59pm Submission: PDF File Through Sakai - Rutgers.edu

This document contains instructions for Assignment 2 for CS314 Fall 2014. It is due on September 24th at 11:59pm and should be submitted as a PDF file through Sakai. The assignment contains two problems. The first problem asks students to determine if five languages are context-free or not, and if context-free, provide a grammar for each in BNF notation. The second problem involves derivation trees, parse trees, ambiguity, precedence and associativity for a grammar defining propositional logic expressions. Students are asked to derive, draw trees and identify ambiguity for an example expression, then modify the grammar to remove ambiguity.

Uploaded by

gameloon
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

CS314 Fall 2014 Assignment 2 Due Wednesday, September 24, 11:59pm Submission: PDF File Through Sakai - Rutgers.edu

This document contains instructions for Assignment 2 for CS314 Fall 2014. It is due on September 24th at 11:59pm and should be submitted as a PDF file through Sakai. The assignment contains two problems. The first problem asks students to determine if five languages are context-free or not, and if context-free, provide a grammar for each in BNF notation. The second problem involves derivation trees, parse trees, ambiguity, precedence and associativity for a grammar defining propositional logic expressions. Students are asked to derive, draw trees and identify ambiguity for an example expression, then modify the grammar to remove ambiguity.

Uploaded by

gameloon
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS314 Fall 2014

Assignment 2
Due Wednesday, September 24, 11:59pm
Submission: pdf file through sakai.rutgers.edu
1

Problem Context-Free Languages

Are the following languages context-free or not? If yes, specify a context-free grammar in
BNF notation that generates the language. If not, give an informal argument.
1. { an bm co | m > n 0, o > 0} , with alphabet = {a, b, c}
2. { an b2n | n 0 }, with alphabet = {a, b}
3. { ww R | w and w R is w in reverse }, with alphabet ={a, b}
4. { an bm cm dn | n 0, m 0 }, with alphabet = {a, b, c, d}
5. { w | w has more than 4 symbols}, with alphabet ={a, b}

Problem Derivation, Parse Tree, Ambiguity, Precedence & Associativity

A language that is a subset of the language of propositional logic may be defined as follows:
<start> ::= <expr>
<expr> :: = <expr> <expr> |
<expr> <expr> |
<expr> <expr> |
<const> | <var>
<const> :: = true | false
<var> :: = a | b | c | . . . | z
1. Give a leftmost and a rightmost derivation for the sentence
a true b false .
2. Give the corresponding parse trees for the derivations.
3. Give the corresponding abstract syntax tree (AST).
4. Show that the above grammar is ambiguous.

5. Give an unambiguous grammar for the same language that enforces the following precedence and associativity:
has highest precedence (binds strongest), followed by , and then
and are right associative, and is left associative
6. Give the parse tree and AST for your new, unambiguous grammar for the sentence
a false b true true .

You might also like