jordannakamoto / ProgrammingLanguageInterpreter

Development of a simple Programming Language to illustrate the stages of processing required to interpret and run program files. Written in c++.
0 stars 2 forks source link

Programming Language Interpreter

An Interpreter for a simple C-Like language written in C++

Demo the program with a Javascript Interface (wrapped around the C++ executable) at https://cspotato.com

SS 409

Stages

Build Instructions

Example run: make all ./app tests/inputs/test1.c

Input File

// ***************************************************
// * CS460: Programming Assignment 6: Test Program 1 *
// ***************************************************

function int sum_of_first_n_squares (int n)
{
  int sum;

  sum = 0;
  if (n >= 1)
  {
    sum = n * (n + 1) * (2 * n + 1) / 6;
  }
  return sum;
}

procedure main (void)
{
  int n;
  int sum;

  n = 100;
  sum = sum_of_first_n_squares (n);
  printf ("sum of the squares of the first %d numbers = %d\n", n, sum);
}

Program Output

sum of the squares of the first 100 numbers = 338350

Batch Testing:

Design Philosophy

As an educational program, the code is designed to be simple with focus placed on modularity and encapsulation of key concepts.

A general C++ programming pattern was used for both ease of development and final program flow.



The general class template is as follows: