A program of the Micro language has only integer data. The possible actionsare the following:
- Input values of a list of variables (read).
- Output/print the values of a list of expressions (write).
- Assign (the value of) an expression to a variable.
- Each expression is a sequence of the common arithmetic operations of integers: addition, minus, multiplication, integer division (result is an integer).
The grammar of a Micro programming language has the following features:
- Comment starts with two dashes (–) and ends at the end of the line.
- Each program starts with the word “begin” and ends with the word “end”.
- Each statement ends with a “;”.
- Each statement is either a read, or a write, or an assignment statement.
-- a simple micro program
-- good luck. It is a comment
begin
read(x, y, z); -- input three integers
a := x+y;
b := 314;
c := 1 + a * (b - 1) / 2;
write(a, b, c, (a+b+c)/(x+y) );
end
< program> --> begin <statement-list> end
<statement-list> --> <statement> {<statement>}
<statement> --> <read-stmt> | <write-stmt> | <assign-stmt>
<assign-stmt> --> id := <expression>;
<read-stmt> --> read ( <id-list> );
<write-stmt> --> write ( <expression-list> );
<id-list> --> id | {, id }
<expression-list> --> <expression> {, }
<expression> --> ???