I was recently thinking about the <[apple] contains [a]?> block for whatever reason (I've forgotten since then) and I was inspired by a post by pajamaclaws21 that I found while looking through images of it to create a parser for Snap! blocks.
It's not in any way close to being finished yet, but I've made some progress while trying to do as bh said, and...
I've created a working script for a sort of lookup table in a way similar to how he said to do it (except for almost EVERY primitive in the palette), and since I couldn't exactly figure out how to...
How bh said to do it
...I've decided that I'm going to make a sort of custom programming language for this parser, and it's going to have syntax similar to... probably quite a few programming languages. I'm not taking inspiration from any of them (except for TypeScript... kind of) so I wouldn't know.
I'm only a bit stuck very stumped right now, as what I'm trying to do involves getting block and input types based on brackets and I have no knowledge on how to implement that. Another factor being my lack of knowledge on how I'll parse C-shape blocks (IF, FOREVER, FOR, etc.) as well, but that might be an easier challenge.
Please, if you have feedback, I'm happy to hear it, especially if it involves what I just previously mentioned, I'd be really grateful!
split ({forever{
}}@>) by [[blocks] v]
keep in mind bh's post only existed because at the time the above feature didn't exist, and he wanted someone to implement it. he also posted something like that on the old xml scribt builder project. also, maybe check out ego-lay_atman-bay's snapblocks converter, he had to use kinda similar things I think.
If you mean...
...I don't want to use these because I want this to be an original project, and I also don't exactly understand Snap!'s Lisp syntax.
I just don't really want to use this or any other libraries, I want to make a Snap! parser in my own, unique way.
Thanks for the subtle suggestion though.
The thing too, with that lisp parser, is it's behind the scenes in snap! which is to say, as an experiment, open an instance of snap and open the library and look at the composition of blocks, and then open snap without the library and build those blocks yourself.
You'll see that it just works, because the lisp definitions are baked into snap at the source level, so if Snap! sees that text, it'll go "Oh this is lisp! This means that!"
As for maybe a first step, BH has, in volume two of his Computer Science Logo style textbook, has a BASIC Compiler, which turns logo into BASIC, and Volume 3 of that textbook has you design your own language! ... Kinda. You're actually turning Logo into Simplified Pascal, which is a very different style, but again, learning steps!
All three of his books are on his website!
I tried a couple times to port it over, but there's a couple things that logo does that snap doesn't, so I always get lost in the weeds... but for people with functioning brains (Anyone who isn't me) it might be a better place to start!