Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I extremely need help with this in Python!! This program will requires me to make a basic parser for an input string that is somewhat

I extremely need help with this in Python!!

This program will requires me to make a basic parser for an input string that is somewhat like Python. Python has an older parser module and a newer ast module to manage pure Python syntax, but they won't be useful here.

The program will read a data string, identify the control characters, and print out the overall structure of the string. So far this is what I have:

Input String: [{1}]

Output: Number inside a dictionary inside a list

Here are some basic rules for the program:

  • The control characters you need to be concerned with are:, { } (dictionary), () (tuple), and ' " (string). Note that all string start with a single quote and end with a double quote (to reduce complexity in your solution).
  • The program must print out the structures starting with the innermost first and ending with the outermost
  • Once you start getting structure close characters (e.g. ] } " ) you can ignore any new start character structures (e.g. [ } ' )
  • You must also identify an errors in the closing order for the structures. Once you identify an error, print an Error message and stop processing

I must also identify an errors in the closing order for the structures. Once you identify an error, print an Error message and stop processing. For instance I have this:

Input String: {[(abc)}]

Output: Characters inside a tuple inside a ERROR

  • The input string may have spaces and other erroneous control characters. These can all be ignored and should not print an error message (i.e. only closing characters above that are out of place will cause an error message to be printed).
  • The innermost characters will either be reported as a "number" or as "characters" based on their value. Numbers will have only 0-9 and a-z and A-Z in the inner set makes the value "characters."
  • In addition to having erroneous characters in the input string, there will also be random digits and characters in the input string. These are not reported and can be ignored. Only the innermost nested characters matter for this exercise.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions