Looking for graph#tree transformer usage examples

你说的曾经没有我的故事 提交于 2019-12-11 07:29:16

问题


I'm writing new transpiler compiler of my programming language Ya. Since the AST Abstract Syntax Tree transformations and output language code generations is a big deal then I'm looking to use existing tree#graph transformers and output generators = pretty printers. Yet up now failed to find the tool since failed to find use examples. The list of promising tools that I've read about:

  • Spoofax + Stratego/XT : have not found source code up now; or maybe found but it's in Java that disallows to evaluate the power of Stratego lang.
  • Rascal MPL. It has only JVM execution => as initial C++ follower I'm in trouble to use it if to.
  • OBJ OBJ3 Maude. Know nothing.

And also have found:

  • Coctail http://cocolab.com costs €3K so with hidden source code so can't see it's source code as best example of use => can't evaluate it's power. €3K also near to disable this for me.

Questions:

  • Are there other tree#graph transformation tools#langs # outputers of source code text from AST_like data?
  • Looking for graph#tree transformer good+big+complex usage examples. Expecting that compiler source code is the best case.
  • All ideas for Spoofax Stratego/XT Rascal Obj are welcome.

回答1:


Your question is very broad and I will try to answer it from the Rascal perspective.

First, Rascal provides extensive support for both concrete and abstract syntax trees. The former are concrete parse trees including all lexical information and can be very conveniently traversed, analyzed and transformed. Preserving all textual information is important for reengineering applications but is convenient in compiler writing as well. The latter are abstract data types (typed trees) that can be traversed and transformed as well.

Second, Rascal provides built-in data types like maps, sets and relations that can be used to conveniently compute with relational data. In fact, many relational algebra operators such as join and transitive closure are built-in. We use this all the time to manipulate graph-like data.

Third, Rascal provides sophisticated string templates for, amongst others, code generation.

Fourth, it is correct that the Rascal implementation is based on the JVM and JVM byte code generation. However, we package Rascal applications as self-contained jars, hence a tool written in Rascal can be deployed and executed independently.

Finally, there are many usage examples including several large compilers, source code analysis, many DSLs (both in research and commercial), and other applications.

Hope this can further help you in your explorations!



来源:https://stackoverflow.com/questions/48120499/looking-for-graphtree-transformer-usage-examples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!