Skip to content

Syntax Basics

Regentq edited this page Nov 14, 2026 · 3 revisions

YTL uses indentation (like Python or YAML) to define structure. There are no curly braces for blocks, only for inheritance and arrays.

1. Blocks and Indentation

A block is defined by a name followed by a colon :. Everything indented below it belongs to that block.

Server:
    host "localhost"
    port 8080

2. Comments

YTL supports three types of comments.

// Single line comment
# Hash comment (useful for configs)
/* 
   Multi-line block comment
*/

3. Inheritance (Multiple)

Use curly braces {} to inherit from one or more blocks.

Character:
    health 100

Warrior{Character}:
    damage 10

You can inherit from multiple parents: MyApp{Network, Database}:

4. Realms (Environment Overlays)

Instead of duplicating code for different difficulties or environments, use Realm.

Warrior:
    health 100
    
    Realm "Hardcore":
        health 50      // Overrides only in Hardcore mode

5. Attach (ECS Composition)

Bring Entity-Component-System architecture to your configs. Inject traits directly into entities.

Goblin:
    health 50
    Attach ytl://components/poison.ytl

6. Const (Immutability)

Protect critical fields from being overwritten in child blocks.

Server:
    Const port 8080
    
    Realm "prod":
        // port 443  <-- This will throw an LSP error!

7. References & Interpolation

Use * to reference other values or interpolate strings.

Network:
    ip 192.168.1.1
    port 8080

Server:
    gateway *ip
    // Note Interpolation requires quotes, because '*' is not part of a valid URL
    url "http://*ip:*port" 

8. Native Types

YTL understands complex data types out of the box.

Ranges & Percentages (GameDev)

Weapon:
    damage 13~30    // Random range
    crit_chance 25% // Percentage

Vectors & Colors

Spawn:
    position (10, 5, 2)
    color (255, 0, 0, 255)

Networks

Server:
    ip 192.168.1.1
    mac 00:1A:2B:3C:4D:5E
    subnet 192.168.1.0/24

UUID & Versions

Service:
    id 550e8400-e29b-41d4-a716-446655440000
    version 1.2.3

Environment Variables (ENV)

Load values from the system environment. You can also provide a default value using :-.

Database:
    host $DB_HOST
    port $DB_PORT:-5432 // Uses 5432 if $DB_PORT is not set

Paths

System:
    linux_path /usr/local/bin
    windows_path C:\Windows\System32

9. Include

Globally import root blocks from another file.

Include ytl://base_network.ytl

Clone this wiki locally