dude (python-based programming language)

I worked on making this yesterday because I was bored during school. Curious what people think of it

https://git.sr.ht/~monarrk/dude

It matches every line against a regex pattern and then interprets based on that. It’s super flexible because of that but it’s also more like a toy than a real language (at the moment)

(please bonk me if this is not what threads are for; I’ve never made a thread before)

3 Likes

Is there any way to define a proc/function/whatever?

1 Like

not at the moment, I’m trying to work on it but I don’t know how that’d look

1 Like

It might be difficult to do with the current architecture, but consider the format from Inform 7:

Understand "turn down volume" or "turn down music" or "turn down the volume" or "turn down the music" as lowering the volume.

So, here:

understand foo [bar] as:
    add 1 to bar.
    show bar.

foo 10.
# outputs 11
1 Like

oh yeah that’s really clean! I’m planning on parsing better so that each “line” is any statement ending with a period, but I can never figure out “real” parsing for some reason so it might take me a bit. I’m thinking maybe I’d steal some prolog syntax and do

understand foo with a,b,c as
    add a to b,
    multiply b by c,
    show b.

call foo with 1, 4, 7.

or something like that

2 Likes

Love it!! This’ll probably also mean you need some scoping rules as well - but I do love the prolog inspiration!

1 Like