Features News

Plugin spotlight: Generate Python or Ruby with MPS-plaintextgen

The guys of DSLFoundry have brought my attention to the MPS-plaintextgen plugin recently. The plugin offers a language that models textual documents as collections of lines and words, supports layouts, alignment and indentation, and in addition to that, it comes with decent editing experience built in.

The binaries of the plugin can be obtained from the JetBrains plugin repository.

The language is primarily meant to be used in generators to ease transformation of complex models into text. Unlike with the TextGen aspect in MPS, the plaintextgen language allows you to leverage the model-to-model capabilities of the MPS Generator and enjoy the comfort of the projectional editor when defining the transformations. You simply model the output document and parametrize it with values from the input model.

This can be useful in several interesting ways:

  • generate textual documents from your models without the need for TextGen
  • quickly mock the generator for your prototype languages during development
  • generate code of limited complexity in general-purpose languages, for which MPS does not have support

As a proof-of-concept, I’ve created a sample project that uses the MPS plaintextgen language to generate Python and Ruby as well as plain text. You can check out the MultiLangEntities project on GitHub.



The Drive to Develop
-JetBrains MPS Team

Comments below can no longer be edited.

6 Responses to Plugin spotlight: Generate Python or Ruby with MPS-plaintextgen

  1. Avatar

    Alessandro Depase says:

    June 23, 2017

    Very interesting, I also tried it for a while.
    But not so user friendly, at least to me (or maybe because I lack of experience with MPS?): after many tries I just cannot format the output as I need (for example, the loop always outputs in a single line: how can I add a newline at the end of each iteration?)
    However, the idea behind the plugin seems to me very useful: I’m trying to write an editor for chatbot rules and the language is not Java…
    Thank you for your answer

    • Avatar

      Remi Bosman says:

      July 18, 2017

      If you struggle with manual editing of plaintextgen models then switching to the structural view may help. Right-click anywhere in the model –> Push Editor Hints –> com.dslfoundry.plaintextgen –> Structural: View under-the-hood structure.

      This view is less compact but provides explicit boundary markers which makes it significantly easier to insert new lines or words at specific places.

  2. Avatar

    Alessandro Depase says:

    June 23, 2017

    Well, I found the way to include the carriage return: it’s simple, (just highlight also the CR before sorrounding it with a macro), but not intuitive and if you forget it you have to destroy the macro and redo it. At least there is a workaround.
    Anyway, nice plugin

  3. Avatar

    Vaclav Pech says:

    June 24, 2017

    Yes, including the end-of-line in a macro is necessary in all target languages. I agree that the UX of macro manipulation could be improved.

  4. Avatar

    Trupti says:

    April 29, 2019

    I am new to MPS and I am trying to understand how to use plaintextgen. I tried to download your sample project MultiLangEntities from git. I added plaintextgen to the dependencies of sandbox, generator and language as well,However, I keep getting the error “map_Entity concept not found”. Could please help me, how can I get MultiLangEntities running?

    • Avatar

      Trupti says:

      April 29, 2019

      I could solve it. I guess, I didnt import plaintextgen properly in global libraries.

Discover more