Language Overview
Scripts, blocks, comments, and how USE scopes them.
Scripts and blocks
A script is a sequence of blocks. Each block has a source — the
document it operates on, set by USE — and a list of verbs
(SELECT, FOREACH, SET, DELETE, REPLACE, INSERT, MERGE, or one
of the MySQL-style shorthands).
; USE is sticky: it applies to every following block until the next USE.
USE database.local.xml
FOREACH arm IN arms
DELETE IGNORE arm.unlock_civi_science
;
; still database.local.xml — USE wasn't repeated
SELECT GROUP arms;USE <path> selects a file on disk. USE "path" works the same, for paths
that need quoting. USE INPUT selects the XML document piped in on stdin
(see CLI: filter mode).
Statement termination and comments
; terminates a statement block, and everything after ; on that line is
ignored — so a line starting with ; doubles as a comment:
; this whole line is a comment
SELECT GROUP goods; this trailing text is also ignoredGroups vs. tags
Most verbs act on either a group or a tag — this distinction shows up everywhere, so it's worth internalizing early:
- A group is the first element whose tag, or
name/idattribute, equals the given name.GROUP goodsmatches one container element and the verb operates on (usually iterates) its direct children. - A tag (
TAG t) matches every element whose tag equalst, at any depth, regardless of attributes. Use it for documents that have no reliable group/container structure.
See Group vs. Tag for the full comparison,
including how nested FOREACH ... IN TAG differs from a top-level one.
Next
- SELECT and OUTPUT — querying, printing results.
- Mutations —
SET,MERGE,DELETE,REPLACE,INSERT. - MySQL-style shorthands —
UPDATE,DELETE FROM,MERGE ... SET. - FOREACH and WHERE — loops, guards,
nesting,
BREAK. - Expressions — operators and typing rules.
- Settings —
FORMAT,IGNORE_COMMENTS,ANALYZE. - Full reference table — every construct, one line each.