Skip to content

3. File structure

EBNF
file = { include | action | selector | plan | query | sifting_pattern | trope } EOF .

A Viv source file (.viv) is a sequence of zero or more include statements and construct definitions, a catch-all term for action definitions, selector definitions, plan definitions, query definitions, sifting-pattern definitions, and trope definitions.

In Viv, empty files, including files containing only whitespace or comments, are valid code:

// Empty files are valid

The various constructs may appear in any order, and interleaving is allowed. As such, a structure like this is syntactically valid:

include ...
action ...
trope ...
query ...
action ...
include ...
plan ...

Despite being written in a certain order, the constructs in a source file are conceptually orderless. An action may inherit from another action that is defined below it within the same file. Likewise, it may target such an action in a reaction. The file-importing process, implemented via includes, also treats these concerns as orderless.