Page 2 of 2

Re: Destroying / clearing a "recursive" vector ?

Posted: March 16th, 2020, 4:51 am
by Slidy
Project sounds awesome :o Keep us updated on how it goes
I was working on a similar thing, a simple statically typed scripting language that I would use in another project of mine (shameless plug: https://github.com/SlidyBat/BatScript)
I haven't worked on it for a while but I'm planning on getting back into it at some point. You might find some stuff useful, the way the AST is made is quite elegant using X-macros ("stole" the implementation idea from other C++ compilers). It also has 2 execution methods, a tree-walking interpreter (which is slow as balls) and a stack-based VM.

Good luck!

Re: Destroying / clearing a "recursive" vector ?

Posted: March 17th, 2020, 9:12 pm
by binbinhfr
Well at last I understand now what is this AST stuff you were talking about :-)
It's finally what I'm doing without knowing it.
had a look at your code. It's true C++ and I'm a little lost in it (I was a C-programmer in my young days, and afterwards I went into classical science).
Did not find the X-macros stuff you were talking about, can you tell me were I must look ?

Re: Destroying / clearing a "recursive" vector ?

Posted: March 19th, 2020, 6:29 am
by Slidy
All the AST definitions are in ast.h.

The X-Macro declaration is here specifically.

You can find an example usage of the X-Macro here for declaring an enum with all the different AST node types.

I feel like it's a nice fit for an AST, pretty much every C++ compiler I've seen uses them as well. Don't worry too much about it if it doesn't work with your project, no point in forcing it.