Skip to main content

Prototype interpreter and design docs for the Greyalien language.

Project description

Greyalien Language (Prototype)

CI PyPI

This is a prototype implementation of the Greyalien language concept: a new, experimental programming language designed to surpass traditional systems languages in clarity and safety.

This ZIP includes:

  • SPEC.md – Greyalien v0 conceptual language design.
  • SPEC_V0.md – the subset spec implemented by this interpreter.
  • GREYALIEN_CORE.md – core design principles.
  • GREYALIEN_VISION.md – long-term vision and roadmap.
  • compiler_architecture.md – high-level architecture for a future native Greyalien compiler.
  • LICENSE – MIT license.
  • CONTRIBUTING.md – contribution guide.
  • CHANGELOG.md – release notes.
  • RELEASE.md – release checklist.
  • ROADMAP.md – v0.2 scope and priorities.
  • TRIAGE.md – issue triage guide.
  • Makefile – release helper targets.
  • greyalien/ – a minimal Greyalien interpreter implemented in Python for a small v0 subset.
  • examples/ – runnable .grl programs.

Note: The interpreter is intentionally small. It runs a Greyalien subset with functions, conditionals, loops, records, lists, match expressions, enums, imports, arithmetic, booleans, and printing. It is meant as a working playground, not a production compiler.

A minimal static type checker for Int, Bool, and String runs before execution and reports type errors.

What's new in v0.3.0

  • match expressions, enums, and enum payloads.
  • Module imports with a minimal loader.
  • Conformance fixtures and parser fuzz coverage.

Unreleased (main branch)

  • Scoped module namespaces (imports require qualification, e.g. math.add(...)).
  • Explicit exports (export { ... }) control module visibility.
  • Exported enums are type-only; variants must be listed explicitly.
  • Enum payload bindings in match patterns (for example, Some(x)).
  • Module-qualified enum types in annotations (for example, colors.Color).

Requirements

  • Python 3.9+

Install from PyPI

python -m pip install greyalien-prototype

Create a file hello.grl:

fn main() {
  print("Hello from Greyalien!");
}

Run it:

greyalien run hello.grl

Install from source

python -m pip install -e .

Then run:

greyalien run examples/hello.grl

Running examples

From the directory where you unpack the ZIP:

python -m greyalien.cli examples/hello.grl

Or with the unified CLI:

python -m greyalien run examples/hello.grl

You should see:

Hello from Greyalien!

Another example:

python -m greyalien.cli examples/math.grl

Or:

python -m greyalien run examples/math.grl

Expected output:

Result is 42

Module example with qualified enum types:

python -m greyalien run examples/modules/type_qual_demo.grl

Expected output:

red

Logic example:

python -m greyalien.cli examples/logic.grl

For-loop example:

python -m greyalien.cli examples/for_demo.grl

Typed example:

python -m greyalien.cli examples/typed.grl

Record example:

python -m greyalien.cli examples/records.grl

List example:

python -m greyalien.cli examples/list_demo.grl

Match example:

python -m greyalien.cli examples/match_demo.grl

Enum example:

python -m greyalien.cli examples/enum_demo.grl

Enum payload example:

python -m greyalien.cli examples/enum_payload_demo.grl

Module/import example:

python -m greyalien.cli examples/modules/module_demo.grl

Running tests

python -m unittest discover -s tests

Maintainer notes

  • Issue triage flow and labels: TRIAGE.md
  • Label definitions live in .github/labels.yml and sync via the Label Sync workflow

Type checking only

python -m greyalien check examples/typed.grl

CLI quick reference

greyalien <file.grl>
greyalien run <file.grl>
greyalien check <file.grl>
greyalien ir <file.grl>
greyalien --all-errors <file.grl>
greyalien run --all-errors <file.grl>
greyalien check --all-errors <file.grl>
greyalien --version
greyalien --help

CLI help example

greyalien --help
Usage:
  greyalien <file.grl>
  greyalien run <file.grl>
  greyalien check <file.grl>
  greyalien ir <file.grl>
  greyalien --all-errors <file.grl>
  greyalien run --all-errors <file.grl>
  greyalien check --all-errors <file.grl>
  greyalien --version
  greyalien --help

