Hacker News new | past | comments | ask | show | jobs | submit login

Read the post and realised it might be a great idea. Perhaps each node in the AST is an entity and you can add/remove components to a node during compilation ? Need to really try it out to be sure this works.



Yes, this is the basic idea. Tokens from the lexer, AST nodes, basic blocks, control and data-flow graph nodes + edges can all be entities and/or components of entities, depending on how you wish to structure your data. Since a 32-bit entity ID provides a sufficiently large "address space", you get the added benefit of only needing to store 4-byte handles instead of 8-byte pointers.

EnTT has an eventing system as well. These can be triggered in various ways (entity created, entity deleted, component assigned/removed, etc). I've used eventing to control fine-grained compilation pipelines. For example a recent scheme compiler I wrote used events to simplify inlining (both define-macro/define-syntax and straight procedure inlining) and quote/quasi-quote/unquote/unquote-splicing translation.

If you spend a lot of time writing compilers, I find an ECS like EnTT can give you extra flexibility during the design/prototype phase. Try it out on a simple prototype and see if you like it.


Wow. Is this a public project or something you can mention? It sounds very interesting!


My recent work involving EnTT is still under NDA, though at least one of the projects should have a public announcement sometime next year.

With that said, if there is interest, I'd enjoy building a clean room compiler for an existing language using EnTT and other techniques I've developed over the years. Thoughts? While I absolutely adore TinyCC, it might be worthwhile giving that space another go?


Well, I don't think I've enough skills on this and I'd follow the project eagerly to learn something new, so I'd go with what you feel confident and/or you like! My thoughts are that such a project would be of interest for tons of people though, I'd willingly share it as much as possible. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: