Skip to content

Sohmteee/Chameleon

Repository files navigation

🦎 Chameleon Programming Language

Chameleon Logo

A multi-paradigm, adaptive programming language that evolves with your coding style.

Write in Python, JavaScript, C++, or Java syntax—or mix them all together. Chameleon adapts to YOU.

🧩 Core Vision

Chameleon is designed to be:

  • Adaptive: Understands multiple syntactic patterns (Python, JavaScript, C++, Java)
  • Multi-Syntax: Use let, var, const, int, string, or any combination
  • 🎯 Type-Aware: Optional explicit typing with validation and inference
  • 📦 Modular: Full Python and C++ style import/include support with file resolution
  • 🔍 Intelligent Linting: Enhanced static analysis with cyclomatic complexity detection
  • Fast Interpretation: Pure Python implementation with efficient AST traversal
  • 🌍 Cross-platform: Runs on Windows, macOS, and Linux
  • 🎨 IDE Integration: Full VS Code extension with syntax highlighting, linting, formatting

🚀 Quick Start

Installation

No installation needed! Just have Python 3.x installed.

Running Code

# Run a Chameleon file
python chameleon_cli.py run your_file.cham

# Start interactive REPL
python chameleon_cli.py repl

# Lint a file
python chameleon_cli.py lint your_file.cham

# Format a file
python chameleon_cli.py format your_file.cham

# Or use VS Code: Ctrl+Shift+R (run), Ctrl+Shift+L (lint), Ctrl+Alt+F (format)

Your First Program

let name = "World"
print("Hello, " + name + "!")

def greet(String greeting, int count):
  for i in range(count):
    print(greeting + ", " + name)

greet("Hi", 3)

📚 Documentation

💡 Example Code

# Multi-syntax variable declarations
let x = 10              # Python style
var y = 20              # JavaScript style
int z = 30              # C++/Java style
String name = "Alice"   # Typed parameter

# All syntaxes work together
if x < y and y < z:
    print("Python logic!")
elif x < y && y < z {   # C++ style if/braces
    cout << "C++ logic!";
}

# Functions with typed parameters
def greet(String name, int age):
    print(name + " is " + age + " years old")

# Mixed print styles
greet("Bob", 25)
console.log("Done!")
cout << "Goodbye" << endl;

See EXAMPLES.cham for comprehensive examples of all features.

🏗️ Architecture

Chameleon consists of six main components:

  1. Lexer (lexer.py) — Tokenizes source code with multi-syntax awareness
  2. Parser (parser.py) — Builds Abstract Syntax Trees (AST) with dual block syntax
  3. Linter (linter.py) — Static code analyzer with enhanced rules
  4. Interpreter (interpreter.py) — Executes code via AST traversal
  5. Formatter (formatter.py) — Normalizes and beautifies code
  6. Runtime (runtime.py) — Manages scopes, functions, and built-ins

📁 Project Structure

chameleon/
├── src/                    # Core language implementation
│   ├── lexer.py            # Tokenization (multi-syntax)
│   ├── parser.py           # AST generation with dual syntax
│   ├── ast_nodes.py        # AST node definitions
│   ├── interpreter.py      # Execution engine
│   ├── runtime.py          # Runtime environment & built-ins
│   ├── linter.py           # Enhanced static code analyzer
│   ├── formatter.py        # Code formatter
│   ├── repl.py             # Interactive shell
│   └── main.py             # Core entry point
├── vscode-extension/       # VS Code extension
│   ├── src/extension.ts    # Extension implementation
│   ├── syntaxes/           # Syntax highlighting rules
│   ├── icons/              # File icons
│   └── package.json        # Extension manifest
├── tests/                  # Test suite
│   ├── test_lexer.py
│   ├── test_parser.py
│   ├── test_interpreter.py
│   ├── test_linter.py
│   └── test_formatter.py
├── docs/                   # Design specifications
├── chameleon_cli.py        # CLI interface
├── DOCUMENTATION.md        # Complete language documentation
├── EXAMPLES.cham           # Comprehensive examples
├── chameleon.png           # Language icon
└── README.md               # This file

🧪 Development Status

Phase 1: Python PrototypeCOMPLETE

Core Features Implemented:

  • ✅ Multi-syntax lexer and parser (Python, JavaScript, C++, Java)
  • ✅ Dual block syntax (: indentation and {} braces)
  • ✅ Full AST interpreter with proper scoping
  • ✅ Interactive REPL with multi-line support
  • Enhanced Static Linter with:
    • Cyclomatic complexity analysis
    • Unused parameter detection
    • Naming convention checking
    • False positive elimination for parameter usage
  • Code Formatter with 2-space indentation and operator normalization
  • Module/Import System:
    • Python import/from statements with file resolution
    • C++ #include statements with path resolution
  • Type System: Explicit typing with validation (int, float, string, bool, List, Dict)
  • Function Keywords: fn, def, function, void with optional typed parameters
  • VS Code Extension with:
    • Syntax highlighting for all supported styles
    • Live linting with inline diagnostics
    • Code execution and formatting via CLI
    • File icon integration
    • Terminal auto-clear on run/format
  • ✅ CLI tool with multiple commands
  • ✅ Comprehensive test suite

Phase 2 (Planned): Production Hardening & Performance

  • Package manager and standard library
  • Debugging support with breakpoints
  • Documentation generator
  • Performance optimizations
  • Error recovery and better diagnostics

📖 Learn More

See DOCUMENTATION.md for complete language documentation, features, syntax reference, and usage guides.

📄 License

MIT License - See LICENSE file for details


Created by Sohmtee | Building the future of adaptive programming 🚀

About

A multi-paradigm, adaptive programming language that evolves with your coding style.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published