April 10, 2026, 10:44 p.m. by Gabe R
As mentioned in a previous post, I had the idea of creating a memory store for LLMs based on a directed graph (semantic network). As for the name, it's simple: the client was supposed to provide context for chat conversations so I called it ContextBot. Then I realised I needed a language the LLM and the client could use to communicate graph operations, so it seemed only natural at this point to call it ContextScript.
The idea was to create a language that would be simple to understand, simple to parse and simple to write in. It was clear from the idea of a directed graph that it would need two data types, i.e. Node and Edge, and three operations, create, update, and delete. I've also decided to use the semicolon as a statement end.
What follows is an introduction to the language. While the language itself is extremely simple, the text that follows is relatively long, so prepare your favorite brew and maybe some biscuits before marching on. Also please keep in mind that the current implementation is a work in progress and not all constraints are enforced.
As mentioned above, there are two data types in the language, Node and Edge. Declaration and instantiation of a variable are done by writing the variable in the source code as in the examples below.
A string within the ContextScript language is composed of any combination of letters, digits, the minus ( - ) the underscore ( _ ), the comma ( , ), the period ( . ) or the single quote ( ' ) symbols. All strings must be enclosed in double quotes.
The float is only used to define weights for the Edge type.
A Node is intended to store concepts on which a user (machine or human) can reason. Each of the Node argument values is a string enclosed in double quotes. A Node has the following properties:
Node(
node_id = "value",
name = "value",
data = "value");An Edge stores a relationship between two Nodes. All Edge argument values are Strings, except for the weight which is a Float. An Edge has the following properties:
Edge(
edge_id = "value",
from_node = "value",
to_node = "value",
verb = "value",
weight = value);A variable can be updated by re-declaring a previously declared variable while keeping the same id:
# This is the original variable.
Node(
node_id = "node_1_id",
name = "Name",
data = "Whatever data");
# Update
Node(
node_id = "node_1_id",
name = "Name",
data = "Whatever data has been changed");The same can be done for variables of the Edge type.
Deletion happens by referencing an element's (Node or Edge) id:
del(id="node_1_id");At the end of the program, the following must be true:
letter = "A" … "Z" | "a" … "z" ;
digit = "0" … "9" ;
float = ["-"] digit {digit} "." digit {digit};
symbol = "-" | "_" ;
punctuation = "," | "." | "'";
str_delim = """;
name = letter, {letter | digit | symbol};
argument_name = letter, {letter | digit | symbol};
id = (letter | digit), {letter | digit | symbol};
verb = letter, {letter | digit | symbol};
str = str_delim, { letter | digit | symbol | punctuation }, str_delim;
assignment = argument_name, "=", (name | id | verb | str | float);
node_decl = "Node", "(", assignment, { ",", assignment }, ")", ";";
edge_decl = "Edge", "(", assignment, { ",", assignment }, ")", ";";
deletion = "del", "(", "id", "=", id, ")", ";"
statement = node_decl | edge_decl | deletion;
program = { statement };If you got to this point, thank you for reading.
And if you're interested in what comes next: