-
Notifications
You must be signed in to change notification settings - Fork 0
Language Specification
Krait edited this page May 28, 2026
·
1 revision
This page outlines the formal grammar rules, type system behavior, and syntax structure of the Krait Object Serialization Language (KOSL).
document = { pair | empty_line | comment } ;
pair = identifier , "=" , value ;
value = implicit_array
| object
| explicit_array
| scalar ;
implicit_array = scalar_or_struct , { "," , scalar_or_struct }+ ;
explicit_array = "[" , [ value , { "," , value } , [","] ] , "]" ;
object = "(" , [ pair , { "," , pair } , [","] ] , ")" ;
scalar_or_struct= object | explicit_array | scalar ;
scalar = string | bareword | number | boolean | "null" ;
identifier = bareword ;
bareword = ( ALPHA | DIGIT | "_" | "-" | "." )+ ;
string = '"' , { ANY_CHAR - '"' } , '"' ;
comment = ( "#" | "//" ) , { ANY_CHAR - NEWLINE } ;KOSL recognizes the following raw types:
| Type | Syntax Example | Notes |
|---|---|---|
| String |
"hello world" or hello_world
|
Quotes are required if spaces or special operators are present. |
| Integer |
2026 or -42
|
Explicit 64-bit integer values. |
| Float | 3.14 |
Must contain exactly one dot operator. |
| Boolean |
true or false
|
Case-sensitive lowercase barewords. |
| Null | null |
Evaluates to an empty/null value. |
| Array | [1, 2, 3] |
Sequence wrapped in brackets. |
| Object | (key=val, foo=bar) |
Key-value mapping wrapped in parentheses. |
Commas residing on the top parsing level (or within an object/array context) split unmapped values into implicit arrays.
# This parses to: Array [ String("windows10"), String("ubuntu16"), String("macOS10") ]
supported=windows10,ubuntu16.5,macOS10
However, commas inside double-quoted strings do not create arrays:
# Parses strictly to: String("hello, world")
message="hello, world"
Barewords are strings that do not contain quotes. To ensure common configuration standards do not crash parsers, semantic versions containing multiple decimal points fall back gracefully to Strings:
-
0.1.0-> Parsed as a String (cannot be validated as a float due to multiple decimals). -
12-> Parsed as an Integer. -
12.5-> Parsed as a Float.