Hi! After a few months with xtext I eventually run into one of the hardest to overcome limitations of it, namely dealing with macros. I’m working on language servers for already existing program languages that use the same type of preprocessing as the C language does, so the macro aspect seems unfortunately a must but it seems that xtext needs a major tweaking to deal with it. l have yet not succeeded properly without glitches and therefore started to peek at MPS as I’ve understand might be able to handle this, but I have yet to find out how. It would therefore be beneficial for me to know if anyone of you have any recommendations for me and can confirm if this is possible in either mentioned frameworks or maybe some other so I know if it’s worth investing time in. And most hopefully if there are any good examples of this out there you could provide me with.
More specific it’s c-styled function/value macros that I need to get working. I don’t need them to cover references to the macros themselves but I do believe I need the macro id:s to be replaced in the AST with whatever is defined as their values. Not sure if what is the best approach here or what alteratives one has.
Thank you. Its good to have an algorithm once I know where to best place it. I’m now thinking a preprocessing perhaps might be best to put into the Lexer stage, and therefore a separate Lexer implementation than the default xtext generates (if I choose that framework).
MPS is based on the projectional editor concept, you don’t edit text but AST’s. So you don’t have macros in the C sense, you have macros in the Lisp sense (AST-to-AST transformations).
You may model existing languages with MPS (they do it already with Java) but you have to keep in mind that MPS is not based on text, so if your input is text files, integration with MPS won’t be trivial. It’s not just a matter of parsing, MPS uses a different paradigm altogether (e.g. it’s not file-based but node-based and nodes are automatically persistent).
I’m aware of at least one robust implementation of a preprocessed language with Xtext (though closed source). So it’s certainly possible but you’ll need to go knee-deep into the internals of the framework. Not sure if that helps as a quick feedback.
Thank you! It definitely does. it’s also motivation boost! Too bad the source can’t be observed though. Might I ask which software it is? I’m curious to see how well it is implemented so I know where to set the bar for myself