Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Multi-Language compiler/code Generator
#1
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?
Quote
#2
I would use lex and yacc
tutorial: https://www2.cs.arizona.edu/classes/cs45...-large.pdf
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  what could i do with my file tree list generator? Skaperen 3 530 Aug-15-2019, 05:09 AM
Last Post: Skaperen
  What is the best book for in-depth Python for advanced other-language programmers? user118967 1 180 Jun-04-2019, 07:56 PM
Last Post: snippsat
  Coconut - A Functional Language Which Compiles to Python nilamo 2 366 Jan-04-2019, 12:01 AM
Last Post: micseydel
  generator concurrency Skaperen 3 435 Dec-26-2018, 07:24 AM
Last Post: Skaperen
  maybe a generator? Skaperen 2 544 Sep-11-2018, 09:00 PM
Last Post: Skaperen
  language feature i'd like to have Skaperen 5 953 Feb-05-2018, 06:41 AM
Last Post: Skaperen
  terminology question: generator data Skaperen 4 944 Jan-30-2018, 05:27 AM
Last Post: Skaperen
  using my flattree generator Skaperen 0 517 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 821 Dec-01-2017, 05:30 PM
Last Post: nilamo
  Some Guy Today Told Me Python Isn't A Real Programming Language digitalmatic7 11 3,262 Dec-01-2017, 12:58 PM
Last Post: I_love_py

Forum Jump:


Users browsing this thread: 1 Guest(s)