📚 node [[20210503135803 kroz_language_design]]

Kroz is a programming language project I'm using to better familiarize myself with Racketand implementing languages in Racket.

Kroz is a language that's used for designing text-based adventure games. The output of a Kroz program is a full-blown adventure game.

Design

The language consists of a series of prompts and expected responses. A Kroz game is a tree of decisions.

; this is a comment
game_start:
    prompt "You find yourself in a dungeon cell with only a rope. What do you do?"
    actions:
        "climb rope" -> climb_rope_action
        "yell" -> end_game "A guard comes and kills you."

climb_rope_action:
    prompt:

Actions

Actions are essentially key-value mappings from accepted inputs to other scenes, delimited by new lines. Their basic syntax is:

ACTION = WORD_LIST -> SCENE_NAME \n
WORD_LIST = WORD+
WORD = ".*"

For example:

actions:
"follow road", "grab rope" -> next_scene_name
"cut rope"                 -> different_scene

Whitespace is ignored on a line-by-line basis.

Special actions

There are two special reserved actions, begin_game and end_game.

begin_game

begin_game tells the program which scene kicks the game off. Conventionally it should be placed at the end of a Kroz file.

begin_game first_scene

end_game

end_game ends the game. It takes no argument and can be used in an action list.

actions:
"foo" -> end_game
📖 stoas
⥱ context