Syntax Overview
File Extensions
Section titled “File Extensions”| Extension | Output | Description |
|---|---|---|
.purus | .js | Standard JavaScript |
.cpurus | .cjs | CommonJS module |
.mpurus | .mjs | ES Module |
Comments
Section titled “Comments”-- This is a line comment
--- This is ablock comment ---Strings
Section titled “Strings”Strings use triple slashes ///:
const greeting be ///Hello, World///Escape sequences
Section titled “Escape sequences”| Escape | Result |
|---|---|
\n | Newline |
\t | Tab |
\\ | Backslash |
\/ | / |
\[ | [ |
\] | ] |
Numbers
Section titled “Numbers”const i be 42const f be 3.14Booleans and null
Section titled “Booleans and null”const a be trueconst b be falseconst c be nullconst d be nil -- alias for nullconst e be undefinedArrays
Section titled “Arrays”const arr be [1, 2, 3]const arr2 be [1; 2; 3] -- semicolons also workconst empty be []Objects
Section titled “Objects”const obj be [name be ///Alice///, age be 30]const empty-obj be [be] -- empty objectBrackets only
Section titled “Brackets only”Purus uses [] for everything — function calls, arrays, objects, and grouping. No () or {}.
Indentation
Section titled “Indentation”Blocks are defined by indentation (2 spaces recommended):
if x gt 0 console.log[///positive///]else console.log[///non-positive///]Identifiers
Section titled “Identifiers”Identifiers can contain hyphens (-), which are converted to underscores in JavaScript output:
const my-variable be 42-- compiles to: const my_variable = 42;