mpc
mpc copied to clipboard
userdata in AST
mpc doesn't have userdata in AST. so we should parse strings in each times while walking AST.
For example: https://github.com/mattn/orelang/blob/master/ore.c#L1236 since parsing in each times, it's very slow.
And I'm thinking, since mpc provide tag as string, we should look what this node is string or number, etc in walking tree every times.
Hey,
I agree it would be nice to let the user use non-string tags of some sort - at least for performance reasons as you mention.
Even better would be a way to let the user give their own AST type to be used with the language parser and a bunch of callback functions to be called for the various operations such as adding children, tagging or deletion.
Then we can just let mpc_ast_t
be the default AST type for people who don't need that functionality and for people who want to make a custom AST type that is faster they can.
I'll have a think about it some more.
- Dan
Hi, sorry about delay. Any thought?
Hi mattn,
Thanks for the reminder. I'll try to make this update soon. I was put off because the code for parsing the ast is kind of a mess because it does lots of auto-merging of nodes depending on various conditions so I'll have to try and separate that out.
- Dan