-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
I realized I can have an ergonomic feature for at least code bodies similar to construction pattern used in Imguis (such as the one done in SectrPrototype)
so it would be essentially
Code body = def_body(CT_Global_Body);
push(body);
CodeTypedef td = parse_typedef(...);
... Any built code asts automatically parent to the body
pop(body);A auto-defer could be made so its just:
PopDefer parent_scope = scope(body);
// Where it just pops using a destructor. Or a for-loop push-pop for C11
for (b32 pushed = push(body); pushed; --pushed, pop(body))
{
...
}
#define scope(body) for (b32 pushed = push(body); pushed; --pushed, pop(body))Requires that the Context struct tracks a some sort of stack of bodies that would automatically have ASTs appended to them from the AST builder interfaces (upfront, parsing, untyped, etc). Usage would be as simple as:
Code<Something> def_<something>(...)
{
...
if (_ctx.body_stack.front) {
body_append( _ctx.body_stack.front, result );
}
return result;
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
No status