Skip to content

thecoolguy2001/programming-playground-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Functional Programming Playground

A lightweight, browser-based programming playground that lets users write and run expressions in a custom mini-language powered by a Python interpreter.

Project Overview

Functional Programming Playground is an educational web application designed to demonstrate how a language runtime works end-to-end:

  • Lexing turns source text into tokens.
  • Parsing transforms tokens into an Abstract Syntax Tree (AST).
  • Evaluation executes AST nodes inside a scoped environment.
  • Web delivery provides an interactive editor and instant feedback loop in the browser.

The project is intentionally compact, making it ideal for students, bootcamp learners, and engineers who want a clear, practical reference for interpreter architecture.

Key Capabilities

  • In-browser code editor with syntax-highlighted input via CodeMirror.
  • Support for numeric expressions and arithmetic operators: +, -, *, /.
  • Variable assignment and lookup (for example, x = 10 * 2).
  • Conditional expressions using if { ... } else { ... } syntax.
  • Structured runtime error feedback (syntax errors, undefined variables, division by zero, invalid characters).

Architecture

1) Web Layer (web/)

  • Flask application serves the UI and exposes a /run execution endpoint.
  • The front-end submits code to the backend and renders either the computed result or an error message.

2) Interpreter Layer (interpreter/)

  • tokens.py defines lexical rules with PLY lex.
  • parser.py defines grammar and AST node types with PLY yacc.
  • evaluator.py walks the AST and executes expressions using an environment model.

Together, these modules provide a concise but complete language pipeline.

Technology Stack

  • Backend: Python, Flask
  • Language tooling: PLY (Python Lex-Yacc)
  • Frontend editor: CodeMirror
  • Styling/UI: HTML + CSS

Getting Started

Prerequisites

  • Python 3.9+
  • pip

Installation

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run the Application

python -m web.app

Then open http://127.0.0.1:5000 in your browser.

Example Input

x = 10 * 2
x + 5

You can also evaluate conditionals in the supported grammar form:

if 1 { 42 } else { 0 }

Who This Project Is For

  • Learners studying interpreters and compilers.
  • Instructors looking for a compact teaching artifact.
  • Developers prototyping language ideas before scaling into a full compiler/runtime.

Future Enhancements

  • Multi-statement program support.
  • First-class functions and function calls.
  • Better static diagnostics and source-positioned error messages.
  • Save/share playground snippets.

License

This repository currently has no explicit license file. Add a license before public distribution if you plan to share or commercialize it.

About

A lightweight, browser-based programming playground that lets users write and run expressions powered by a Python interpreter.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors