Chris Pollett>
Old Classses > |
HW#3 --- last modified March 26 2020 03:48:00.Due date: Mar 26 Files to be submitted: Purpose: To gain familiarity with context free languages and their applications. To gain more experience with pumping lemmas. To understand parsers for context free grammars. To understand normal forms for context free grammars. Related Course Outcomes: The main course outcomes covered by this assignment are: LO1 (Learning Outcome 1) -- Write a grammar for a language described otherwise. LO7 -- Be able to use a pumping lemma to show that some languages are not regular and/or not context-free Use closure properties to simplify proofs of non-regularity of languages. Description: This homework consists of some exercises and a coding assignment. Put the written problems in a file Hw3.pdf, put your Java code in the file Cyk.java, and ZIP both into a file Hw3.zip. For the written part of the assignment do the following problems:
For the coding part of the assignment I want you to code a program in the file Cyk.java which can parse a string over a {a,b} according to a CFG in 2NF. The grader will compile your Java program from a shell prompt using the line: javac Cyk.java Your program will then be tested on various inputs using lines in the format: java Cyk grammar_file some_string For example, the grader might type: java Cyk my_grammar.txt aabba If the grammar generates the string aabba, then your program should output YES and stop; otherwise, it should output NO and stop. It should also output NO and stop on invalid inputs. A grammar_file consists of a sequence of newline delimited lines of the form: Variable:Variable_Or_Terminal,Variable_Or_Terminal_Or_Empty. Here a variable is a string of 0's and 1's which serves as an identifier for that variable, and a terminal is either an 'a' or a 'b'. We use 'e' to denote empty string. Below is an example grammar file: 0:a,0 0:1,b 1:10,11 10:a,e 11:b,b 11:b,e The string aabb is in the language generated from this grammar as: `{0} =>a{0} => a{1}b => a{10}{11}b => aa{11}b =>aa\b\b`. Here I am writing braces around the variables for clarity.
|