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
manual.mdwn
[[!toc]]
Intro
Kort is a simple, line-based language for expressing [[/projects/Smaoin]] statements. It can be viewed and slightly edited by humans, but major editing and writing are quite inconvenient. Kort is meant to be a tool for interchange of semantic data between machines and a simple format for testing, conversions, comparisons and other automated tasks.
Despite being mainly a tool for Smaoin, it’s possible to have statements of arbitrary length (at least 3 components). For Smaoin, only 4-component statements are valid, but perhaps other systems or future development can use statements of other lengths (e.g. to support ternary relations).
Lines
A Kort document is a sequences of lines, separated by ASCII linefeed characters. Each line is either a comment or a statement. Documents must be encoded in UTF-8.
A comment begins with two dashes (--
). It is meaningless semantically, i.e. statements aren’t generated from it. The parser can ignore comment lines. They are meant only for humans to read.
A statement line specifies the 4 components of a statement, separated by ASCII tab characters, 1 tab or more between each two consequtively specified components. The order of the components is: identifier, property, subject, object. The object can be a value or a resource. The other three components must be resources.
Statements can have any number of elements after the property, but there must be at least one. For Smaoin based data, this number of elements must be 2: the subject and the object.
Entities
A resource Uid is specified between angle brackets (<>
) as a sequence of non-whitespace Graphical Unicode characters. The text between the brackets is taken literally as the Uid, except for several escape sequences:
\
must be escaped as\\
>
must be escaped as\>
- A Uid starting with
%
must have the first%
escaped as\%
- A Uid starting with literal
%
is not a Uid but a placeholder which can later be replaced with an actual Uid. The part after the%
, if exists, is a placeholder name. All placeholders sharing a name get the same (but unique) Uid.
A value consists of a literal and a type. The format is:
{{
- A literal string
}}::
- A type Uid or placeholder (between
<
and>
)
Let’s see how values of the Smaoin fundamental data types are specified. Note that what determines the type is the type Uid, not the literal behind the braces. But e.g. specifying {{XYZ}}
and the Boolean type is an invalid value in Smaoin.
Boolean:
[x]
and [_]
for true and false respectively.
Character:
Unicode characters with basic type Graphical can be specified as-is, but there are escape sequences:
\
must be escaped as\\
{
must be escaped as\{
}
must be escaped as\}
- Unicode code points (character numbers) can be specified by prefixing the number in hexadecimal with
\x
. For example,{{\x6D1f9}}
.
Number:
A number can be represented in one of 3 forms:
- Hexadecimal non-negative integer, e.g.
0x0f47b5
,0x51D98A354EA
- Ratio of decimal integers, possibly with a preceding minus sign, e.g.
-2/3
,24343/97
- Real number consisting of a significand (decimal number with optional minus and decimal point) and an exponent (decimal number with optional minux), separated with
$
. The number meant by signiifcands
and exponente
iss * 10^e
. Examples:-852
,852.36
,-68$20
,46.2$-12
.
String:
Strings are written as sequences of Unicode characters. A character with basic type Graphical can be written as-is, but there are exceptions and escape sequences:
\
must be escaped as\\
{
must be escaped as\{
}
must be escaped as\}
- Unicode code points (character numbers) can be specified by prefixing the number in hexadecimal with
\x
. For example,{{Hello \x6D1f9 world!}}
. \&
is a special escape sequence which doesn’t produce any characters, but allows to break numeric escape sequences. For example,\xabc123
is a string containing a single character, while\xabc\&123
contains 4 characters.
Data:
Chunks are expressed as [[!wikipedia Base64]] strings without spaces and with optional padding using =
characters. The alphabet is A-Z, a-z, 0-9, + and / in this order.