OcaltQL Syntax & EMIT
OcaltQL is designed to read like English and execute like a machine. Statements are built from verbs, subjects, and prepositions. The rules are minimal by design.
EMIT
EMIT is the output verb. Whatever follows it is written directly to the response. It is the equivalent of echo in PHP or print in Python.
EMIT "Hello World"
STRING "Hello World" SET ?msg
AFTER EMIT ?msg
Statement Structure
Every OcaltQL statement follows this pattern:
[CHAIN] [SUBJECT] VERB [MODE] [ARGS] [PREPOSITION TARGET] [SET ?var]
- CHAIN —
AFTER,AND, orOR. Absent on the first statement. - SUBJECT — optional. A
?varthe verb acts upon. - VERB — the operation.
EMIT,CALCULATE,STRING,REPLACE, etc. - MODE — optional modifier on the verb.
ALL,ONCE,FROM...TO, etc. - ARGS — inputs to the verb. Literals or
?var. - PREPOSITION TARGET — verb-specific.
TO,INTO,WITH,WHERE,AS,FROM. The verb dictates which one applies. - SET ?var — optional. Captures the result. Only valid on value-returning verbs.
Case Sensitivity
OcaltQL is case-insensitive for everything except variable names. EMIT, emit, and Emit are identical. ?var and ?Var are not.
emit "Hello World"
after emit "This works too"
AFTER Emit "So does this"
String Delimiters
Double quotes, single quotes, and backticks are fully interchangeable as string delimiters.
EMIT "double quotes"
AFTER EMIT 'single quotes'
AFTER EMIT `backticks`
Line Rules
A fullstop at the end of a line is optional — it is not required and has no effect on execution. Multiple statements can sit on the same line. The chain keyword (AFTER, AND, OR) acts as the delimiter between statements on the same line.
EMIT "Hello World".
AFTER EMIT "Same result"
EMIT "Hello" AFTER EMIT "World" AFTER EMIT "!"
Comments
Comments are wrapped in (* ... *). They are ignored by the parser and can appear anywhere in the script — inline or on their own line.
(* This is a comment *)
EMIT "Hello World" (* inline comment *)
AFTER EMIT "Done"
OPEN and CLOSE
OPEN and CLOSE define the body of conditional and loop blocks. They can be nested to any depth.
STRING "hello" SET ?var
AFTER IF ?var IS SET
OPEN
EMIT "outer block"
IF ?var IS EQUAL TO "hello"
OPEN
EMIT " — inner block"
CLOSE
CLOSE
SET and Value-Returning Verbs
SET ?var is only valid when the verb produces a returnable value. Verbs that are pure side-effects — such as SAVE — do not accept SET. The runtime enforces this at the caller level per verb.
CALCULATE 10 + 5 SET ?result
AFTER EMIT ?result