Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>
Clone
HTTPS:
git clone https://vervis.peers.community/repos/yEzqv
SSH:
git clone USERNAME@vervis.peers.community:yEzqv
Branches
Tags
01-concept.mdwn
[[!meta title=“4.2.1 | Concept”]]
Concept
Positional references are relative: They are based on offsets, not on absolute positions in the document.
Offsets are either statement-based or block-based. Statement-based offsets ignore the block structure and can refer between statement in the same block. Block-based offsets treat blocks as atomic units and can refer only between blocks, not inside them.
A reference either points down to the next statements in the document, or up to the previous statements. Each one of these two directions has a character representing it consistently in Idan. Up is represented by a caret (^
) and down is represented by a comma (,
). The representing character of a direction is called a “pointer”. Thus, Idan has two pointers: ^
and ,
.
A general scheme for references is as follows. A reference begins with a special character indicating its type. Immediately follows a offset specification. There are two types of specifications: textual and numeric.
A textual specification is a sequence of one or more repetitions of a pointer, where the number of occurences indicates the offset. For example, a single occurence or ,
points to the next statement/block, and two occurences of ^
, i.e. ^^
, point to the second previous statement/block (i.e. one before the previous).
A numeric specification begins with a single pointer, followed by a positive integer indicating the offset. The offset integer is written as a sequence of ASCII decimal digits 0-9. For example, the numeric equivalents to the examples in the previous paragraph are ,1
and ^2
.
It’s possible for a reference to refer to a location that itself is a reference. In that case they refer to the same entity, the one determined by resolving the latter reference. For example, if R1 points to R2 which points to some literal L, then after reference resolution all three components expressed by R1, R2 and L will be the same entity expressed by L. In other words, it’s the same as writing L three times in the document at these locations. Circular references may be technically possible in the syntax, but documents containing them and invalid, and they should be detected and reported by the referece resolver.
The reference’s type, indicated by the first character, indicates to which statement component exactly it refers, and whether it’s statement based or block based. The next sections describe the types of positional references.