Skip to main content

Prototype interpreter and design docs for the Greyalien language.

Project description

Greyalien Language (Prototype)

CI PyPI TestPyPI

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.1.tar.gz (50.8 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.1-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: greyalien_prototype-0.3.1.tar.gz
  • Upload date:
  • Size: 50.8 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.1.tar.gz
Algorithm Hash digest
SHA256 8de7c4758879ab5158563017734942cb8324e5052729c83749744a26aa2a1ac3
MD5 689ab7000f4dd7dd2a27b546283f691b
BLAKE2b-256 51bef8a0b81af6431254446408407b02248ea7039336a88071835ddee9fc2ebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for greyalien_prototype-0.3.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for greyalien_prototype-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4564b3de1d716dc1ecf9a69389852a9fb5dd1e61fb982dac2fe0bfb3017911a
MD5 ca4664fd9841ed25c489ffd96d5fda9c
BLAKE2b-256 8de5533a9c8403daca281cff4475ca2ca29aaffbf296097a26115c562a0e5d6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for greyalien_prototype-0.3.1-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