Skip to content

jfdnc/c_jsrepl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript REPL in C

A JavaScript interpreter and REPL implemented in C from scratch, with split-screen Python visualizer of AST.

Screen.Recording.2025-06-25.at.11.00.52.mov

Project Structure

├── src/           # Source code
│   ├── lexer/     # Tokenization
│   ├── parser/    # AST generation
│   ├── interpreter/ # Execution engine
│   ├── debug/     # Debug and visualization tools
│   ├── memory/    # Memory management (planned)
│   ├── error/     # Error handling (planned)
│   └── cli/       # Command-line interface
├── include/       # Header files
├── tests/         # Test suite
├── visualizer/    # Python visualization tools
├── build/         # Build artifacts
├── planning.md    # Design documentation
└── ARCHITECTURE.md # Current implementation status

Building

make

Usage

Basic REPL

make run

Live Split-Screen REPL

Experience the interpreter with real-time visualization:

# Setup (one time)
cd visualizer
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cd ..

# Build debug tool
make debug

# Launch live REPL
source visualizer/venv/bin/activate
python visualizer/live_repl.py

This provides a split-screen interface with:

  • Left pane: Interactive REPL for entering expressions
  • Right pane: Live tokens and AST visualization

Command-Line Visualization

For one-off expression analysis:

# Visualize expressions
source visualizer/venv/bin/activate
python visualizer/visualize.py "2 + 3 * 4"           # Both tokens and AST
python visualizer/visualize.py "(1 + 2) * 3" tokens  # Just tokens  
python visualizer/visualize.py "-5 + 8" ast          # Just AST

See visualizer/README.md for detailed visualization documentation.

Features

Phase 1: Complete ✅

  • Lexical analysis (numbers, operators, parentheses)
  • Expression parsing with proper precedence
  • Basic arithmetic evaluation (+, -, *, /, unary -)
  • Interactive REPL
  • Comprehensive test suite
  • Visualization tools

Phase 2: Planned

  • Variable declarations and assignments
  • String and boolean literals
  • Comparison and logical operators

Future Phases

  • Control flow (if/else, loops)
  • Function declarations and calls
  • Advanced REPL features (history, multi-line)

Development

See planning.md for detailed design decisions and implementation phases.

About

jsrepl written in c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published