- Aakarshan Gupta
- Himanshu Tolani
- Jatin Garg
- Saumya Goyal
- Skand Vishwanath Peri
This program takes in basic C text file as an input (input to be given in input.txt) and simulates that C program and results the output.
a = 5;
a[1] = 5l
a = b;
[b
is previously assigned, else will give an error]
while( Condition )
{
Statement;
};
Note : There is a ;
after the while loop
closing curly braces.
Operations are similar to that in C
language:
a = a + 1;
a = b + c;
a = 5 + 3;
a = a - 1;
a = b - c;
a = 5 - 3;
a = a * 1;
a = b * c;
a = 5 * 3;
a = a / 1;
a = b / c;
a = 5 / 3;
P -> S; | S;P
S -> A | W | R | O
A -> V1 = E
W -> while(E){P}
V1 -> V | Vi
V -> {a-z}+ [except while]
Vi -> V[E]
E -> E < E1 | E == E1 | E1
E1 -> E1 + E2 | E1 - E2 | E2
E2 -> E2 * E3 | E2 / E3 | E3
E3 -> (E) | V1 | C
C -> {0-9}+ . {0-9}k | {0-9}+
R -> read V1
O -> print V1 | print C
Here 0 <= j <= B is the precision limit of the decimal point
The name of the file is input.txt. The precision of the decimal point is taken (by default) to be 8.
Compile: gcc simulator.c
Run ./a.out