Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse existing files to MPS language

Tags:

mps

I am thinking to move to Jetbrains MPS, so i can edit my files with custom defined language more easily.

I have started to create the files a while ago and there are a lot of files already. Is there any way to convert those files automatically to my language in MPS, than just copy pasting parts of code?

like image 873
user3009344 Avatar asked May 21 '16 11:05

user3009344


1 Answers

Sure: there are several ways. The first one is to define a custom persistence mechanism for MPS. It means that you will be able to open, edit and save the files in MPS keeping the current format. However if you do this you will lose some of the flexibility of MPS because when you will extend the language or combine your language with others you will have to revise the persistence mechanism. I suggest instead to simply parse your files, build an Abstract Syntax Tree and create corresponding nodes in MPS. Here there is a tutorial showing how to use an ANTLR parser to import files in MPS: http://tomassetti.me/antlr-and-jetbrains-mps-parsing-files-and-display-the-ast-usign-the-tree-notation/

like image 116
Federico Tomassetti Avatar answered Oct 19 '22 03:10

Federico Tomassetti