Coder Social home page Coder Social logo

mini-c's Introduction

Codacy Badge

Team Members:

  1. Aakarshan Gupta
  2. Himanshu Tolani
  3. Jatin Garg
  4. Saumya Goyal
  5. Skand Vishwanath Peri

Description of Program:

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.


Syntax:

Variable assignment:

a = 5;
a[1] = 5l
a = b; [b is previously assigned, else will give an error]

While Loop:
while( Condition )
{
  Statement;
};

Note : There is a ; after the while loop closing curly braces.

Operations :

Operations are similar to that in C language:

Addition:

a = a + 1;
a = b + c;
a = 5 + 3;

Subtraction:

a = a - 1;
a = b - c;
a = 5 - 3;

Multiplication:

a = a * 1;
a = b * c;
a = 5 * 3;

Division:

a = a / 1;
a = b / c;
a = 5 / 3;


Description of the Grammar: (with print and read commands)

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


NOTE :

The name of the file is input.txt. The precision of the decimal point is taken (by default) to be 8.


Instructions to run and compile the code:

Compile: gcc simulator.c

Run ./a.out

The output can be viewed in output.txt file that would be created.

mini-c's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.