DreamBerd icon indicating copy to clipboard operation
DreamBerd copied to clipboard

[DRAFT] Make an interpreter for this abomination

Open Bytestorm5 opened this issue 1 year ago • 57 comments

putting this here so there's a thread for it, it's not nearly done but if anyone wants to mess with it there's something

the current plan is to write the compiler in python and from there rewrite it in C or Rust, whichever is funnier at the moment or maybe I'll leave it as python that might be cursed enough, idk

For the time travel the way I'm thinking things should work is that execution follows a "cursor", regardless of what timeline that cursor is in. This allows for somewhat deterministic time travel which is pretty cool

Cool git stuff: Resolves #14

Bytestorm5 avatar Jun 05 '23 01:06 Bytestorm5

The idea with the whole Compinterpreter is to do things in the most convoluted way possible- I want to have it interpret some parts of the code and transpile other parts to another language (maybe multiple based on situation?). I'm kinda indecisive as to what language it should transpile to, I think Javascript is cursed enough to fit the bill but I'm not sure yet

Bytestorm5 avatar Jun 05 '23 01:06 Bytestorm5

Best of luck to you! Please be careful out there

TodePond avatar Jun 05 '23 06:06 TodePond

thanks, so far it hasn't been too crazy, though now that I'm getting to parsing it's gonna be interesting. Is it okay if I make a video on the whole process? I figure it'd be pretty funny and may have some value in showing how to make tokenizers/parsers/etc. I know you have your own channel so I wanna make sure I'm not encroaching on anything you might have in the works

Bytestorm5 avatar Jun 05 '23 06:06 Bytestorm5

I'm curious to see how you're going to deal with that: AI

MaxenceDC avatar Jun 05 '23 07:06 MaxenceDC

@Bytestorm5 Of course! You should go for it, I'd love to see it :)

TodePond avatar Jun 05 '23 08:06 TodePond

I'm glad my time travel implementation is actually going to (sorta) become real

For the time travel the way I'm thinking things should work is that execution follows a "cursor", regardless of what timeline that cursor is in. This allows for somewhat deterministic time travel which is pretty cool

labbo-lab avatar Jun 05 '23 15:06 labbo-lab

Just had a horrible idea inspired by #76 - we store const const const variables in a cloud database, making DreamBerd the first Always-Online Singleplayer language

Bytestorm5 avatar Jun 05 '23 16:06 Bytestorm5

we do a small quantity of trolling

const const const delete Date()!

labbo-lab avatar Jun 05 '23 17:06 labbo-lab

💀

Come to think of it tho someone could probably turn that into an attack vector, maybe injecting code from the cloud into people's computer isn't a good idea lol

Bytestorm5 avatar Jun 05 '23 17:06 Bytestorm5

const const const declarations should be reviewed by a team of mods (similarly to the AI feature) I think.

MaxenceDC avatar Jun 05 '23 17:06 MaxenceDC

Come to think of it tho someone could probably turn that into an attack vector, maybe injecting code from the cloud into people's computer isn't a good idea lol

Yes in all seriousness, I'd like to implement it in a sandbox'd web version. For a local version, people could connect to their own const const const stores.

TodePond avatar Jun 05 '23 17:06 TodePond

Yeah moderation should work- maybe limit it to primitive types as well to prevent any chicanery in terms of infiltrating whatever platform is used to moderate them

Bytestorm5 avatar Jun 05 '23 17:06 Bytestorm5

Alright so I did some thinking on what needs to happen at a high level because I've kinda hit the limit of "don't think just code," so here's how I think things should work: (This is mostly here for myself bc things are easier for me when I write out my thoughts like this)

File comes in, gets split into however many files are actually in it. Each of those are processed completely independently.

After Tokenizing, the task is to take DreamBerd and turn it into JSX. However JSX is unenlightened and allows for a lot of barbaric practices such as loops- so we have to first make sure the user's code is free of such barbarism with our own syntax check before JavaScript's. This should check things like mutating a const, referencing a variable after its life has ended (if its lifespan is deterministic), etc. Certain things like ==== can also be handled by the compiler to prevent JavaScript from being JavaScript.

After the syntax is confirmed to be correct with no compilation errors, it is converted to JSX. However there are cases where DreamBerd runtime errors can occur. As such the logical solution is to have many hard-coded templates of error catchers that raise exceptions in case any such issues arise.

