Question: Problem 1 (16pts). Write a top-down depth-first parser with backtracking for the language (1) SaSbS (2) S bSaS (3) S Write your parser in Python.

 Problem 1 (16pts). Write a top-down depth-first parser with backtracking for

Problem 1 (16pts). Write a top-down depth-first parser with backtracking for the language (1) SaSbS (2) S bSaS (3) S Write your parser in Python. Include a function dfparse that takes a string, and returns a tuple (True, Seq) when the string is in the language, or (False, [) when the string is not in the language. Seq is the sequence of productions the depth-first parser applies. For example, dfparse ('abab') yields (True, [1, 2, 3, 3, 3]), and dfparse ('abbb') yields (False, ) You must name your file dfparser.py, and submit it under HW2 Python in Submitty. Our configuration assumes that your Python file includes function dfparse as specified above (and no prints!), which we call in interactive mode with various inputs. We run with Python 2.7. Problem 1 (16pts). Write a top-down depth-first parser with backtracking for the language (1) SaSbS (2) S bSaS (3) S Write your parser in Python. Include a function dfparse that takes a string, and returns a tuple (True, Seq) when the string is in the language, or (False, [) when the string is not in the language. Seq is the sequence of productions the depth-first parser applies. For example, dfparse ('abab') yields (True, [1, 2, 3, 3, 3]), and dfparse ('abbb') yields (False, ) You must name your file dfparser.py, and submit it under HW2 Python in Submitty. Our configuration assumes that your Python file includes function dfparse as specified above (and no prints!), which we call in interactive mode with various inputs. We run with Python 2.7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!