Most parsers/compilers need just a small API with basic methods for parsing/analyzing/compiling a String or a file.
Although it is possible to create such an API using the Spoofax API, it is still complicated and requires a lot of code (example here).

It would be very useful if Spoofax could automatically generate a Java class with the necessary functionality:

class MyLang {

  void MyLang() {
    // generated code for loading and initializing the language here
  }

  ParseResult parse(String s) {
    // generated code for parsing the String here
  }

  ParseResult parse(File f) {
    // generated code for parsing the file here
  }

  AnalysisResult analyze(ParseResult pr) {
    // generated code for analyzing the parse result here
  }

  String myLangBuilder1(String s) {
    // generated code for executing the builder here
    // for example, the builder may compile a Green-Marl program into Java
    // method can be generated from .esv
  }
}
Submitted by Oskar van Rest on 21 February 2017 at 21:55

Log in to post comments