Custom language loader

Hello!

We are have some own Pascal-like language for oracle db. But all it texts is just plain texts, not AST as MPS required. And I think it is good idea to use MPS as editor for this language, but i didn't find how can i load plain text as AST of custom MPS language. Only i did find is 'Convert java to MPS' button in MPS Idea plugin. Is there an option to write own parser to load text of custom language to MPS AST of it, and after all save MPS AST to text of this custom language to save it under git. Is this possible use MPS in this way? Thank you!

3 comments

Well, I would do this:

* first I would build a parser using ANTLR. I would package that parser as a single fat JAR (a jar with all the dependencies)*

* then I would define MPS concepts for your language

* then I would use that parser inside MPS building new MPS nodes which corresponds to the AST built from your parser

For the third point I would use a ModelAccess instance:

ModelAccess.instance().runWriteActionInCommand(new Runnable() {
    public void run() {
      // Instantiate your nodes here
     }
})

There are different ways to trigger this import code, but that is just a UI decision.

0

For the last two points, you could look at the ANTLR_MPS project: https://github.com/CampagneLaboratory/ANTRL_MPS

It can help you define concepts and the visitor you will need to populate the AST from the parse tree.

0

Please sign in to leave a comment.