Skip to main content

ArchScript programming language — Python-like syntax, Haskell-inspired features, Arch Linux integration

Project description

ArchScript

A programming language designed on top of Arch Linux: Python-like syntax, Haskell-inspired functional features, and first-class integration with the Arch ecosystem.

Features

  • Python-like syntax with clean, readable code
  • Haskell-inspired pattern matching, algebraic data types, traits
  • First-class Arch Linux integration — built-in pacman, systemd, aur, and fs modules
  • First-class functions and closures with lambda expressions
  • Pipe operator (|>) for function composition
  • Built-in types: integers, floats, strings, booleans, lists, dicts, tuples
  • Type definitions (type, data, trait, instance)
  • List comprehensions and higher-order functions (map, filter)
  • Recursive functions with proper closure support
  • Interactive REPL with persistent state, multiline support, and introspection commands
  • CLI for running scripts, parsing, and evaluating expressions

Building

cargo build

Usage

# Run a source file
archscript run examples/hello.as

# Run the Arch Linux stdlib demo
archscript run examples/archlinux.as

# Evaluate an expression
archscript eval "2 + 3 * 4"

# Start an interactive REPL session
archscript repl

# Parse and print AST (debugging)
archscript parse examples/hello.as

Language Overview

Variables

var x = 42
var name = "ArchScript"
var pi = 3.14159

Functions

def add(a, b) = a + b

def factorial(n) = if n <= 1: 1
    else: n * factorial(n - 1)

Lambda Expressions

var double = lambda x: x * 2

Control Flow

if x > 0: println("positive")
    elif x == 0: println("zero")
    else: println("negative")

for i in range(10): println(str(i))

while x > 0: x = x - 1

Pattern Matching

match value {
    0 => println("zero"),
    1 => println("one"),
    x if x > 0 => println("positive"),
    _ => println("other")
}

Data Types

data Color = Red | Green | Blue | Custom(r, g, b)
type Point = Tuple(Float, Float)

Pipe Operator

result = data |> transform |> filter_fn |> summarize

Imports

import math
import { sqrt, pi } from math
import math as m

Interactive REPL

Start an interactive session with archscript repl:

$ archscript repl
ArchScript 0.1.0 REPL
Type :help for help, :quit to exit.
>>> var x = 42
>>> x * 2
84
>>> def greet(name) = "Hello, " + name + "!"
>>> greet("Arch")
Hello, Arch!
>>> :env
  greet = <function greet>
  x = 42
>>> :quit

REPL commands: :help, :quit, :env (show variables), :reset (clear state), :ast <expr> (show AST).

Arch Linux Standard Library

ArchScript ships with built-in modules for Arch Linux system management. See docs/stdlib.md for the full reference.

// Package management
var result = pacman.install("vim")
println(result.command)     // "sudo pacman -S --noconfirm vim"
println(result.success)     // True or False

// Service management
systemd.enable("sshd")
systemd.start("sshd")
var status = systemd.status("nginx")

// AUR packages
aur.install("visual-studio-code-bin")
aur.search("spotify")

// File system
fs.write("/tmp/hello.txt", "Hello from ArchScript!")
var content = fs.read("/tmp/hello.txt")
var exists = fs.exists("/etc/pacman.conf")
var files = fs.ls("/etc")
fs.mkdir("/tmp/mydir")
fs.remove("/tmp/hello.txt")

Modules available:

Module Description Functions
pacman Package management install, remove, update, search, list, info
systemd Service management start, stop, restart, enable, disable, status
aur AUR helper (yay) install, search, update, info
fs File system I/O read, write, exists, ls, mkdir, remove

Project Structure

src/
  archscript.pest   -- Pest grammar (PEG)
  ast.rs            -- AST node definitions
  parser.rs         -- Pest parse tree to AST conversion
  interpreter.rs    -- Tree-walking interpreter
  repl.rs           -- Interactive REPL
  main.rs           -- CLI entry point
  lib.rs            -- Library module exports
  stdlib/
    mod.rs          -- Stdlib module registry and dispatch
    pacman.rs       -- Pacman package management
    systemd.rs      -- Systemd service management
    aur.rs          -- AUR helper wrapper
    fs.rs           -- File system operations
tests/
  integration.rs    -- Integration tests (48 tests)
examples/
  hello.as          -- Hello world example
  functions.as      -- Functions example
  archlinux.as      -- Arch Linux stdlib demo
docs/
  stdlib.md         -- Standard library reference
  architecture.md   -- Architecture overview
  development.md    -- Development guide
  language-reference.md -- Language reference
  grammar-reference.md  -- Pest grammar reference

Running Tests

cargo test                    # all 121 tests
cargo test --lib              # unit tests only
cargo test --test integration # integration tests only
cargo test stdlib             # stdlib tests only
cargo test repl               # REPL tests only

Documentation

License

MPL-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

archscript-0.2.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (625.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

archscript-0.2.4-py3-none-macosx_11_0_arm64.whl (569.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

archscript-0.2.4-py3-none-macosx_10_12_x86_64.whl (606.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file archscript-0.2.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for archscript-0.2.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fde91acdfd9951daf1b33bda6ab46e2a19750e321336b26fe102f822b497fe9b
MD5 b8e3f9cde925d6e83117a15eadd8922a
BLAKE2b-256 1f25113a18e94da6cb8f7f16f8f3884b675e2d8fb9d7d9b12dd423ded1b25823

See more details on using hashes here.

File details

Details for the file archscript-0.2.4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for archscript-0.2.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63a65c9cd682d5e836edf39e0e7ddccf1aa99e76598965a2ac1fcb1b4adb4287
MD5 ce99f4c71a05fdad13e58afc742be6bd
BLAKE2b-256 6af0d45c9b072fbcdf776ee903b59eb15ed6410e57af52af9f849f1095cf28bc

See more details on using hashes here.

File details

Details for the file archscript-0.2.4-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for archscript-0.2.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3bdce113c060520bcf2d4969f54d429061cdde0b6b342d8aede16949c8f1cc52
MD5 28de3749115ad6a4993451704a8b852c
BLAKE2b-256 c0423a44ac2d8c7cfb830890f14568540c5d9193494f1c0257aa77e02117bcfb

See more details on using hashes here.

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