Skip to content

Latest commit

 

History

History
333 lines (250 loc) · 9.98 KB

File metadata and controls

333 lines (250 loc) · 9.98 KB

L++ — Light Programming Language

A statically-typed systems language with modern syntax that transpiles to C++

✅ ALPHA v0.8.19 - Stack Overflow Protection (BUG #300 fixed) ✅

Quick StartLanguage SpecAdvanced FeaturesDesign PatternsExamples


🏆 NEW: Automatic Design Pattern Generation

L++ introduces the revolutionary autopattern keyword that intelligently generates complete implementations of all 23 Gang of Four design patterns!

// ONE LINE = COMPLETE PATTERN IMPLEMENTATION!
autopattern Singleton ConfigManager;
autopattern Factory ShapeFactory;
autopattern Observer EventBus;

✨ Features:

  • 🎯 Intelligent Detection — Keyword-based pattern recognition
  • 🚀 Zero Boilerplate — Complete pattern in one line
  • 📚 All 23 GoF Patterns — Creational, Structural, Behavioral
  • 🔧 Smart Defaults — Pattern-specific methods and properties
  • 💡 Type Safe — Full C++ type system integration

→ See Complete Pattern Catalog


✨ Core Features

Language Features

  • 🎯 Modern Syntax — Rust/JS-inspired (arrow functions, destructuring, spread)
  • 🎨 Multi-Paradigm — HYBRID, FUNCTIONAL, IMPERATIVE, OOP, GOLFED (5 paradigms!)
  • 📦 ES6+ Support — Optional chaining (?.), nullish coalescing (??), template literals
  • Golf-Style Operators — Symbolic functional programming (~, @, ?, \)
  • 🔁 Iterate-While — Haskell-inspired sequence generation (!!<, !!>, !! $, ~>)
  • 🎭 Paradigm Enforcement — Per-file paradigm declaration with validation
  • 🔧 Pattern Matchingmatch expressions with guards
  • 🧩 ADTs — Algebraic data types and type unions
  • 🎨 Higher-Order Functions — Map, filter, compose, pipeline operator
  • 🔗 Interfaces & Traits — Protocol-oriented programming
  • 📝 List Comprehensions — Python-style syntax
  • 🌊 Lambda Expressions — Closures with capture
  • 🎁 Generatorsyield keyword for lazy evaluation
  • 🔍 Type Guardstypeof, instanceof operators
  • 📊 Getters/Setters — Property accessors with get/set
  • ⬅️ Arrow-Left Returns — Alternative return syntax (<-)

Static Analysis

  • 🛡️ Path-Sensitive Analysis — CFG + data-flow tracking
  • Paradigm Validation — Enforce functional purity, OOP, or imperative style
  • 🔍 Division by Zero — Compile-time detection
  • ⚠️ Uninitialized Variables — Catch bugs before runtime
  • 💀 Dead Code Detection — Find unreachable code
  • 🚫 Null Dereference — Safety checks (45/45 critical bugs fixed ✅)
  • 💧 Memory Leak Detection — Track allocations
  • 🔢 Integer Overflow — Warnings for potential overflows

Security & Safety (NEW in v0.8.16 🔒)

  • Memory Safe Patterns — Smart pointers in all design patterns
  • Command Injection Prevention — Path validation & shell escaping
  • Bounds Checking — 80+ array access validations
  • NULL Safety — nullptr checks after dynamic_cast
  • Virtual Destructors — Prevent undefined behavior
  • Thread-Safe Singleton — std::call_once implementation

Graph Algorithms (NEW in v0.8.16 📊)

  • 🔍 Path Finding — BFS-based path existence check
  • 🛤️ Shortest Path — Unweighted graph traversal
  • 🌐 Connected Components — Count graph components
  • 🎨 Bipartite Check — 2-colorability detection

Developer Experience

  • 🔧 VS Code Extension — Syntax highlighting + real-time errors
  • 📖 Problem Matcher — Errors shown directly in editor
  • 🚀 Fast Compilation — Transpiles to C++ then native code
  • High Performance — Optimized C++ output

📚 Documentation

Quick Links

Full Documentation Index

See docs/README.md for complete documentation with topic index.


🗂️ Project Structure

lpp/
├── src/                    # Compiler source code
├── include/                # Header files
├── stdlib/                 # Standard library
├── examples/               # Sample programs
├── tests/                  # Test suite
├── docs/                   # 📚 Complete documentation
│   ├── QUICKSTART.md       # Getting started
│   ├── FULL_SPEC.md        # Language reference
│   ├── ADVANCED_FEATURES.md # Modern features
│   ├── DESIGN_PATTERNS.md  # Pattern catalog
│   ├── PARADIGMS.md        # Programming styles
│   ├── BUG_FIXES.md        # Bug fix history (45 bugs fixed)
│   └── README.md           # Documentation index
├── vscode-extension/       # VS Code integration
├── CHANGELOG.md            # Version history
└── README.md               # This file

��� Quick Start

Installation

Download a release or build from source:

git clone https://github.com/alb0084/lpp.git
cd lpp
cmake -B build
cmake --build build --config Release

Compiler output:

  • Windowsbuild/Release/lppc.exe
  • Unixbuild/lppc

Your First Program

Create hello.lpp:

fn main() -> int {
    println("Hello, LPP!");
    return 0;
}

Compile & run:

lppc hello.lpp
./hello

��� Language Overview

Variables & Types

let x = 42;           // immutable by default
let mut counter = 0;  // mutable
counter = counter + 1;

let name: string = "LPP";   // explicit types
let pi: float = 3.14159;

Functions

fn add(a: int, b: int) -> int {
    return a + b;
}

let multiply = (x, y) => x * y;   // arrow functions
let squares = numbers.map(|n| n*n);

Control Flow

if (x > 0) {
    println("positive");
} else if (x < 0) {
    println("negative");
} else {
    println("zero");
}

let result = x > 0 ? "positive" : "negative";  // ternary

Modern Features

// Golf-style operators (compact functional programming)
let range = 0~10;                     // [0,1,2,...,10]
let doubled = nums @ (x -> x * 2);    // map
let evens = nums ? (x -> x % 2 == 0); // filter
let sum = nums \ ((acc,x) -> acc+x);  // reduce

// Iterate-while (Haskell-inspired sequence generation)
let countdown = 10 !!> 0;                      // [10,9,8,7,6,5,4,3,2,1]
let powers = 1 !! (x -> x < 100) $ (x -> x*2); // [1,2,4,8,16,32,64]
let squares = 1 ~> (x -> x+1) !! (x -> x < 10) @ (x -> x*x); // [1,4,9,16,25,36,49,64,81]

// Destructuring & spread
let [a, b, ...rest] = array;
let {x, y} = point;
let combined = [...a1, ...a2];

// Optional chaining & nullish coalescing
let city = user?.address?.city;
let username = user?.name ?? "Anon";

���️ Static Analysis

LPP includes a built-in analyzer that catches issues before compilation:

Example

fn example() -> int {
    let x;
    let y = x + 10;    // ERROR: uninitialized variable

    let z = 10 / 0;    // ERROR: division by zero

    return 0;
    println("unreachable"); // WARNING: dead code
}

Analyzer Capabilities

  • ✅ Division by zero detection
  • ✅ Uninitialized variable use
  • ✅ Dead code detection
  • ✅ Null dereference checks
  • ✅ Memory leak detection
  • ✅ Integer overflow warnings

���️ Architecture

LPP uses a multi-stage pipeline:

Source Code (.lpp)
    ↓
Lexer (Tokenization)
    ↓
Parser (AST Construction)
    ↓
Static Analyzer (CFG + Data-Flow)
    ↓
C++ Transpiler
    ↓
g++/clang (Native Compilation)
    ↓
Executable

Details in ARCHITECTURE.md.

📚 Documentation

��� Use Cases

  • Systems Programming — Low-level performance, modern syntax
  • Learning — Great introduction to compilers and type systems
  • Rapid Prototyping — Fast C++ generation without memory headaches
  • Embedded Development — Efficient binaries for constrained devices

��� Contributing

  1. Fork repository
  2. Create feature branch
  3. Commit changes
  4. Push branch
  5. Open Pull Request

��� Examples

See the examples/ directory:

��� Related Projects

  • LightJS — The original runtime that inspired LPP

��� License

MIT License — see LICENSE.

��� Acknowledgments

  • Clang Static Analyzer for CFG-based analysis approach
  • JavaScript/TypeScript for syntax inspiration
  • Rust for modern language design principles

Built with ❤️ for modern systems programming

⭐ Star on GitHub��� Report Bug��� Request Feature