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
  Coconut - A Functional Language Which Compiles to Python nilamo 2 176 Jan-04-2019, 12:01 AM
Last Post: micseydel
  generator concurrency Skaperen 3 200 Dec-26-2018, 07:24 AM
Last Post: Skaperen
  maybe a generator? Skaperen 2 309 Sep-11-2018, 09:00 PM
Last Post: Skaperen
  language feature i'd like to have Skaperen 5 693 Feb-05-2018, 06:41 AM
Last Post: Skaperen
  terminology question: generator data Skaperen 4 654 Jan-30-2018, 05:27 AM
Last Post: Skaperen
  using my flattree generator Skaperen 0 355 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 635 Dec-01-2017, 05:30 PM
Last Post: nilamo
  Some Guy Today Told Me Python Isn't A Real Programming Language digitalmatic7 11 2,287 Dec-01-2017, 12:58 PM
Last Post: I_love_py
  the fastest-growing major programming language dvs1 0 591 Sep-07-2017, 02:50 AM
Last Post: dvs1
  Transcrypt Python to JavaScript compiler now supports async/await jacques_de_hooge 4 1,483 Aug-24-2017, 04:21 PM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)