wm.WILLIAM MARAISLet’s talk ↗
← All projects
LANGUAGE DESIGN / PYTHON

ExJSON.

ExJSON explores the path from a readable source language to an executable representation. A Python transpiler turns .xjs programs into JSON instructions, and a separate interpreter executes those instructions.

STATUSPersonal project
TOOLS & TECHNOLOGIESPython / Language design / JSON

Two stages, one program

The transpiler tracks nested blocks through a context stack and emits structured instructions. The execution layer dispatches those instructions, maintaining variable values and declared types.

Language features

The supplied implementation supports integer and string variables, input, output, addition, while loops, if statements and a rand() function returning zero or one. Output supports variable interpolation using ${name}.

The grid example

The program below reads two dimensions and assembles a text grid using nested loops and string concatenation. The literal \n sequences remain part of the source and are handled by the output implementation.

EXPLORE THE SOURCE

Explore the implementation

View repository ↗
git clone https://github.com/SAED2906/ExJSON.git

Code example

grid.xjsExJSON
int x = 0
int y = 0

in(x)
in(y)

String grid = ""

int counterx = 0
int countery = 0
int linewidthcounter = 0
while (countery < y) {
    linewidthcounter = 0
    while (linewidthcounter <= x) {
        grid = grid + "__"
        linewidthcounter = linewidthcounter + 1
    }
    grid = grid + "\n"
    while (counterx < x) {
        grid = grid + " |"
        counterx = counterx + 1
    }
    grid = grid + "\n"
    countery = countery + 1
    counterx = 0
}
linewidthcounter = 0
while (linewidthcounter <= x) {
    grid = grid + "__"
    linewidthcounter = linewidthcounter + 1
}

print(${grid})

NEXT PROJECTCellular Automata ↗