Table of Contents
This program was developed as the culminating project for CS460: Programming Languages at Sonoma State University during the Fall 2024 semester. Collaboratively created by a team of five students, this project presents an interpreter designed to process and execute code written in Backus-Naur Form (BNF), a C-like programming language. The interpreter interprets the input in BNF, analyzes its structure and logic, and executes the corresponding computations to generate the desired output. This project exemplifies advanced concepts in parsing, syntax analysis, data structures, and interpreter design.
The interpreter was constructed through a modular design, composed of several key components that work in sequence to process the input code. These components include:
-
Comment Removal: Eliminates non-executable comments to prepare the input for further processing.
-
Tokenization: Breaks the input into meaningful tokens, such as keywords, identifiers, and symbols, forming the building blocks of the program.
-
Recursive Descent Parsing: Analyzes the tokenized input based on the defined BNF grammar, ensuring syntactical correctness while building a structural representation of the code. Generates a Concrete Syntax Tree (CST) representing program strucutre.
-
Symbol Table Generation: Creates a mapping of variables, functions, and other symbols to their corresponding definitions and values, enabling efficient lookup during execution.
-
Abstract Syntax Tree (AST) Generation: Constructs a tree representation of the program that encapsulates its logical structure and relationships, serving as the foundation for execution.
Each component builds on the outputs of the previous stage, concluding in a fully functional interpreter capable of processing complex inputs and producing correct results. This layered approach highlights the importance of modularity and abstraction in software engineering and programming language design.
This repository contains additional functionality to further integrate these components and enable the interpreter's functionality.
The interpreter is compatible with Windows, MacOS, and Linux.
This project utlizes ncurses when run on MacOS / Linux. This library can be insalled via:
brew install ncurses
sudo apt-get install libncurses-dev
- Clone the repo
git clone https://github.com/Pip-Install-Party/Interpreter.git
- Run the makefile
make
- Run the executable
./interpreter.x
- Clone the repo
git clone https://github.com/Pip-Install-Party/Interpreter.git
- Run the makefile
make
- Run the executable
./interpreter.exe
Output will be written to Output.txt
in the working directory.
The interpreter is capable of producing output for code written in Backus-Naur Form. The program may also work with some programs written in C, however differences in reserved words (such as string) may lead to unexpected output.
See getting-started.
This program contains a series of files that can be used to test the interpreter. The program's interface will prompt you to make a selection from the available test files.
In addition to interpretting code, this program also lets you test its various components. Upon starting the program, the interface will display a series of components to select from. The following components can be selected:
- Comment Removal
- Tokenization
- Recursive Descent Parser
- Symbol Table
- Abstract Syntax Tree
- Interpreter
The results from the selected component will print to Output.txt
.
Five students worked together to construct the interpreter.
Blake Marshall - LinkedIn
Brandon Robinson - LinkedIn
Holden Ea - LinkedIn
Jacob Sellers - LinkedIn
Rolando Yax - LinkedIn
Distributed under the MIT License. See LICENSE.
for more information.
Test files were provided by Robert Bruce.