Skip to content

alb0o/lpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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 Start β€’ Language Spec β€’ Advanced Features β€’ Design Patterns β€’ Examples


πŸ† 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 Matching β€” match 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
  • 🎁 Generators β€” yield keyword for lazy evaluation
  • πŸ” Type Guards β€” typeof, 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:

  • Windows β†’ build/Release/lppc.exe
  • Unix β†’ build/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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages