I have a specific application DSL query language which I need to translate to Cypher.
This means I get in runtime a string with my domain query language query (SQL like for the example) and need to create a Cypher query string that I can send to the Neo4j server.
I was wondering what are the best options for implementing such a translation engine.
I've read about Xtext and I'm familiar with Antlr but I'm interested if there are better tools for such a task.
The translation isn't just translating between the two languages, it needs to translate between the data models of the two, which means I need a good infrastructure for analyzing the source language statement.
In addition, if there is some open-source project which does similar things, it can be a great starting point.

- 6,601
- 9
- 53
- 92
-
See https://stackoverflow.com/q/14483337/120163 – Ira Baxter Jun 08 '20 at 01:16
1 Answers
I am no sure why you mention Xtext and Antlr, they are usually used for creating languages (most importantly the parser part) which you are not doing.
You want to determine what kind of translation you want to perform, i.e. whether you build an AST from your query DSL or not, and whether you generate a Cypher AST or simply Cypher code.
If your query DSL looks a lot like Cypher, you could probably easily do code-to-code translation in the Java flavour of your choice.
Otherwise, you will need to build an AST from your query DSL. Either you already have a parser (note that if you have a runtime for your query DSL it probably includes a parser) or you will have to create it (in ANTLR or even with the Java flavour of your choice). Creating a parser takes time though.
Secondly, you want to determine what you are going to generate: a Cypher AST, if you have the Cypher grammar as some artefact; or more likely, a Cypher query. If you have a Cypher AST you can do the transformation with any language, but if you need to generate a Cypher query you will have to write a code generator either in the Java flavour of your choice or using something like Eclipse Acceleo or Eclipse Xtend.

- 778
- 4
- 12
-
Thanks for your answer. I've added some details in case it helps to understand better the specific scenario. @user1292456 – Avner Levy Jun 08 '20 at 13:03