Error propagation(lifting) and static analysis Follow
I have recently finished the tutorial part of fast track but have couple of things unclear.
Firstly, as far as I get the intuition, MPS dsls are always built on already existing languages (which are implemented in MPS via textgen) so the compiler of the underlying language may provide messages or errors (or even analyze the code with solvers) and these messages are propagated to the user if the program doesn't compile or has any issues, but these messages are propagated according to text generated files (e.g. error in line 8 is with respect to textgened file line 8 not projectional one). And the question is whether there is a way to propagate such messages with respect to MPS code, i.e. to tell the user that the compilation error raised from some line in textgened file was actually caused by his projectional code at line e.g. 2. Or MPS has enough constraint mechanics to eliminate the need in such messages?
Secondly, modern IDE's have a lot of tools for static analysis and I know MPS provide a way for implementing part of this tools via constraints and typesystem. But, for instance, my target language has such a tool (e.g. SMT solver) which operates with its bytecode. So, I'm interested whether there is a way to bind the output of the solver with projectional code (similarly to the first question) and for example to generate code on the fly (while editing) for so-called online checking. Or a way to implement such tools as solvers above MPS language. Basically I want to know the limits of built-in tools for implementing analysis for MPS languages, i.e. what I can and can not do with em.
Please sign in to leave a comment.
You are right in the assumption that all MPS models are, as of now, eventually generated to text files, which are then processed by an external tool, such as compiler. Along with the generated text, a trace file is generated (trace.info), which contains mapping of text file locations to original nodes in the model. This is used by the debugger. Theoretically this information can be used for other purposes, such as propagating of compiler messages.
If by "on the fly" you mean generating text from a model while editing it, then unfortunately the answer is no. One has to explicitly invoke the generator via Make or Build actions in order to produce the text.
As to the question of integrating tools that operate on the model itself, which is represented as an AST, then the possibilities are infinite. One is welcome to write custom "checking" rules, which will be executed on demand when a change in the model occurs. Such rules have full access to the model in memory, and can execute various queries with the use of "SModel Language". The rules can also report issues that will be shown by the editor.
FYI: There is some ongoing work for doing model transformations while editing at the MPS Extensions Repository (called Shadow Models).