CloudScribe

CloudScribe

A statically typed scripting language for IT automation that compiles to JavaScript.

160
Tests Passing
~98%
Coverage
5
Compiler Stages
0
Runtime Deps

Why CloudScribe?

Python's readability meets PowerShell's utility, with compile-time guarantees.

Compile-Time Safety

Full static type checking catches errors before your scripts reach production. No more runtime surprises.

Task-Based Model

First-class task declarations organize automation workflows into composable units.

Compiles to JavaScript

Multi-pass optimizing compiler produces clean, readable JS. Constant folding, dead code elimination, and more.

See the Compiler in Action

Write CloudScribe, get optimized JavaScript.

Input — deploy.csc
task deploy {
  let services = ["web", "api", "db"];
  let count = 0;
  const TIMEOUT = 2 + 3;

  for svc in services {
    print("Deploying: " + svc);
    count++;
  }

  if count > 0 {
    print("Done: " + count);
  }
}
Output — JavaScript
// task: deploy
{
  let services_0 = ["web", "api", "db"];
  let count_1 = 0;
  const TIMEOUT_2 = 5; // folded!

  for (const svc_3 of services_0) {
    console.log("Deploying: " + svc_3);
    count_1++;
  }

  if (count_1 > 0) {
    console.log("Done: " + count_1);
  }
}

Example Programs

Real-world automation patterns, statically checked.

Data Backup

function backupFile(filename: string): boolean {
  print("Backing up: " + filename);
  return true;
}

task backupData {
  let files = ["config.json", "users.db", "logs.txt"];
  let completed = 0;

  for file in files {
    if backupFile(file) {
      print("Done: " + file);
      completed++;
    }
  }

  print("Backed up " + completed + " files");
}

Security Scan

function scanPort(port: int): boolean {
  return true;
}

task securityScan {
  let ports = [80, 443, 22];
  let threats = 0;

  for port in ports {
    if scanPort(port) {
      print("Port " + port + " secure");
    } else {
      threats++;
    }
  }
}

Type System

// Primitives
let count = 42;                  // int
let name = "server-01";          // string
let active = true;               // boolean
const MAX = 3;                   // immutable

// Compound types
let ports = [80, 443];           // [int]

// Expressions
let status = active ? "OK" : "DOWN";
let timeout = configTimeout ?? 30;
let result = (2 ** 8) % 256;

Compiler Architecture

Five-stage pipeline, each fully tested.

.csc Parser Analyzer Optimizer Generator .js
cloudscribe.ohm PEG grammar definition using Ohm
parser.js Produces a concrete syntax tree from source
analyzer.js Type checking, scope resolution, validation
optimizer.js Constant folding, dead code elimination
generator.js Transpiles optimized IR to JavaScript
core.js AST node constructors and type system

Compile-Time Error Detection

CloudScribe catches these errors before your code ever runs.

ERR Redeclared variables
ERR Undeclared identifiers
ERR Type mismatches in expressions
ERR Non-boolean conditions
ERR Non-array in for...in
ERR break outside loop
ERR Assignment to const
ERR Wrong argument count
ERR Calling non-functions
ERR Non-integer array index

Quick Start

# Clone and install
git clone https://github.com/patrickking67/cloudscribe.git
cd cloudscribe && npm install

# Compile a script to JavaScript
node src/cloudscribe.js examples/data_backup.csc js

# Other output stages
node src/cloudscribe.js script.csc parsed      # syntax check
node src/cloudscribe.js script.csc analyzed     # typed AST
node src/cloudscribe.js script.csc optimized    # optimized IR

# Run the test suite (160 tests, ~98% coverage)
npm test