eryjus / ast-cc

An Abstract Syntax Tree compiler
1 stars 0 forks source link

Automatically generate a function to dump the contents of a node #19

Open eryjus opened 7 years ago

eryjus commented 7 years ago

Since we are taking definitions and generating code, ast-cc should take the opportunity to generate the code to dump the contents of a node. This function would have a definition similar to the following: meth Common::HiDebug(msg : stdString, file : pChar, line : int) : void { /* emitted code here */ } ... where stdString is a typedef of std::string and pChar is a typedef of char *. This function would have to call the parent's version of the code in all cases to get the parent's attributes.

The following definition should also be included: meth Tree::HiDebug(msg : stdString) : void { HiDebug(msg, (char *)NULL, 0); } ... when file and line are not known or not needed.

I believe that this would be a great addition since the flow of the parent's calls are directly related to the declaration section and the parent relationship defined there.