Feb. 4th, 2008

rbandrews: (Default)

Saturday evening I started making a language.

I had a working lexer (better: a lexer generator) by the time I went to sleep, and I knocked together a parser on Sunday. I added some more advanced features to it tonight, and it's to a point where it can be played with, or at least described.

Funny thing is, I had no real plan going in, and even less of one now. I was just noodling around; I don't even have a use for a new language. Both projects that I am working on will be perfectly fine with JSON/Script.

Keemun

The language is used to walk a tree of objects. You don't really write programs in it so much as you write paths. I was thinking of it more as a messaging protocol than a language, so it's designed around the idea of short single statements.

There is currently no way to build an object tree in-language, you have to build it in Script and then use Keemun to query it. Queries can have side-effects, also determined by the structure of the tree in Script.

Basics

Trees are made up of nodes. Each node has a key and a value. Keys are always strings. Paths are made up of dot-separated key names:

players.1.name

Key names can also have funny characters or multiple words in them if you quote them:

journalists.'Robert McX'.network

Internally in the object tree, some nodes can be functions. If a path reaches a function, then that function gets called with the rest of the path as parameters:

board.move.g1.f3

is equivalent to (in Script)

board['move']('g1','f3');
Subexpressions, lists, and more! )

Profile

rbandrews: (Default)
rbandrews

July 2024

S M T W T F S
 123456
78910111213
14151617181920
212223242526 27
28293031   

Style Credit

Page generated Jun. 25th, 2025 01:34 pm
Powered by Dreamwidth Studios

Expand Cut Tags

No cut tags