Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Multi-Language compiler/code Generator
Hello. I'm looking into the feasibility of using python to generate an interpreter/code generator for a custom language. The idea is that the custom language is used to generate different code outputs in multiple other languages.

I feel getting to the point where I can generate an AST from my custom language is very doable (albeit not easy considering my skill level). However, I am having difficultly understanding how to create a code generator which can interpret the AST and spit out code in a few target languages (Ultimately, I would like to generate both C and python code). If it makes things easier, the custom language would only need simple constructs such as loops, conditionals, assignment, print statements etc. The main reason for creating a custom language is to support some specific builtin functions (i.e. raw code insertion in target language among others).

I know there is existing code translators such as Haxe, but I think that is a bit overkill for what I am trying to achieve as I do not need the entire syntax of the target language only a subset of the rules based on the constructs I define in the custom language. The overall intention here is to provide a 'golden' source that will be equivalent in the target languages and avoid potential syntax or semantic errors involved in manually writing the target code.

Any idea if something like this would be feasible?
I would use lex and yacc

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  What is the best book for in-depth Python for advanced other-language programmers? user118967 1 135 Jun-04-2019, 07:56 PM
Last Post: snippsat
  Coconut - A Functional Language Which Compiles to Python nilamo 2 325 Jan-04-2019, 12:01 AM
Last Post: micseydel
  generator concurrency Skaperen 3 380 Dec-26-2018, 07:24 AM
Last Post: Skaperen
  maybe a generator? Skaperen 2 467 Sep-11-2018, 09:00 PM
Last Post: Skaperen
  language feature i'd like to have Skaperen 5 909 Feb-05-2018, 06:41 AM
Last Post: Skaperen
  terminology question: generator data Skaperen 4 880 Jan-30-2018, 05:27 AM
Last Post: Skaperen
  using my flattree generator Skaperen 0 480 Jan-24-2018, 03:25 AM
Last Post: Skaperen
  Transcrypt 3.6.56 Python to Javascript compiler now supports embedded JSX. jacques_de_hooge 1 786 Dec-01-2017, 05:30 PM
Last Post: nilamo
  Some Guy Today Told Me Python Isn't A Real Programming Language digitalmatic7 11 3,047 Dec-01-2017, 12:58 PM
Last Post: I_love_py
  the fastest-growing major programming language dvs1 0 733 Sep-07-2017, 02:50 AM
Last Post: dvs1

Forum Jump:

Users browsing this thread: 1 Guest(s)