Syntax Reference
Complete LOVE-LANG syntax specification based on the formal ABNF grammar.
Syntax Reference
Section titled “Syntax Reference”LOVE-LANG has an intentionally minimal surface syntax. It is formally defined by an ABNF grammar derived from “Forma — A Formal Naturalized Language.”
Documents
Section titled “Documents”A LOVE document is a series of base statements, whitespace, and comments:
forma-doc = *(ws / comment / base-statement)Base Statements
Section titled “Base Statements”The fundamental unit of LOVE code is the base statement — assigning a value to a named key:
key = valuekey is value # 'is' is an alias for '='base-statement = key-def ws assign-op ws value ws *(newline)assign-op = "=" / "is"Examples
Section titled “Examples”name = "LOVE-LANG"version = 0.0.1active = truedescription is "A linguistics-oriented programming language"Type Annotations
Section titled “Type Annotations”You can optionally annotate the type of any key using two syntaxes:
name @[String] = "Alice" # angle-bracket styleage :Number = 30 # colon styletype-annotation = ( "@" "[" identifier "]" ) / ( ":" identifier )Atoms (Primitive Values)
Section titled “Atoms (Primitive Values)”| Atom type | Example | Description |
|---|---|---|
string | "hello world" | Double-quoted UTF-8 string |
number | 42, 3.14 | Integer or float |
boolean | true, false | Boolean literal |
symbol | :keyword | Lisp-style named constant |
identifier | myValue | Bareword reference |
datetime | (ISO 8601) | Date/time value |
The Five Expression Levels
Section titled “The Five Expression Levels”LOVE uses bracket depth to encode semantic complexity and trust. This is not merely syntactic sugar — each level has a distinct meaning in the evaluator’s topology.
L1 — Data Expressions [x]
Section titled “L1 — Data Expressions [x]”Simple S-expressions. Variables and primitive references.
colours = [red green blue]pair = [1 2]empty = []L2 — Pure Operations [[x]]
Section titled “L2 — Pure Operations [[x]]”Standard library math and pure functions. No side-effects.
sum = [[ + 1 2 3 ]]product = [[ * 6 7 ]]max-val = [[ Math.max [1 9 3 7] ]]L3 — Type Contracts [[[x]]]
Section titled “L3 — Type Contracts [[[x]]]”Structural schemas and type validators. Used for type checking.
UserPayload = [[[ name @[String] email @[String] age @[Number]]]]L4 — Compiler Directives [[[[x]]]]
Section titled “L4 — Compiler Directives [[[[x]]]]”Macros and compile-time transformations. Evaluated before the programme runs.
config = [[[[ #mode Production #target wasm #inline true]]]]L5 — System FFI / I/O [[[[[x]]]]]
Section titled “L5 — System FFI / I/O [[[[[x]]]]]”Side-effecting operations: file I/O, network, database writes. The highest trust level.
[[[[[ @sql_write "users" { :name "Alice" :age 30 }]]]]]
[[[[[ @http_post "https://api.example.com/record" payload]]]]]The “stuff inside” brackets — forms are recursive and data-only:
form = ws / comment / atom / expressionComments
Section titled “Comments”Comments begin with # and extend to end of line:
# This is a commentname = "LOVE" # inline commentIdentifiers and Symbols
Section titled “Identifiers and Symbols”# Valid identifiersmyValuemy-valuemy_value?my-predicate!
# Symbols (Lisp-style keywords):name:type:activeidentifier = 1*(ALPHA / "_") *ID-CHARID-CHAR = ALPHA / DIGIT / "-" / "_" / "?" / "!"symbol = ":" 1*ID-CHARComplete ABNF Reference
Section titled “Complete ABNF Reference”The formal grammar is reproduced here in full from syntax.abnf:
; 1. TOP LEVELforma-doc = *(ws / comment / base-statement)
; 2. BASE STATEMENTbase-statement = key-def ws assign-op ws value ws *(newline)key-def = identifier [ws type-annotation]assign-op = "=" / "is"value = atom / expression
; 3. TYPE ANNOTATIONtype-annotation = ( "@" "[" identifier "]" ) / ( ":" identifier )
; 4. CORE EXPRESSIONSexpression = meta-expr-5 / meta-expr-4 / macro-expr / type-expr / data-exprdata-expr = "[" *form "]"type-expr = "[[" *form "]]"macro-expr = "[[[" *form "]]]"meta-expr-4 = "[[[[" *form "]]]]"meta-expr-5 = "[[[[["*form "]]]]]"
; 5. FORMform = ws / comment / atom / expression
; 6. ATOMSatom = symbol / identifier / string / number / boolean / datetimesymbol = ":" 1*ID-CHARidentifier = 1*(ALPHA / "_") *ID-CHARID-CHAR = ALPHA / DIGIT / "-" / "_" / "?" / "!"
; 7. WHITESPACE & COMMENTSws = 1*(%x20 / %x09)comment = "#" *(%x20-%x10FFFF) %x0Anewline = %x0A