Gruetzig's shithole

I have thought of a funny programming language to make today.
It’s a scripting language that will be run by a program I’ll make in C.

The concept

Very small amount of keywords, but still a lot of potential.
My current idea is 9/10 keywords:

include - includes other files functions
incl - starts/ends function declarations in files
func - starts a function definition
return - return to line after function call
if - if condition true then go to next line, else go to provided line
jump - jump to provided line
malloc - allocates memory for a pointer
free - frees allocated memory
unalloc - unallocs defined variables/strings


// comment
+ - * / unchanged
* pointer declaration
function:startline include function syntax
[] go to offsets of a pointer
& get pointer of variable


whats called by the executing program is _start in the main.sof file
there is one global function called “init” which gives the provided pointer allocated memory that has important data at offsets 0(/1), to be exact, the framebuffer(s).

The language doesn’t do any memory management/garbage collection automatically, every defined variable/pointer declaration has to be freed manually or will be freed at execution end

Example code would be:
//file: main.sof incl _start main:5 incl func _start() *ctx init(ctx) a = 3 if a == 3 12 a = 2 jump 9 unalloc a ctx return
Including other files in the same directory:
//file test.sof incl func inc2:5 incl func inc2(*a) *a = *a + 2 return //file: main.sof include test.sof incl _start main:6 incl func _start() a = 3 test.inc2(&a) unalloc a return
Drawing library example:
//file ctr.sof incl drawPixel ctr:11 getColor ctr:7 drawRect ctr:21 incl SCREEN_HEIGHT = 240 func getColor(r, g, b, *ret) *ret = r << 24 | b << 16 | g << 8 | r unalloc r g b return func drawPixel(x, y, screen, clr, *ctx) xpos = x * 3 * SCREEN_HEIGHT ypos = (SCREEN_HEIGHT - y - 1) * 3 pixelpos = ctx[screen] + xpos + ypos *(pixelpos + 0) = clr >> 16 // B *(pixelpos + 1) = clr >> 8 // G *(pixelpos + 2) = clr & 0xFF // R unalloc xpos ypos pixelpos x y screen clr return func drawRect(x, y, w, h, clr, screen, *ctx) i = x j = y if i<=x+w 28 drawPixel(i, j, clr, ctx[screen], ctx) i = i + 1 jump 24 i = x j = j + 1 if j<=y+h 32 jump 24 unalloc i j x y w h clr screen return //file: main.sof include ctr.sof incl _start main:6 incl func _start() *ctx init(ctx) color = 0 ctr.getColor(255, 255, 255, &color) ctr.drawRect(10, 10, 10, 10, color, 0, ctx) unalloc color ctx return
Every file can have an incl section and a script section. Files can also have only incl sections or only script sections. When you use include <file>, the interpreter will include all incls from the function under file., which is what object oriented programming needs if I recall correctly.

There will be no scopes, which will make global variables very easy without includes. Heres an example of how I think it will work:

//file screen.sof incl init screen:6 exit screen:9 incl func init() screen_height = 240 return func exit() unalloc screen_height return //file main.sof include screen.sof include debug.sof incl _start main:7 incl func _start() debug.print(screen_height) //undefined screen.init() debug.print(screen_height) //240 screen.exit() debug.print(screen_height) //undefined return
Note: the file debug.sof is not a real file and will likely not be in the standard library, but is used to show how things should be implemented

Yes, there are no return values, thats why pointers exist.