Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you will use sed, bash, and some other command-line utilities to create a program for formatting C code. Your program should take

For this assignment, you will use sed, bash, and some other command-line utilities to create a program for formatting C code. Your program should take a source code le as input and apply the following:

No more than one space between tokens.

No trailing whitespace after a line.

Binary operators should always surrounded by a single space on either side (including assignment and Boolean). Only the following operators must be accounted for: +, -, *, /, =, ==, <=, >=, <, >.

Conditions should not have whitespace immediately inside of the parentheses.

The program should not modify spaces which are leading, expanded tabs.

Comments should be left alone. You may assume comments (single- and multi-line) will not appear on lines with source code.

Hint: All of the above does not need to be done in a single pass. This assignment requires only sed and bash. Do not use awk, Python, or any other languages/utilities.

Script Execution

Your program should be invoked through a single bash le (see below) with the path to the input program as the argument. The resulting output le should be printed directly to stdout. $ assign2.bash /path/to/input.txt

Script Files

Your program should consist of at least two les: assign2.bash - the main le which is initially invoked At least one .sed le which is used for a sed invocation run in assign2.bash. Each sed invocation should have its own .sed le which may contain multiple sed commands.

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago