programming-language
Here is an informal description of a simple language. Statements in the language are as follows:
input a; | read an integer from standard input device into the variable a. a can be any lower case letter._x000D_ output a; | Write the value of a on standard output device (whatever it is). a can be any lower case letter._x000D_ a := b; | Assign to the variable a the value of the variable b. a and b can be any letter between a and z._x000D_ a := 58; | Assign the value of 58 to the variable a. a can be any letter between a and z. 58 can be any single digit or multiple digit integer. _x000D_ a := a + 1; | Add 1 to a. a can be any lower case letter._x000D_ a := a - 1; | Subtract 1 from a. a can be any lower case letter._x000D_ if a < 0 goto L;| If a < 0, transfer control to statement labeled with L. L can be any letter between A and Z. a can be any lower case letter._x000D_ if a = 0 goto L;| If a = 0, transfer control to statement labeled with L. L can be any letter between A and Z. a can be any lower case letter._x000D_ if a > 0 goto L;| If a > 0, transfer control to statement labeled with L. L can be any letter between A and Z. a can be any lower case letter._x000D_ goto L; | Transfer control to statement labeled with L. L can be any letter between A and Z._x000D_ halt; | Stop execution, program should always end with halt_x000D_ _x000D_ Lower case letters a-z represent names of integer variables, upper case letters A-Z represent names of labels. Each statement may have a label as a prefix, separated from the statement by a colon (:). A program must have at least one statement and ends with halt. All statements end with ;._x000D_ _x000D_ For example, the following program computes the sum of two positive integers a + b._x000D_ Preconditions: Variables a and b contain positive integers_x000D_ Postconditions: Variable a contains the sum of the integers, the contents of variable b is destroyed._x000D_ _x000D_ input a;_x000D_ input b;_x000D_ L: a := a+1;_x000D_ b := b-1;_x000D_ if b > 0 goto L;_x000D_ output a;_x000D_ halt;_x000D_ _x000D_ Task 1 (10 points): Using the statements of the simple language described above, write a program that computes the sum of two integers a and b, with the following specifications:_x000D_ Preconditions: Variables a and b contain any integers (might be positive, negative, or zero)._x000D_ Postconditions: Variable x contains the sum a + b, the contents of a and b are preserved._x000D_ Note: You may use additional variables in your program if necessary. For simplicity, you may use single letter for variables and labels. Use lower case letter for variables and upper case letters for labels. _x000D_ _x000D_ Task 2 (30 points): Develop a formal definition of the language syntax using BNF notation. Make sure your grammar covers all the valid statements in this language._x000D_