Options:
  --all-errors  Show all parse errors instead of the first.

Parse error diagnostics

Use --all-errors to report every parse error in one run:

greyalien check --all-errors examples/for_demo.grl

Subset supported by the interpreter

  • Optional module declaration (ignored at runtime):

    module main
    
  • Function definitions:

    fn main() {
      print("Hello");
    }
    
    fn add(a, b) {
      return a + b;
    }
    
  • Optional type annotations (checked before execution):

    fn add(a: Int, b: Int) -> Int {
      return a + b;
    }
    
    fn main() {
      let x: Int = 1;
      print("x = " + x);
    }
    

    Type errors include line/column locations where available.

  • let bindings inside functions:

    fn demo() {
      let x = 10;
      let y = x * 2;
      print(y);
    }
    
  • set assignments to update existing bindings:

    fn demo() {
      let count = 0;
      set count = count + 1;
    }
    
  • while loops:

    fn demo() {
      let i = 0;
      while i < 3 {
        print(i);
        set i = i + 1;
      }
    }
    
  • for loops over integer ranges:

    fn demo() {
      for i in 0..10 by 2 {
        print(i);
      }
    }
    

    Use start..end for exclusive ranges or start..=end for inclusive ranges. Add by step to control the step size.

  • break and continue inside loops:

    fn demo() {
      for i in 0..10 {
        if i == 2 { continue; } else { print(i); };
        if i == 5 { break; } else { 0; };
      }
    }
    
    fn demo() {
      let i = 0;
      while true {
        set i = i + 1;
        if i == 2 { continue; } else { 0; };
        if i == 4 { break; } else { 0; };
      }
    }
    
  • return statements in functions.

  • Expressions:

    • Integer literals: 1, 42
    • String literals: "hello"
    • Boolean literals: true, false
    • Record literals: {x: 1, y: 2}
    • List literals: [1, 2, 3]
    • Unary operators: -expr, !expr
    • Binary operators: +, -, *, /, ==, !=, <, <=, >, >=, &&, ||
    • Field access: expr.field
    • Indexing: expr[index]
    • Parentheses: (expr)
    • if expressions: if cond { expr; } else { expr; }
    • else if is supported as sugar for else { if ... }
  • Function calls: name(arg1, arg2)

  • Built-in print(...) for output.

Types supported by the checker: Int, Bool, String, Unit.

Anything else will result in a parse or runtime error.

Example Greyalien program

module main

fn main() {
  let a = 40;
  let b = 2;
  let result = a + b;
  print("Result is " + result);
}

This runs on the interpreter and prints:

Result is 42

Enjoy experimenting with Greyalien!

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

greyalien_prototype-0.3.0.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greyalien_prototype-0.3.0-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file greyalien_prototype-0.3.0.tar.gz.

File metadata

  • Download URL: greyalien_prototype-0.3.0.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for greyalien_prototype-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0589cf7eaa9c70bd77edce5453234d4cd15e160151899be0ac1e74addb2afb17
MD5 6d680b572095aeaf9e998659704d4c86
BLAKE2b-256 ba183b65b216ba63e8604786b2cbeea03e7782af38266938c9d8f404c899ca70

See more details on using hashes here.

Provenance

The following attestation bundles were made for greyalien_prototype-0.3.0.tar.gz:

Publisher: publish.yml on JROChub/greyalien-prototype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file greyalien_prototype-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for greyalien_prototype-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 526c0627972c01bec8f4b33505657d64f9fd24f59a69dc827c79b50780ebb04c
MD5 0b122bc53d30bae4faec98ae5bb6635c
BLAKE2b-256 20223c4749caa6d54963882296460954be7e1a535f4ff49bcf2c50d1c91bac15

See more details on using hashes here.

Provenance

The following attestation bundles were made for greyalien_prototype-0.3.0-py3-none-any.whl:

Publisher: publish.yml on JROChub/greyalien-prototype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page