A simple toy programming language built in Python
Project description
GlimLang ๐
GlimLang is a lightweight, educational toy programming language designed and implemented entirely from scratch in Python. It features a hand-written Lexical Analyzer (Lexer), a recursive descent Parser that structures tokens into an Abstract Syntax Tree (AST), and a stateful, tree-walking Interpreter supporting first-class environments.
GlimLang is packed with modern language constructs including first-class anonymous functions (lambdas), pattern matching (match statements), classes (OOP), and a highly capable pre-compiled built-ins library. It serves as an accessible entry point for students, educators, and curious developers seeking to understand compiler design and programming language internals.
๐ Key Features
- โ๏ธ Hand-Written Pipeline: Completely custom Lexer and Parser written in readable Python with zero external parsing dependencies.
- ๐ฆ Rich Type System: Numbers (floats/integers), Strings (with f-string dynamic interpolation), Booleans, explicit
null, dynamic Arrays, and custom Blueprint Classes. - ๐ฏ Anonymous Functions & Closures: Standard function statements (
def) and inline lambdas (fn) that carry outer lexical scopes. - ๐ Advanced Pattern Matching: A robust
matchconstruct supporting piped patterns (|), fallback wildcards (_), and multi-statement block arms. - ๐๏ธ Object-Oriented Programming (OOP): Custom blueprint templates (
class), constructor instantiators (init), self-referencing properties (self.x), and standard methods. - ๐ ๏ธ Native Built-ins Library: Over 40 native helper functions covering complex arithmetic, string slicing, array filter/maps, file reader/writers, and user input prompts.
๐ฆ Installation
Ensure you have Python 3.8 or higher installed. Clone the repository and install it in editable developer mode:
git clone https://github.com/YOUR_GITHUB_USERNAME/glimlang.git
cd glimlang
pip install -e .
Verify your installation has registered the global gl command utility:
gl version
Expected Output:
GlimLang v1.2.2
โก Syntax Preview & Showcase
Functions and Lexical Closures
# Let's create an anonymous function and assign it to a variable
let double = fn(x) { return x * 2 }
print double(10) # Prints 20.0
# Pass named/anonymous functions directly into array helper functions
let scores = [1, 2, 3, 4]
let doubled_scores = map(scores, double)
print doubled_scores # Prints [2.0, 4.0, 6.0, 8.0]
Pattern Matching (match)
let browser_status = 404
match browser_status {
200 => print "Success"
404 => print "Page Not Found"
500 | 502 => {
print "Server Error!"
print "Please try again later."
}
_ => print "Unknown Status Code"
}
๐ Quick Start CLI Usage
Run GlimLang Files
Save a simple print statement inside hello.glim and run it:
gl run examples/hello.glim
Run the Interactive REPL
Type GlimLang expressions directly in an active terminal loop:
gl repl
REPL Shell:
GlimLang> let msg = "Hello from REPL!"
GlimLang> print msg
Hello from REPL!
GlimLang> exit
๐ Project Structure
glimlang/
โโโ src/ # Source code directory
โ โโโ glimlang/ # Core compiler & interpreter package
โ โโโ __init__.py # Package initialization
โ โโโ __main__.py # CLI execution entrypoint
โ โโโ lexer.py # Lexical analysis (character streams -> tokens)
โ โโโ parser.py # Syntactic analysis (token lists -> AST nodes)
โ โโโ ast_nodes.py # Abstract Syntax Tree structural dataclasses
โ โโโ interpreter.py # Stateful environment walker & native builtins
โ โโโ errors.py # Standardized diagnostics and trace compiler
โ โโโ cli.py # Positional argument CLI router (run, repl, help)
โ โโโ main.py # Programmatic API entrypoint
โ โโโ stdlib.glim # Code helper utilities written in GlimLang
โโโ docs/ # Documentation and Guides
โ โโโ ARCHITECTURE.md # Pipeline state flows and design patterns
โ โโโ CLI.md # Global CLI command references
โ โโโ EXAMPLES.md # Example catalog with detailed output keys
โ โโโ GETTING_STARTED.md # Installation and REPL setup instructions
โ โโโ INSTALL.md # Brief installation info
โ โโโ LANGUAGE_GUIDE.md # Core syntax, scoping, OOP, and builtins list
โ โโโ README_WEB.md # Web playground readme
โ โโโ glimlang_docs.html # Compiled docs in HTML
โ โโโ index.html # Documentation index HTML
โโโ examples/ # Example programs in GlimLang
โ โโโ arrays.glim # Array syntax and allocations
โ โโโ builtins.glim # Demonstrates built-in function groups
โ โโโ builtins_demo.glim # Rich showcase of standard builtins
โ โโโ calculator.glim # Match-based interactive calculator
โ โโโ conditions.glim # Conditional check control flows
โ โโโ countdown.glim # Simple countdown loop
โ โโโ error_handling.glim # Error catching syntax tests
โ โโโ fizzbuzz.glim # FizzBuzz implementation
โ โโโ functions.glim # Scope boundaries and functions
โ โโโ grade_checker.glim # Nested grade categorization
โ โโโ greeting.glim # Standard greetings
โ โโโ hello.glim # Hello World program
โ โโโ import_demo.glim # Demo of loading dependencies
โ โโโ indexing.glim # Array index getters and setters
โ โโโ lambdas_demo.glim # Anonymous functions and closures
โ โโโ match_demo.glim # Advanced pattern matching features
โ โโโ math.glim # Expressions and math utilities
โ โโโ nested_conditions.glim # Deeply nested conditions
โ โโโ simple_menu.glim # Simple menu loops
โ โโโ stdlib_demo.glim # Demonstrates stdlib integrations
โ โโโ strings.glim # Dynamic f-string interpolation
โ โโโ utils.glim # Basic utility functions
โ โโโ variables.glim # Basic let-bindings and identifiers
โ โโโ while_loop.glim # While loop control structures
โโโ vscode-extension/ # Visual Studio Code editor extension
โ โโโ glimlang-vscode/ # Syntax highlighting and snippet files for VS Code
โโโ web/ # Interactive web-based playground/terminal
โ โโโ server.py # Web application server
โ โโโ requirements.txt # Web playground dependencies
โ โโโ templates/ # HTML templates for the playground
โโโ pyproject.toml # Modern build metadata and CLI mapping
โโโ setup.py # Setuptools project routing configuration
โโโ CONTRIBUTING.md # Developer setup and AST feature safety checks
โโโ CHANGELOG.md # Historical release logs
โโโ LICENSE # Project License File (Apache 2.0)
๐ Documentation Reference Links
For more guides and documentation, visit glimlang.org.
Deep-dive into GlimLang subsystems using these detailed local guides:
- ๐ Getting Started Guide โ Steps for installing Python, GlimLang CLI, and launching the REPL.
- ๐ Language Syntax Guide โ Comprehensive syntax definitions, classes, built-ins, and common mistakes.
- ๐ป CLI Reference Guide โ CLI flags, arguments, stdout, stderr, and exit codes.
- โ๏ธ Architecture & Implementation Design โ Source code flow diagram, environment frames, and a tutorial on how to add a feature.
- ๐ Examples Catalog โ Review of pre-made sample files and expected terminal stdout.
๐ ๏ธ Development Setup
Check CONTRIBUTING.md to set up a virtual environment, run code style formats, verify parser changes, and submit structured pull requests.
๐ License
GlimLang is licensed under the Apache License 2.0. See the LICENSE file for the complete terms.
๐บ๏ธ Future Roadmap
- Standard Module Imports: File imports support (
import "math.glim"). - Class Inheritance: Support standard blueprint extensions (
class Dog in Animal). - Inline Dictionary Literals: Explicit dictionary literals (
let dict = { "x": 10 }). - LSP Server: Language Server Protocol integration for autocompletions in IDEs.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glimlang-1.2.2.tar.gz.
File metadata
- Download URL: glimlang-1.2.2.tar.gz
- Upload date:
- Size: 47.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03353856daabe6a87ca27f3d8472a4bd2d1e9968ed77b3cdf27f7e41deb31667
|
|
| MD5 |
485ef4c8b57fa35c9a9ac4231747bfef
|
|
| BLAKE2b-256 |
49dfbdbd0997a53f59457ada4e30243a706b3655fc0e3ca73859ed416274edea
|
Provenance
The following attestation bundles were made for glimlang-1.2.2.tar.gz:
Publisher:
publish.yml on salmanghouridev/glimlang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glimlang-1.2.2.tar.gz -
Subject digest:
03353856daabe6a87ca27f3d8472a4bd2d1e9968ed77b3cdf27f7e41deb31667 - Sigstore transparency entry: 1810622208
- Sigstore integration time:
-
Permalink:
salmanghouridev/glimlang@3c229d0a0517a429dbe9d740024aa7260d0b2ba5 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/salmanghouridev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c229d0a0517a429dbe9d740024aa7260d0b2ba5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file glimlang-1.2.2-py3-none-any.whl.
File metadata
- Download URL: glimlang-1.2.2-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6788a1badeab77d3bae63b9d4ada68eb2b41ab47694971c3cb617cfdb88d1db4
|
|
| MD5 |
c5e9a0775e171a19cde9db7ae434339e
|
|
| BLAKE2b-256 |
41ce8a70d0fca83e144efe179be9e63c6638091dc70f48d67b24ef79b4f7b6cb
|
Provenance
The following attestation bundles were made for glimlang-1.2.2-py3-none-any.whl:
Publisher:
publish.yml on salmanghouridev/glimlang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glimlang-1.2.2-py3-none-any.whl -
Subject digest:
6788a1badeab77d3bae63b9d4ada68eb2b41ab47694971c3cb617cfdb88d1db4 - Sigstore transparency entry: 1810622227
- Sigstore integration time:
-
Permalink:
salmanghouridev/glimlang@3c229d0a0517a429dbe9d740024aa7260d0b2ba5 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/salmanghouridev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c229d0a0517a429dbe9d740024aa7260d0b2ba5 -
Trigger Event:
push
-
Statement type: