Skip to content

An attempt to build our very own Interpreter for Procedural Languages from scratch in C++, so as to gain a better insight into how an interpreter works and functions.

Notifications You must be signed in to change notification settings

bansaljas/DeCipher

Repository files navigation

DeCipher: Our Very Own Interpreter in C++

Group - 16

Mentor - Dr. Sanjeev Sofat, Professor, Computer Science and Engineering

Team Members:

  • Srishti Arora - 18103011
  • Jasmeen Bansal - 18103016
  • Bhavya Gulati - 18103024
  • Saksham Basandrai - 18103048

Project Synopsis:

BACKGROUND:

The main purpose of a compiler or an interpreter is to translate a source program written in a high-level source language to machine language. The difference between a compiler and an interpreter is that a compiler generates object code written in the machine language and the interpreter executes the instructions directly.

-

MOTIVATION:

I hear and I forget. I see and I remember. I do and I understand.

These famous lines said by Confucius, holds true in all scenarios. For the best way to fully test the understanding of a concept is by building or creating it.

So, following the same philosophy, we as Computer Science students, use programming languages everyday and thus, we attempt to build our very own Interpreter from scratch, so as to gain a better insight on how it works and functions. To write an interpreter we need to have a lot of technical skills that need to be used together and writing an interpreter will help us improve those skills and become better software developers.

WORKFLOW:

Following is a document, entailing all the work we have done till now, the various approaches we tried out and how we implemented our source code for the interpreter: WorkFlow Document

Timeline:

28 July 2020 - 15 August 2020:

  • Team formation and Mentor Selection:

    • Team Formation.
    • Brainstorming sessions amongst the team members to discuss upon the various viable project ideas.
    • Selecting the mentor best suited to our project ideas.
    • Pitched our idea to the mentor and he approved our idea of making an interpreter.

16 August 2020 - 31 August 2020:

  • Research and Exploration Phase

    • As suggested by our team mentor, we looked into various research papers based on compilers and interpreters.
    • Exploring various tools like ANTLR, yacc, lex which could be beneficial for our project.
    • Acquainted ourselves with the existing work that has happened, and narrowed down to a few viable approaches.

1 September 2020 - 15 September 2020:

  • Implementation Phase 1

    • Explored the various terminologies related to the interpreter like Tokenization, Lexical Analyser and a few more.
    • Started with the basic brute force implementation for the addition operation of single digit integers.
    • Looked into the various edge cases and figured out the shortcomings.
    • This implementation lacked handling whitespace given in the input.
    • Ponderred upon the features to be added and discussed their workflow.

16 September 2020 - 30 September 2020:

  • Implementation Phase 2

    • Created the GitHub repository for collaboration purposes.
    • Now added the subtraction operation functionality as well.
    • Handled the previous shortcoming by adding code for ignoring whitespaces.
    • Further implemented the code for performing operations on multi digit integers.
    • Tried out various edge cases and discussed further workflow

1 October 2020 - 15 October 2020:

  • Implementation Phase 3

    • As discussed with our mentor, we know majorly focused on exploring Context-Free Grammars.
    • We then prepared a few grammar rules (productions) for our interpreter.
    • Added functionality for multiplication, division, exponentiation along with handling parenthesis.
    • Looked into edge cases and made a few minor fixes.

15 October 2020 - 30 October 2020:

  • Implementation Phase 4

    • Started with the implementation of Abstract Syntax Trees.
    • Added the functionality to evaluate Unary Operators.
    • Explored more into the functionality of an interpreter and completed AST implementation.
    • Created various header files for better code readability.

1 Novemeber 2020 - 15 November 2020:

  • Implementation Phase 5

    • Started with the implementation of symbol tables to perform Semantic Analysis.
    • Fixed a few bugs caused due to some edge cases.
    • Added the feature of evaluating procedures having arguments.
    • Improved the Semantic Analyser further and looked into the concept of scopes.

16 Novemeber 2020 - 30 November 2020:

  • Implementation Phase 6

    • Added functionality to handle Global as well as Functional Scopes.
    • Introduced print statement.
    • The process of error handling was improved.
    • Implemented the execution of function calls.

1 December 2020 - Present:

  • Implementation Phase 7

    • Improved the memory system by introducing call stack.
    • Implemented nested procedure call.
    • Introduced read statement for taking input from the user.
    • Accesing non-local variables for functions.

How to Run:

  • The code will run on Visual Studio Code 2019. You need to connect the project with C++ Boost External Library.
  • Now give the program you'd like to evaluate in sample.txt file.
  • Now, we can run the main.cpp file and get the desired output.

About

An attempt to build our very own Interpreter for Procedural Languages from scratch in C++, so as to gain a better insight into how an interpreter works and functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages