Parsley Language Manual

The complete reference for the Parsley programming language. Parsley is a modern, expression-oriented language designed for building web applications with the Basil server.

New to Parsley? Start with the Getting Started Tutorial for a hands-on introduction, then explore the topics below.


Language Fundamentals

Core language concepts — start here to learn how Parsley works.

Page Description
Comments Single-line and block comments
Variables & Binding let, destructuring, scope, and reassignment
Types All types, coercion rules, typeof, and is
Operators Arithmetic, comparison, logical, and special operators
Functions Function expressions, closures, destructuring, and this binding
Control Flow if/else, for, while, skip, stop, and check
Error Handling try/catch, check, fail, and error objects
Modules import, export, and module resolution
Tags HTML/XML tag syntax, attributes, children, and components
Data Model Schemas, records, and tables — how structured data fits together

Built-in Types

Reference pages for each of Parsley's built-in types.

Page Description
Booleans & Null true, false, null, and truthiness
Numbers Integers, floats, arithmetic, and formatting
Strings String literals, interpolation, methods, and formatting
Arrays Ordered collections with map, filter, reduce, sort, and more
Dictionaries Key-value pairs, destructuring, this binding, and iteration
Schemas Declaring data shapes with types, constraints, and metadata
Records Schema-bound dictionaries with validation and form binding
Tables Typed tabular data with query, aggregation, and export methods
Regex Regular expressions — literals, operators, and methods
Paths File path literals, interpolation, properties, and methods
URLs URL literals, interpolation, properties, and methods
DateTime Date and time values, formatting, and arithmetic
Duration Time durations and date arithmetic
Money Currency values, arithmetic, and formatting
Units Physical measurements — length, mass, volume, temperature, area, and data

Features

Parsley's I/O and integration capabilities.

Page Description
Command Line Interface pars commands, options, and security flags
Interactive REPL REPL commands, output modes, and debugging
File I/O Reading and writing files with operators and handles
Database Database connections, SQL tag, transactions, and table bindings
Query DSL Declarative queries — @query, @insert, @update, @delete
Data Formats Parsing and generating Markdown, CSV, and JSON
HTTP & Networking fetch operator, HTTP methods, and SFTP
Shell Commands @shell and the execute operator
Security Model Security policy, file restrictions, and injection prevention
PLN Parsley Literal Notation — safe data serialization format

Standard Library

Importable modules providing higher-level functionality.

Module Description
@std/math Constants, rounding, statistics, random, trigonometry, and geometry
@std/valid Validation predicates for types, strings, numbers, and formats
@std/id ID generation — ULID, UUID v4/v7, NanoID, CUID
@std/hash Cryptographic hashing — MD5, SHA-1, SHA-256, SHA-512
@std/mdDoc Markdown document analysis — headings, links, TOC, and transforms

Server Modules (@basil/)

Module Description
@basil/api Auth wrappers, error helpers, and redirect for Basil handlers
@basil/log Development logging utilities for Basil handlers
@basil/html Accessible HTML form and UI components
Session Management basil.session — key-value storage and flash messages

Deprecated Modules

Module Replacement
@std/table Built-in table type — use .parseCSV() or CSV()
@std/schema @schema { ... } DSL syntax
@std/api @basil/api
@std/dev @basil/log
@std/html @basil/html

Quick Reference by Topic

Working with Text

Strings · Regex · Data Formats · @std/valid

Working with Data

Arrays · Dictionaries · Tables · @std/table · Schemas · Records · Data Model

Building Web Pages

Tags · Modules · Strings (interpolation) · Control Flow (for loops)

Database Access

Database · Query DSL · Schemas · Tables

Building APIs

@basil/api · HTTP & Networking · Session Management · Error Handling

Files & External Systems

File I/O · Paths · URLs · HTTP & Networking · Shell Commands · PLN

Dates, Numbers, Money & Measurements

Numbers · DateTime · Duration · Money · Units · @std/math


Suggested Reading Order

If you're learning Parsley from scratch, we recommend this path:

  1. Getting Started — Your first Parsley program
  2. Variables and Types — The basics
  3. Strings and Arrays — Working with data
  4. Functions and Control Flow — Logic and structure
  5. Tags — Building HTML
  6. Modules — Organizing code
  7. Error Handling — Robust programs
  8. Features — Pick the topics relevant to your project