How to convert my DSL to an existing programming language?

559 views Asked by At

I want to build a domain-specific language that can be converted to an existing language (e.g. python, SQL). I try to avoid building a full-blown compiler and have looked into Xtext and Xpand. They look plausible, as Xtext will be used to design the grammar and produce the parse tree, Xpand will use the parse tree to generate code of the existing language (please correct me if I'm wrong).

What are your opinions on this? Do you think there're better alternatives to XText & Xpand I can use to achieve my purpose?

1

There are 1 answers

0
Ira Baxter On

You might consider the DMS Software Reengineering Toolkit.

It is designed provide general purpose program (e.g., arbitrary language or DSL) parsing, analysis, and transformation. It autoamtically produces ASTs from a context free grammar, provides support for building symbol tables and doing flow analysis, has source-to-source transformations to enable translations, and full prettyprinters from ASTs. The purpose of all this machinery is to enable minimal effort to build and support robust tools.

(I'm the principal behind it. I believe DMS is much more mature than Xtext for this purpose, having been in use for over 13 years now. YMMV).