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
definition.mdwn
This page is going to be a specification of the Kort language. I’m not following any specific strict rules here - just trying to define things in an accurate unambiguous way.
Grammar Notation
See [[/grammar-notation]].
Encoding
The latest Unicode version at the time of writing is 7, and that is the version assumed for Kort.
Kort files must be encoded in UTF-8.
Resources
See Idan’s [[projects/idan/definition]].
Context-Free Grammar (for parser)
Kort is a regular language, i.e. it can be precisely described using regular expressions. As a result, the lexical analyzer is enough to parse a Kort document, and a parser isn’t needed.
Lexical Structure (for lexer)
The lexical structure defines how characters can be combined into lexemes by matching regular expressions.
[[!format sgn """
document = (line? nl) * line = statement | comment nl = linefeed
statement = identifier sep relation (sep element)+ sep = tab + identifier = uid | gen relation = uid | gen element = uid | gen | value
uid = uidopen uidbody uidclose uidopen = “<” uidclose = “>” uidbody = uidfirst uidrest uidfirst = esc gensym | uidpart - gensym uidrest = uidpart* uidpart = uidchar | esc esc | esc uidclose uidchar = graphical - (wspace | esc | uidclose)
gen = uidopen genbody uidclose genbody = gensyn genlabel gensym = “%” genlabel = uidchar*
value = valopen literal valclose typeop type valopen = valopenchar valopenchar valopenchar = “{” valclose = valclosechar valclosechar valclosechar = “}” typeop = “::” type = uid
literal = boolean | number | character | string | chunk | general
boolean = “[_]” | “[x]”
number = hex | ratio | real hex = “0x” hexadecimal ratio = sign? decimal “/” decimal real = sign? realbase realexp? realbase = decimal | decimal “.” decimal realexp = “$” sign? decimal decimal = digit+ hexadecimal = hexit+ digit = [0-9] hexit = [0-9a-fA-F] sign = “-” | “+”
character = charchar | charescape charchar = graphical - charesc charescape = esc (charesc | numesc) charesc = valopenchar | valclosechar | esc numesc = “x” hexadecimal
string = ( strchar | strescape )* strchar = graphical - charesc strescape = esc (stresc | numesc) stresc = charesc | “&”
chunk = [A-Za-z0-9+/]* “=” #0-2
general = generalpart + generalpart = generalchar | esc graphical generalchar = graphical - (esc | valclosechar)
comment = dashes commentchar dashes = “–” “-” commentchar = graphical | tab
graphical = / any unicode character with basic type Graphical / wspace = / any unicode whitespace character, i.e. property WSpace=Y / tab = 9 linefeed = esc = ""
"""]]