In this assignment you will write a C program that takes an advanced bash (bash++ ?) program and outputs a standard bash program that has no syntax errors.

So, there are two features of bash++ (no its NOT an OO language) that are not supported by bash in general, namely: 1) bash does not allow spaces, tabs or newlines around the "=" symbol used in initialization, and 2) the "then" keyword in bash if statements must be on a different line than the if itself. Also, the brackets ([,]) in bash’s conditionals must have spaces between the bracket and the condition itself. So, the following two statements (legal in bash++) are not acceptable to bash,

    num    =                0            
    if [x -lt 5] then ...

Your preprocessor will need to change those two statements (and others like them) in the output to be:


if [ x -lt 5 ]


Again as a "preprocessor" your program will not actually change the input file itself but rather copy the input file to output making the necessary changes to the output file to make it "bashable".

Two items which may seem to you to be choices of the implementation are in fact REQUIRED, namely

1. The program MUST be written in C, not C++ (or java, bash, ruby, …).
2. The name of the bash++ file must be passed to your C program’s executable as command line argument 1.   And any command line arguments required for the bash++ program will (must be) passed to your C program’s executable as command line arguments 2 .. n

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <string.h>
#include <stdio.h>

void shiftLeft(int,char *);
void shiftRight(int,char *);

int main(int argc, char **argv)
    char buffer[800];
    int i=0;
    int j=0;
    int counter = 0;
    //int temp=0;
    FILE *input;
    FILE *output;
    //opens the input file
    input = fopen(argv[1],"r");
    //puts contents of input file into a string

50% discount

$55.00 $27.50
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats