Coder Social home page Coder Social logo

compiler-design-project-interpreter's Introduction

Compiler-Design-Project-Interpreter

Code for Interpreter which takes JAVA program as input and performs simple arithmetic subtraction: Code for extended interpreter which performs print, arithmetic operations, function calls, loops etc with integers as well as doubles using regex for lexical analysis and ast for parsing:

Run the code:

Interpreter 1:

javac JavaSubtractionInterpreter.java
java JavaSubtractionInterpreter

Examples

You can find some examples of the language in line, Only change this line for testing different test cases.

Output

Prints the difference Screenshot from 2023-03-11 14-32-37

4

Screenshot from 2023-03-12 10-13-17
Screenshot from 2023-03-12 10-03-19

ERROR Screenshot from 2023-03-12 10-12-21

Interpreter-2

The grammar is C-like

For print with newline

println ""

replace double quotes with anystring you want to print or any variable.

For defining integers:

int x = 10
int y = -5
int res = x - y

where x, y, res and the values 10, -5 can be replaced by any valid name. The convention of variable names is similar to that of c. For remaining grammar the test file can be referred

Examples

You can find some examples of the language in src/main/resources

Output

The result of subtraction is as in the start of the output in the sample case. Screenshot from 2023-03-11 14-59-25

ERROR

Screenshot from 2023-03-12 10-27-32

Run

Compile it using the maven command: (If maven not installed install using sudo apt install maven in ubuntu)

mvn package

A jar file will be created in the target folder. Then, to run the interpreter, type in the terminal:

java -jar target/interpreter-1.0.jar src/main/resources/test.c+-

compiler-design-project-interpreter's People

Contributors

richa-iitr avatar

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.