Destroying / clearing a "recursive" vector ?

The Partridge Family were neither partridges nor a family. Discuss.
Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: Destroying / clearing a "recursive" vector ?

Post by Slidy » March 16th, 2020, 4:51 am

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!

binbinhfr
Posts: 78
Joined: May 9th, 2019, 10:57 pm

Re: Destroying / clearing a "recursive" vector ?

Post by binbinhfr » March 17th, 2020, 9:12 pm

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 ?

Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: Destroying / clearing a "recursive" vector ?

Post by Slidy » March 19th, 2020, 6:29 am

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.

Post Reply