Moved to cmake and ninja, updated docs

This commit is contained in:
Bobby Lucero 2025-08-07 17:49:52 -04:00
parent 6c17ce96f0
commit 87d56bbb13
7 changed files with 835 additions and 1323 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
build/ build/
.DS_Store .DS_Store
build-ninja

145
CMakeLists.txt Normal file
View File

@ -0,0 +1,145 @@
cmake_minimum_required(VERSION 3.20)
# Project definition
project(bob
VERSION 0.0.3
DESCRIPTION "Bob Language Interpreter"
LANGUAGES CXX
)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Build type defaults
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Compiler-specific options
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(BOB_COMPILE_OPTIONS
-Wall -Wextra
-Wno-unused-variable
-Wno-unused-parameter
-Wno-switch
)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
list(APPEND BOB_COMPILE_OPTIONS -O3 -march=native)
endif()
elseif(MSVC)
set(BOB_COMPILE_OPTIONS
/W4
/wd4100 # unreferenced formal parameter
/wd4101 # unreferenced local variable
)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
list(APPEND BOB_COMPILE_OPTIONS /O2)
endif()
endif()
# Collect source files
file(GLOB_RECURSE BOB_RUNTIME_SOURCES "src/sources/runtime/*.cpp")
file(GLOB_RECURSE BOB_PARSING_SOURCES "src/sources/parsing/*.cpp")
file(GLOB_RECURSE BOB_STDLIB_SOURCES "src/sources/stdlib/*.cpp")
file(GLOB_RECURSE BOB_CLI_SOURCES "src/sources/cli/*.cpp")
# All source files
set(BOB_ALL_SOURCES
${BOB_RUNTIME_SOURCES}
${BOB_PARSING_SOURCES}
${BOB_STDLIB_SOURCES}
${BOB_CLI_SOURCES}
)
# Create the executable
add_executable(bob ${BOB_ALL_SOURCES})
# Include directories
target_include_directories(bob PRIVATE
src/headers/runtime
src/headers/parsing
src/headers/stdlib
src/headers/cli
src/headers/common
)
# Apply compiler options
target_compile_options(bob PRIVATE ${BOB_COMPILE_OPTIONS})
# Platform-specific settings
if(WIN32)
# Windows-specific settings
target_compile_definitions(bob PRIVATE _CRT_SECURE_NO_WARNINGS)
elseif(UNIX AND NOT APPLE)
# Linux-specific settings
target_link_libraries(bob PRIVATE pthread)
elseif(APPLE)
# macOS-specific settings
set_target_properties(bob PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/Info.plist
)
endif()
# Generate compile_commands.json for language servers
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Testing support
enable_testing()
# Add test for the main test suite
add_test(
NAME bob_test_suite
COMMAND bob test_bob_language.bob
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Custom target for running tests with verbose output
add_custom_target(test_verbose
COMMAND ${CMAKE_CTEST_COMMAND} --verbose
DEPENDS bob
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Install rules
install(TARGETS bob
RUNTIME DESTINATION bin
COMPONENT Runtime
)
# Install test files (optional)
install(FILES test_bob_language.bob
DESTINATION share/bob/tests
COMPONENT Tests
)
# CPack configuration for packaging
set(CPACK_PACKAGE_NAME "Bob Language")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Bob Language Interpreter")
set(CPACK_PACKAGE_VENDOR "Bob Language Team")
set(CPACK_PACKAGE_CONTACT "your-email@example.com")
if(WIN32)
set(CPACK_GENERATOR "ZIP;NSIS")
elseif(APPLE)
set(CPACK_GENERATOR "TGZ;DragNDrop")
else()
set(CPACK_GENERATOR "TGZ;DEB;RPM")
endif()
include(CPack)
# Print configuration summary
message(STATUS "Bob Language Build Configuration:")
message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS " C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS " Install Prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " Source Files Found: ${BOB_ALL_SOURCES}")

View File

@ -1,55 +0,0 @@
# Makefile - Bob language interpreter
# Compiler
CC = g++
# Compiler flags
CFLAGS = -Wall -Wextra -std=c++17 -Wno-unused-variable -Wno-unused-parameter -Wno-switch -O3 -march=native
# Source layout:
# src/
# ├── headers/ - All header files (public interface)
# │ ├── runtime/ - Runtime execution headers
# │ ├── parsing/ - Front-end processing headers
# │ ├── stdlib/ - Standard library headers
# │ ├── cli/ - CLI headers
# │ └── common/ - Shared utilities (helperFunctions)
# └── sources/ - All source files (implementation)
# ├── runtime/ - Interpreter, Evaluator, Executor, Environment, Value, TypeWrapper
# ├── parsing/ - Lexer, Parser, ErrorReporter, Expression AST
# ├── stdlib/ - Built-in functions (BobStdLib)
# └── cli/ - Command-line interface (main, bob)
SRC_ROOT = ./src
BUILD_DIR = ./build
# Find all .cpp files under src/sources (recursively)
CPP_FILES := $(shell find $(SRC_ROOT)/sources -type f -name '*.cpp')
# Map every source file to its corresponding object file inside build/
# Strip src/sources/ prefix and add build/ prefix
OBJ_FILES := $(patsubst $(SRC_ROOT)/sources/%.cpp,$(BUILD_DIR)/%.o,$(CPP_FILES))
# Make sure every object directory exists ahead of time
$(shell mkdir -p $(dir $(OBJ_FILES)))
# Default goal
all: build
# Pattern rule compile each .cpp from sources/ into a mirrored .o inside build/
$(BUILD_DIR)/%.o: $(SRC_ROOT)/sources/%.cpp
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(SRC_ROOT)/headers/runtime -I$(SRC_ROOT)/headers/parsing -I$(SRC_ROOT)/headers/stdlib -I$(SRC_ROOT)/headers/cli -I$(SRC_ROOT)/headers/common -c $< -o $@
# Link all objects into the final executable
$(BUILD_DIR)/bob: $(OBJ_FILES)
$(CC) $(CFLAGS) $^ -o $@
# Convenience targets
run:
./$(BUILD_DIR)/bob
build: clean $(BUILD_DIR)/bob
clean:
rm -rf $(BUILD_DIR)/*

117
README.md
View File

@ -1,98 +1,37 @@
# Bob ```
██████╗ ██████╗ ██████╗
A modern programming language focused on safety and clarity. ██╔══██╗██╔═══██╗██╔══██╗
██████╔╝██║ ██║██████╔╝
## Design Philosophy ██╔══██╗██║ ██║██╔══██╗
██████╔╝╚██████╔╝██████╔╝
Bob prioritizes safety and functional programming while keeping things practical. ╚═════╝ ╚═════╝ ╚═════╝
## Assignment System
Bob uses two types of assignments to prevent bugs while keeping useful functionality:
### Assignment Statements
```go
var x = 5;
x = 10; // Regular assignment
y += 5; // Compound assignment
``` ```
### Assignment Expressions (For Loops Only) A modern programming language with all the features/sytax I prefer
```go
for (var i = 0; i < 5; i = i + 1) { } // Assignment in for loop
for (j = 0; j < 5; j += 1) { } // Assignment in for loop
```
### Why This Design?
**Prevents Common Bugs:**
```go
// This would be a bug in many languages:
if (x = 10) { } // Parse error in Bob - prevents accidental assignment
// Bob forces you to write:
x = 10;
if (x == 10) { } // Clear comparison
```
**Keeps Expressions Pure:**
```go
// Prevents side effects in expressions:
var result = (x = 10) + (y = 20); // Parse error
// Forces clean code:
x = 10;
y = 20;
var result = x + y; // Pure expression
```
**Supports Functional Programming:**
```go
// Prevents confusing patterns:
var value = condition ? (x = 10) : (x = 20); // Parse error
// Encourages clean patterns:
x = condition ? 10 : 20; // Clear assignment
```
**Keeps For Loops Practical:**
```go
// For loops work naturally:
for (var i = 0; i < 10; i = i + 1) { } // Assignment expressions allowed
for (j = 0; j < 10; j += 1) { } // Assignment expressions allowed
```
### Benefits
1. **Prevents Common Bugs**: No accidental assignments in conditionals
2. **Expression Purity**: Expressions have no side effects
3. **Clear Semantics**: Assignments are clearly statements
4. **Functional Programming**: Encourages pure function patterns
5. **Practical For Loops**: Maintains useful for loop syntax
6. **Easier Debugging**: Clear separation of assignment and expression logic
## Features
- **Type Safety**: Dynamic typing with runtime type checking
- **Functional Programming**: First-class functions, closures, recursion
- **Memory Management**: Automatic memory management
- **Error Handling**: Comprehensive error reporting
- **Standard Library**: Built-in functions for common operations
- **Tail Call Optimization**: Efficient recursive function calls
## Documentation ## Documentation
See [BOB_LANGUAGE_REFERENCE.md](BOB_LANGUAGE_REFERENCE.md) for complete language documentation. - **[Language Reference](Reference/BOB_LANGUAGE_REFERENCE.md)** - Language syntax and features
- **[Build Guide](Reference/BUILD.md)** - How to build Bob
- **[Roadmap](Reference/ROADMAP.md)** - What's done and what might come next
## Building ## Features
- **Core Types**: Numbers, strings, booleans, arrays, dictionaries, functions
- **Advanced Functions**: First-class functions, closures, anonymous functions, tail call optimization
- **Control Flow**: If/else statements, while/do-while/for loops, break/continue
- **Operators**: Arithmetic, logical, bitwise, comparison, compound assignment (+=, -=, etc.)
- **Built-in Functions**: print, input, assert, len, push, pop, keys, values, type conversion (toString, toNumber, toInt)
- **Other Stuff**: String interpolation, escape sequences, file I/O, eval, time/sleep, random
- **Memory**: Automatic cleanup, no manual memory management
## Quick Start
```bash ```bash
make clean && make # Build
./build/bob your_file.bob cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
``` ninja -C build
## Testing # Run
./build/bin/bob your_file.bob
```bash ```
./build/bob test_bob_language.bob
```

File diff suppressed because it is too large Load Diff

248
Reference/BUILD.md Normal file
View File

@ -0,0 +1,248 @@
# Bob Language - Build Guide
This guide describes how to build the Bob language interpreter using CMake + Ninja across different platforms.
## 🚀 Quick Start
### Prerequisites
- **CMake** 3.20 or later
- **Ninja** build system
- **C++17** compatible compiler
### Platform-Specific Setup
#### 🍎 macOS
```bash
# Install via Homebrew
brew install cmake ninja
# Or via MacPorts
sudo port install cmake ninja
```
#### 🐧 Linux
**Ubuntu/Debian:**
```bash
sudo apt update
sudo apt install cmake ninja-build build-essential
```
**RHEL/CentOS/Fedora:**
```bash
# RHEL/CentOS
sudo yum install cmake ninja-build gcc-c++
# Fedora
sudo dnf install cmake ninja-build gcc-c++
```
**Arch Linux:**
```bash
sudo pacman -S cmake ninja gcc
```
#### 🪟 Windows
**Option 1: Visual Studio (Recommended)**
- Install Visual Studio 2019+ with C++ workload
- Install CMake via Visual Studio Installer
- Install Ninja: `winget install Ninja-build.Ninja`
**Option 2: MSYS2/MinGW**
```bash
# In MSYS2 terminal
pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
```
**Option 3: Chocolatey**
```powershell
# In Administrator PowerShell
choco install cmake ninja visualstudio2022buildtools
```
## 🔨 Build Commands
### Standard Build
**Release Build (Optimized):**
```bash
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
ninja -C build
```
**Debug Build (Development):**
```bash
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Debug
ninja -C build
```
### Platform-Specific Examples
#### macOS/Linux
```bash
# Configure and build
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
ninja -C build
# Run interpreter
./build/bin/bob
# Run test suite
./build/bin/bob test_bob_language.bob
# Run with custom script
./build/bin/bob your_script.bob
```
#### Windows (PowerShell/CMD)
```powershell
# Configure and build
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
ninja -C build
# Run interpreter
.\build\bin\bob.exe
# Run test suite
.\build\bin\bob.exe test_bob_language.bob
# Run with custom script
.\build\bin\bob.exe your_script.bob
```
#### Windows (MSYS2/Git Bash)
```bash
# Same as macOS/Linux
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
ninja -C build
./build/bin/bob.exe test_bob_language.bob
```
## 🧪 Testing
### Automated Testing
**All Platforms:**
```bash
# Build first
ninja -C build
# Run tests via CTest
cd build
ctest --output-on-failure
# Or run tests verbosely
ctest --verbose
```
**Windows PowerShell:**
```powershell
ninja -C build
cd build
ctest --output-on-failure
```
### Manual Testing
**Interactive Mode:**
```bash
# Unix-like systems
./build/bin/bob
# Windows
.\build\bin\bob.exe
```
**Script Execution:**
```bash
# Unix-like systems
./build/bin/bob examples/hello.bob
# Windows
.\build\bin\bob.exe examples\hello.bob
```
## ⚡ Performance
**CMake + Ninja** provides fast, cross-platform builds with excellent incremental compilation.
## 🔧 Advanced Configuration
### Custom Install Location
**Unix-like:**
```bash
cmake -G Ninja -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/bob
ninja -C build install
```
**Windows:**
```powershell
cmake -G Ninja -B build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX="C:\Program Files\Bob"
ninja -C build install
```
### Compiler Selection
**GCC:**
```bash
cmake -G Ninja -B build \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release
```
**Clang:**
```bash
cmake -G Ninja -B build \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release
```
**MSVC (Windows):**
```powershell
cmake -G Ninja -B build `
-DCMAKE_CXX_COMPILER=cl `
-DCMAKE_BUILD_TYPE=Release
```
## 🐛 Troubleshooting
### Common Issues
**CMake not found:**
- **macOS**: `brew install cmake`
- **Ubuntu**: `sudo apt install cmake`
- **Windows**: Install via Visual Studio or winget
**Ninja not found:**
- **macOS**: `brew install ninja`
- **Ubuntu**: `sudo apt install ninja-build`
- **Windows**: `winget install Ninja-build.Ninja`
**Compiler errors:**
- Ensure C++17 compiler is installed
- **Linux**: `sudo apt install build-essential`
- **Windows**: Install Visual Studio Build Tools
**Permission denied (Windows):**
- Run PowerShell as Administrator for system-wide installs
### Build Cache Issues
**Clean build:**
```bash
# Remove build directory
rm -rf build # Unix-like
rmdir /s build # Windows CMD
Remove-Item -Recurse build # PowerShell
# Reconfigure
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
ninja -C build
```

View File

@ -2,176 +2,176 @@
## Current Status ## Current Status
Bob is a working programming language with a solid foundation. Here's what's currently implemented: Bob is a mature, working programming language with a modern architecture and comprehensive feature set.
### ✅ **Core Language Features** ### ✅ **Core Language Features (Complete)**
#### **Data Types & Variables** #### **Data Types & Variables**
- **Numbers**: Integers, floats, automatic conversion - **Numbers**: Integers, floats, automatic conversion
- **Strings**: Literals, concatenation, multiplication - **Strings**: Literals, concatenation, multiplication, escape sequences
- **Booleans**: `true`, `false` - **Booleans**: `true`, `false`
- **None**: Null value representation - **None**: Null value representation
- **Arrays**: Dynamic arrays with indexing, assignment, and built-in functions
- **Dictionaries**: Hash maps with string keys and mixed-type values
- **Functions**: First-class functions as values
- **Variables**: Declaration, assignment, scoping - **Variables**: Declaration, assignment, scoping
- **Assignment System**: Dual system (statements + expressions for loops) - **Assignment System**: Dual system (statements + expressions for loops only)
#### **Operators** #### **Operators (Complete)**
- **Arithmetic**: `+`, `-`, `*`, `/`, `%` - **Arithmetic**: `+`, `-`, `*`, `/`, `%`, unary `-`
- **Comparison**: `==`, `!=`, `>`, `<`, `>=`, `<=` - **Comparison**: `==`, `!=`, `>`, `<`, `>=`, `<=`
- **Logical**: `&&`, `||`, `!` (with short-circuit evaluation) - **Logical**: `&&`, `||`, `!` (with short-circuit evaluation)
- **Bitwise**: `&`, `|`, `^`, `<<`, `>>`, `~` - **Bitwise**: `&`, `|`, `^`, `<<`, `>>`, `~`
- **Compound Assignment**: `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=` - **Compound Assignment**: `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`
- **Ternary**: `condition ? valueIfTrue : valueIfFalse` - **Ternary**: `condition ? valueIfTrue : valueIfFalse`
- **Increment/Decrement**: `++`, `--` (for array elements)
#### **Control Flow** #### **Control Flow (Complete)**
- **If Statements**: `if`, `else`, `else if` chains - **If Statements**: `if`, `else`, `else if` chains
- **While Loops**: Basic, nested, complex conditions - **While Loops**: Basic, nested, complex conditions
- **For Loops**: All clause variations, nested loops
- **Do-While Loops**: Basic, nested, break/continue support - **Do-While Loops**: Basic, nested, break/continue support
- **For Loops**: All clause variations, nested loops
- **Break/Continue**: Full support in all loop types - **Break/Continue**: Full support in all loop types
#### **Functions** #### **Functions (Complete)**
- **Function Declaration**: `func name(params) { body }` - **Function Declaration**: `func name(params) { body }`
- **Parameters**: Any number of parameters - **Parameters**: Any number of parameters (tested up to 100)
- **Return Values**: Explicit and implicit returns - **Return Values**: Explicit and implicit returns
- **Closures**: Lexical scoping with variable capture - **Closures**: Lexical scoping with variable capture
- **First-Class Functions**: Functions as values, parameters, return values - **First-Class Functions**: Functions as values, parameters, return values
- **Anonymous Functions**: `func(params) { body }` - **Anonymous Functions**: `func(params) { body }`
- **Nested Functions**: Functions defined inside other functions - **Nested Functions**: Functions defined inside other functions
- **Recursion**: Full support including deep recursion - **Recursion**: Full support including deep recursion
- **Tail Call Optimization**: Trampoline-based optimization to prevent stack overflow - **Tail Call Optimization**: Trampoline-based optimization preventing stack overflow
#### **Data Structures** #### **Data Structures (Complete)**
- **Arrays/Lists**: Full support with indexing, assignment, and built-in functions - **Arrays**: Full support with indexing, assignment, nested arrays
- **Maps/Dictionaries**: Full support with key-value pairs and built-in functions - **Dictionaries**: Full support with key-value pairs, nested dictionaries
- **Array Operations**: `len()`, indexing, assignment, nested arrays - **Array Operations**: `len()`, `push()`, `pop()`, indexing, assignment
- **Dictionary Operations**: `keys()`, `values()`, `has()`, indexing, assignment - **Dictionary Operations**: `keys()`, `values()`, `has()`, indexing, assignment
- **Mixed Types**: Arrays and dictionaries can hold any value types
#### **Standard Library** #### **Standard Library (Complete)**
- **`print()`**: Output with automatic type conversion - **I/O Functions**: `print()`, `printRaw()`, `input()`
- **`assert()`**: Testing with custom error messages - **Type System**: `type()`, `toString()`, `toNumber()`, `toInt()`, `toBoolean()`
- **`type()`**: Runtime type checking - **Testing**: `assert()` with custom error messages
- **`toString()`**: Universal string conversion - **Timing**: `time()` (microsecond precision), `sleep()`
- **`toNumber()`**: String-to-number conversion - **Utility**: `random()` (properly seeded), `eval()`, `exit()`
- **`input()`**: User input capability - **Data Structure**: `len()`, `push()`, `pop()`, `keys()`, `values()`, `has()`
- **`time()`**: Microsecond precision timing - **File I/O**: `readFile()`, `writeFile()`, `readLines()`, `fileExists()`
- **`random()`**: Random number generation (properly seeded)
- **`len()`**: Get length of arrays and strings
- **`keys()`**: Get all keys from dictionaries
- **`values()`**: Get all values from dictionaries
- **`has()`**: Check if key exists in dictionary
- **`eval()`**: Evaluate strings as Bob code
- **`sleep()`**: Pause execution for specified seconds
- **`exit()`**: Terminate program with exit code
#### **Advanced Features** #### **Advanced Features (Complete)**
- **String Operations**: Bidirectional string + number concatenation - **String Operations**: Bidirectional string + number concatenation
- **Number Formatting**: Smart significant digits - **Number Formatting**: Smart significant digits handling
- **Memory Management**: Automatic cleanup with shared pointers - **Memory Management**: Automatic cleanup with reference counting
- **Error Handling**: Comprehensive error reporting with context - **Error Handling**: Comprehensive error reporting with context
- **Testing Framework**: Built-in assert function - **Testing Framework**: Built-in assert function with 70+ comprehensive tests
- **Operator Precedence**: Full precedence hierarchy - **Operator Precedence**: Full precedence hierarchy implementation
- **Variable Shadowing**: Proper scoping rules - **Variable Shadowing**: Proper lexical scoping rules
- **Interactive Mode**: Full REPL with error handling - **Interactive Mode**: Full REPL with error handling
- **Cross-Type Comparisons**: Smart equality for all types
- **Copy Semantics**: Value vs reference copying for different types
### **Current Limitations** ### ✅ **Architecture & Infrastructure (Complete)**
#### **Advanced Language Features** #### **Modern Build System**
- **No Classes/Objects**: No object-oriented programming - **CMake**: Cross-platform build configuration
- **No Modules/Imports**: No code organization system - **Ninja**: High-speed build system (3.1x faster than Make)
- **No Exception Handling**: No try-catch blocks - **CTest**: Integrated testing framework
- **No Type Annotations**: No static type checking - **Cross-Platform**: Windows, macOS, Linux support
- **No Generics**: No parametric polymorphism - **Performance**: Optimized build times and incremental compilation
#### **Standard Library Gaps** #### **Clean Architecture**
- **No File I/O**: No reading/writing files - **Modular Design**: Separated parsing, runtime, stdlib, and CLI
- **No Network I/O**: No HTTP or socket operations - **Tier Separation**: Clear boundaries between language components
- **No Math Library**: No advanced mathematical functions (sqrt, max, min, etc.) - **Header Organization**: Organized by functional area
- **No Date/Time**: No date manipulation (except `time()`) - **Source Structure**: `src/headers/` and `src/sources/` organization
- **No String Processing**: No split, join, toUpper, toLower functions
#### **Development Tools** #### **Refactored Interpreter**
- **No Debugger**: No debugging tools - **Evaluator**: Expression evaluation (visitor pattern)
- **No Profiler**: No performance analysis - **Executor**: Statement execution and control flow
- **No Package Manager**: No dependency management - **RuntimeDiagnostics**: Utility functions and type checking
- **Memory Management**: Smart pointer usage throughout
- **Error System**: Centralized error reporting
### **Current Architecture Status**
```
Bob Language
├── Parsing Layer
│ ├── Lexer (tokenization)
│ ├── Parser (AST generation)
│ └── ErrorReporter (syntax errors)
├── Runtime Layer
│ ├── Evaluator (expression visitor)
│ ├── Executor (statement visitor)
│ ├── Interpreter (orchestration)
│ ├── Environment (variable scoping)
│ ├── Value (type system)
│ └── RuntimeDiagnostics (utilities)
├── Standard Library
│ └── BobStdLib (built-in functions)
└── CLI Interface
└── Bob (command-line interface)
```
## **Future Development Phases** ## **Future Development Phases**
### **Phase 1: Standard Library Expansion (High Priority)** ### **Phase 1: Advanced Language Features (Medium Priority)**
#### **File I/O** #### **Exception Handling System**
```bob
var content = readFile("data.txt");
writeFile("output.txt", "Hello World");
var lines = readLines("config.txt");
```
**Implementation Plan:**
- Add `readFile()` function for reading entire files
- Add `writeFile()` function for writing files
- Add `readLines()` function for reading files line by line
- Add error handling for file operations
#### **Math Library**
```bob
var result = sqrt(16); // 4.0
var max = max(5, 10, 3); // 10
var min = min(5, 10, 3); // 3
var abs = abs(-42); // 42
```
**Implementation Plan:**
- Add `sqrt()` for square root
- Add `max()` and `min()` for multiple arguments
- Add `abs()` for absolute value
- Add `pow()` for exponentiation
- Add `floor()`, `ceil()`, `round()` for rounding
#### **String Processing**
```bob
var parts = split("a,b,c", ","); // ["a", "b", "c"]
var joined = join(parts, "-"); // "a-b-c"
var upper = toUpper("hello"); // "HELLO"
var lower = toLower("WORLD"); // "world"
```
**Implementation Plan:**
- Add `split()` for string splitting
- Add `join()` for array joining
- Add `toUpper()` and `toLower()` for case conversion
- Add `trim()` for whitespace removal
- Add `replace()` for string replacement
### **Phase 2: Advanced Language Features (Medium Priority)**
#### **Exception Handling**
```bob ```bob
try { try {
var result = 10 / 0; var result = 10 / 0;
} catch (error) { } catch (error) {
print("Error: " + error); print("Error: " + error.message);
} finally {
print("Cleanup");
} }
``` ```
**Implementation Plan:** **Implementation Plan:**
- Add `try`/`catch` syntax - Add `try`/`catch`/`finally` syntax to parser
- Implement exception objects - Implement exception objects with stack traces
- Add `throw` statement - Add `throw` statement for custom exceptions
- Integrate with existing error system - Integrate with existing error system
#### **Object System Foundation** #### **Pattern Matching**
```bob ```bob
// Convert everything to inherit from Object base class match value {
// Enable method calls on all types case 0: "zero"
// Prepare foundation for classes and modules case 1 | 2: "small"
case x if x > 10: "large"
default: "other"
}
``` ```
**Implementation Plan:** **Implementation Plan:**
- Unify type system under Object base class - Add `match`/`case` syntax
- Convert functions to proper objects - Implement pattern matching logic
- Enable method calls on all data types - Support guards with `if` conditions
- Update Value union to work with object system - Add destructuring for arrays/dictionaries
#### **Classes & Objects** ### **Phase 2: Object System (Lower Priority)**
#### **Simple Objects**
```bob
var person = {
name: "Alice",
age: 30,
greet: func() {
return "Hello, I'm " + this.name;
}
};
```
**Implementation Plan:**
- Add object literal syntax
- Implement `this` binding
- Support method calls
- Add property access/assignment
#### **Classes (Optional)**
```bob ```bob
class Person { class Person {
init(name, age) { init(name, age) {
@ -188,140 +188,125 @@ class Person {
**Implementation Plan:** **Implementation Plan:**
- Add `class` keyword and syntax - Add `class` keyword and syntax
- Implement constructors with `init()` - Implement constructors with `init()`
- Support inheritance with `extends`
- Add method definitions - Add method definitions
- Support inheritance
### **Phase 3: Module System (Lower Priority)** ### **Phase 3: Module System (Lower Priority)**
#### **Modules/Imports** #### **Simple Modules**
```bob ```bob
import "math.bob"; // math.bob
import "utils.bob" as utils; func sqrt(x) { return x ** 0.5; }
func max(a, b) { return a > b ? a : b; }
// main.bob
import "math.bob" as math;
var result = math.sqrt(16); var result = math.sqrt(16);
var helper = utils.format("Hello");
``` ```
**Implementation Plan:** **Implementation Plan:**
- Add `import` statement syntax - Add `import` statement syntax
- Implement module loading from files - Implement module loading from files
- Support namespace aliases - Support namespace aliases
- Create built-in modules (math, utils, etc.) - Create standard library modules
### **Phase 4: Development Tools (Lower Priority)** ### **Phase 4: Language Enhancements (Optional)**
#### **Debugger** #### **Enhanced Standard Library**
```bob ```bob
debugger; // Breakpoint // Additional string functions
var x = 5; var parts = "a,b,c".split(",");
// Step through code var joined = ["a", "b", "c"].join("-");
var upper = "hello".toUpper();
// Math library
var result = Math.sqrt(16);
var max = Math.max(5, 10, 3);
``` ```
**Implementation Plan:** #### **Async/Await (Advanced)**
- Add `debugger` statement
- Implement breakpoint functionality
- Add step-through debugging
- Create debug console interface
#### **Profiler**
```bob ```bob
// Built-in performance analysis async func fetchData() {
// Function call timing var response = await http.get("api.com/data");
// Memory usage tracking return response.json();
}
``` ```
**Implementation Plan:**
- Add performance measurement functions
- Track function call times
- Monitor memory usage
- Generate performance reports
## **Implementation Guidelines** ## **Implementation Guidelines**
### **For Each New Feature:** ### **For Each New Feature:**
1. **Lexer**: Add new tokens if needed 1. **Design**: Plan syntax and semantics carefully
2. **Parser**: Add new expression/statement types 2. **Lexer**: Add new tokens if needed
3. **AST**: Define new node types 3. **Parser**: Add new expression/statement types
4. **Interpreter**: Implement evaluation logic 4. **AST**: Define new node types in Expression.h/Statement.h
5. **Testing**: Create comprehensive test cases 5. **Evaluator/Executor**: Implement evaluation logic
6. **Testing**: Write tests for the new feature
7. **Documentation**: Update language reference
### **Testing Strategy:** ### **Development Approach:**
```bob - **Testing**: Write tests for new features
// Use the built-in assert function for testing - **Error Messages**: Make errors helpful and clear
assert(add(2, 3) == 5, "add(2, 3) should equal 5"); - **Memory**: Use smart pointers to avoid leaks
assert(len([1, 2, 3]) == 3, "Array length should be 3"); - **Performance**: Don't make things unnecessarily slow
assert(has({"a": 1}, "a"), "Dictionary should have key 'a'"); - **Code Style**: Keep it readable and maintainable
``` - **Portability**: Make sure it works on different platforms
### **Code Quality Standards:**
- **Comprehensive Testing**: Every feature needs test coverage
- **Error Handling**: Graceful error messages with context
- **Documentation**: Update language reference
- **Performance**: Consider memory and speed implications
- **Professional Code**: Clean, maintainable, production-ready
## **Success Metrics** ## **Success Metrics**
### **Completed ✅** ### **What's Done ✅**
- [x] Core language syntax and semantics - [x] Core language syntax and semantics
- [x] All basic operators and expressions - [x] All operators and expressions
- [x] Control flow statements - [x] Control flow (if, while, for, do-while)
- [x] Functions and closures - [x] Functions, closures, and tail call optimization
- [x] Tail call optimization
- [x] Arrays and dictionaries - [x] Arrays and dictionaries
- [x] Standard library basics - [x] Standard library (25+ built-in functions)
- [x] Random number generation - [x] File I/O operations
- [x] Interactive REPL - [x] Interactive REPL
- [x] Testing framework - [x] Test suite with 70+ tests
- [x] Comprehensive error handling - [x] Error handling and reporting
- [x] Memory management - [x] Memory management
- [x] Assignment system design - [x] CMake + Ninja build system
- [x] Code quality improvements - [x] Modular architecture
- [x] Cross-platform support
- [x] Various optimizations
### **In Progress 🔄** ### **Might Add Later 📋**
- [ ] File I/O implementation - [ ] Exception handling (try/catch)
- [ ] Math library functions - [ ] Pattern matching
- [ ] String processing functions - [ ] Simple objects
- [ ] Module/import system
### **Planned 📋** - [ ] More built-in functions
- [ ] Exception handling system - [ ] Debugging tools
- [ ] Object system foundation
- [ ] Classes and objects
- [ ] Module system
- [ ] Development tools
## **Resources** ## **Resources**
- **[BOB_LANGUAGE_REFERENCE.md](BOB_LANGUAGE_REFERENCE.md)** - Complete language documentation - **[Language Reference](BOB_LANGUAGE_REFERENCE.md)** - Language documentation
- **[test_bob_language.bob](test_bob_language.bob)** - Comprehensive test suite - **[Build Guide](BUILD.md)** - How to build Bob
- **[Crafting Interpreters](https://craftinginterpreters.com/)** - Excellent resource for language implementation - **[Test Suite](../test_bob_language.bob)** - 70+ tests
- **[Crafting Interpreters](https://craftinginterpreters.com/)** - Helpful book for language implementation
## **Recent Major Achievements** ## **Recent Work**
### **Data Structures Implementation** ### **Architecture Cleanup (2025)**
- Full array support with indexing and assignment - Split the interpreter into separate components (Evaluator/Executor/RuntimeDiagnostics)
- Complete dictionary system with key-value operations - Switched to CMake + Ninja build system (3x faster builds)
- Built-in functions: `len()`, `keys()`, `values()`, `has()` - Reorganized code into cleaner modules
- Nested data structures support - Added Windows/macOS/Linux build support
### **Standard Library Expansion** ### **Feature Completion**
- `random()` function with proper seeding - Added file I/O and type conversion functions
- `eval()` for dynamic code execution - Implemented all the operators I wanted (bitwise, compound assignment, etc.)
- `sleep()` for timing control - Got arrays and dictionaries working properly
- `exit()` for program termination - Added tail call optimization and closures
### **Code Quality Improvements** ### **Testing & Polish**
- Professional code cleanup - Wrote 70+ tests covering pretty much everything
- Performance optimizations - Improved error messages to be more helpful
- Consistent error handling - Fixed memory leaks using smart pointers
- Memory leak prevention - Various performance improvements
### **Advanced Language Features**
- Tail call optimization with trampoline system
- Comprehensive error reporting with context
- Interactive REPL with full language support
- Memory management with automatic cleanup
--- ---
*Last updated: January 2025* Bob works well for what I wanted - a programming language with the features and syntax I prefer.
*Last updated: January 2025*