Similarly we need to inject some structs to every built file to correctly represent DB Strings, Ints, etc.

Bytestorm5 avatar Jun 05 '23 19:06 Bytestorm5

Sounds good! Great job so far :D

TodePond avatar Jun 05 '23 20:06 TodePond

https://stackoverflow.com/questions/1759987/listening-for-variable-changes-in-javascript https://lage.us/Javascript-Watch-Variables-for-Change.html

Saving this here for later when figuring out the when control flow

Bytestorm5 avatar Jun 05 '23 21:06 Bytestorm5

https://chat.openai.com/share/53a01ea6-d655-4b6a-918e-6e13c4e78769

I have decided we are going to have localization for compiler errors, but only for the different dialects of english to achieve true i18n

Bytestorm5 avatar Jun 06 '23 03:06 Bytestorm5

Hi, I was thinking about doing a similar thing. Have you already thought about a way to handle the past feature, var const(and similar) and this type of stuff? Because in my opinion it would probably be possible to handle them using dictionaries in this way: const var gets transpiled into a function that adds both the entry and the allowed modifications to the dictionary. When it gets updated (in the same way of the when instruction) there is a check against this dictionary to check if the operation is valid. While doing this it saves the old value too. In the same way it would be possible to handle lifetimes too.

If you think this is a good idea I would love to implement it and help you in general with this project

Odinmylord avatar Jun 06 '23 11:06 Odinmylord

Yeah I had a similar idea in mind- I don't think we're quite at the point of setting up JS since the parser still needs work, but I can add you to the repo so you can contribute.

Bytestorm5 avatar Jun 06 '23 12:06 Bytestorm5

Do you have a specific version you're following or are you going to add features when they're released?

labbo-lab avatar Jun 06 '23 14:06 labbo-lab

For now I'm adding features as they come, once the compiler fully encompasses one version of DreamBerd then we can set it up with proper versioning

Bytestorm5 avatar Jun 06 '23 15:06 Bytestorm5

Ok so hear me out What if instead of having the parser build the js file, we instead have it only check the syntax, and if the syntax is correct it calls some other program entirely to actually convert it into javascript using regex

Bytestorm5 avatar Jun 06 '23 17:06 Bytestorm5

What if instead of having the parser build the js file, we instead have it only check the syntax, and if the syntax is correct it calls some other program entirely to actually convert it into javascript using regex

Update: This is so cursed I love it image

Bytestorm5 avatar Jun 06 '23 18:06 Bytestorm5

What if instead of having the parser build the js file, we instead have it only check the syntax, and if the syntax is correct it calls some other program entirely to actually convert it into javascript using regex

Update: This is so cursed I love it image

lol I can't believe what I just read...

PThorpe92 avatar Jun 06 '23 20:06 PThorpe92

Hey @Odinmylord and/or @Bytestorm5 I really want to demo this at this week's Future of Coding meetup here in London. Either of you up for a video call/chat today? Would love to speak with you about this :)

TodePond avatar Jun 07 '23 10:06 TodePond

Cool, I'll be free in the evening

Odinmylord avatar Jun 07 '23 11:06 Odinmylord

Awesome, pop me a DM anywhere to arrange!

Discord: TodePond#9999 twitter: TodePond mastodon: [email protected]

TodePond avatar Jun 07 '23 11:06 TodePond

@TodePond It would have to be rather late today (my time) but I'm down, I'll send you a DM on Discord

Any time tmrw / in the next week, just lmk and I should be able to make time

Bytestorm5 avatar Jun 07 '23 12:06 Bytestorm5

Since I can't directly DM you on discord I sent you the friend request. I'm Odin#8743

Odinmylord avatar Jun 07 '23 13:06 Odinmylord

@Bytestorm5 since we are both working on the project but we haven't discussed some details together yet it would be amazing if you could add me on discord at Odin#8743 or contact me on telegram, username: @Odinmylord. So that we can discuss details when needed

Odinmylord avatar Jun 07 '23 19:06 Odinmylord

@Bytestorm5 since we are both working on the project but we haven't discussed some details together yet it would be amazing if you could add me on discord at Odin#8743 or contact me on telegram, username: @Odinmylord. So that we can discuss details when needed

Ye I'll add you, sent a req

Bytestorm5 avatar Jun 07 '23 19:06 Bytestorm5