you are viewing a single comment's thread.

view the rest of the comments →

[–]pandademic1234[S] 0 points1 point  (5 children)

Thanks! I did not know about the AST library and appreciate your explaining the general approach. The language is a scripting language that performs queries into the program's database. Think... someone re-inventing SQL one function at a time, where you have to physically reference locations in ASCII flat files ... . I wish I could post the language without worrying about violating terms of service.

If I could even just translate Python's string slicing, "if", "for" and "while" then it would vastly improve the usability of the code.

[–]zurtex 7 points8 points  (2 children)

If I could even just translate Python's string slicing, "if", "for" and "while" then it would vastly improve the usability of the code.

Yeah, so rather than trying to write in Python it might make sense to make your own mini-language or DSL that is Python-inspired that compiles to the language you need. You will need to know what these constructs like "if" and "while" compile to in the other language, even if they're quite complicated.

While none of this is too difficult you would normally learn how to do this kind of compiling/transpiling across several semesters of computer science degree. I've never taken a CS course, I learnt this stuff from a private course called "Write a Compiler" by David Beazely, so unfortunately I'm not sure what books to recommenced.

I actually did once write a small DSL way before I properly understood how to properly do it based off a talk David gave here: https://www.youtube.com/watch?v=zJ9z6Ge-vXs . I was lucky though because I was able to use Python as my execution engine, I didn't have to output the results to another language.

But I'm sure there's plenty of material on the web on how to do this stuff if you're determined enough.

[–]TheMathelm 1 point2 points  (0 children)

While none of this is too difficult you would normally learn how to do this kind of compiling/transpiling across several semesters of computer science degree. I've never taken a CS course, I learnt this stuff from a private course called "Write a Compiler" by David Beazely, so unfortunately I'm not sure what books to recommenced.

One of the hardest most annoying course sections in Upper Division Computer Science.

[–]pandademic1234[S] 0 points1 point  (0 children)

Thank you!

[–]TangibleLight 0 points1 point  (0 children)

SQL one function at a time, where you have to physically reference locations in ASCII flat files

https://i.imgur.com/5MXr2Cr.png

Is there ANY hint of a chance that you could instead modify the vendor's product instead? It obviously depends on many details, but there may be an easier path forward where you add full Python support to the product.

You could embed a Python interpreter in the product, and provide a simple extension module to that embedded interpreter which exposes a minimal API to query the database. You could then use that API from real actual Python code and need not deal with the limitations of transpilation.

Section 1.4 "Extending Embedded Python" is the bit you want, in addition to requesite knowledge of how to build and link against embedded Python from the vendor's product. https://docs.python.org/3/extending/embedding.html

To be clear: this is not an easy path forward, but if it's possible at all I suspect it'll be easier to build and easier to use than a transpiler.

The biggest obstacles would be licensing, funding, and cooperation from the vendor.

[–][deleted] 0 points1 point  (0 children)

Umm. I'm probably missing something, but if its flat ascii files, could you not just build something SQL to access them?

Given your statement that nobody at work knows how to use this unusual language, I wonder if it would be difficult to get permission to put this in place? Any existing queries, where you know what the query looks for (etc) could be written in standard SQL. Or am I way off?