ats3 extension - jsonize abstract syntax trees

63 views
Skip to first unread message

Richard

unread,
Dec 22, 2019, 9:36:46 PM12/22/19
to ats-lang-users
Hello all,

Here is an ats3 compiler extension that I have been working on called "xjsonize", see https://github.com/sparverius/xjsonize

Brief overview, 
  • written in ats2 
  • similar to xinterp, links the ats3 compiler library (libxatsopt)
  • exports the AST at any level of compilation as json
  • provides a library libxjsonize 
    • link other extensions with -lxjsonize
    • for example, https://github.com/sparverius/xatscc,
      •  this example links both libxatsopt and libxjsonize to xinterp for jsonizing the the tree of the interpreter
Later versions can suite specific needs however, for now the jsonized output is currently meant to be as verbose as possible with the exception of location information (coming soon!). Also, the labify branch provides a flatter representation than the master branch. 




Possible use cases:
  • Learn about each translation phase of the ats3 compiler
  • Export AST to write extensions in any programming language you wish. (some examples soon!)
  • Something else you think ofentirely??
Personally, reading through the AST in json form has helped me tremendously with understanding the compilation phases of ats3. I hope you find it useful as well!


Cheers!

rodol

unread,
Dec 27, 2019, 1:54:36 AM12/27/19
to ats-lang-users
Awesome! Will definitely be reading and trying it out :)

Are there plans to support the reverse operation? To transform json to ATS3 ASTs?

gmhwxi

unread,
Dec 27, 2019, 10:58:40 AM12/27/19
to ats-lang-users
Yes. And also to other languages such as Python, JS, etc. for, say,
web development.
Reply all
Reply to author
Forward
0 new messages