mpc icon indicating copy to clipboard operation
mpc copied to clipboard

userdata in AST

Open mattn opened this issue 9 years ago • 4 comments

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.

mattn avatar Jun 01 '15 05:06 mattn

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.

mattn avatar Jun 01 '15 06:06 mattn

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

orangeduck avatar Jun 01 '15 13:06 orangeduck

Hi, sorry about delay. Any thought?

mattn avatar Nov 03 '15 12:11 mattn

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

orangeduck avatar Nov 03 '15 13:11 orangeduck