What source languages ​​should my compiler use?

I wrote a compiler for a general-purpose programming language that creates an optimized tree for parsing its input. This intermediate format is then run through the preprocessor to translate it into the target language for later compilation into its own executable file.

Currently, C ++ is the only target language, but I would like to offer other solutions in case some programs can be useful for compiling with a backend that better supports some constructs in the source language.

Are there any languages ​​that are designed or very well suited for the compiler role?

I know LLVM, and although this is an exciting project in itself, I find it too low-level to directly target. I am looking for generic, medium-high-level languages ​​with high-quality implementations, the syntax of which can be created by the C preprocessor ; this way nothing like Python or Ruby. Lambda support would be nice, but not necessary.

+3
source share
6 answers

JavaScript, . , C, lambdas, , HQ, . : -, , -, JavaScript.

+7

, , ( C). . .

C-, .

+3

Neko - / , . Neko -, JIT- ( x86).

+2

O'Caml, Haskell, C99, Ada 2005, Scheme Lisp?

, - , .

+1

Google Go , . Go , # ++ Java - , "" ( ).

, Lua , AFAIK , C/++, (??).

+1

LISP dalects . , LISP S- AST, , , AST JSON XML. , LISP , , LISP . LISP, , ( , LISP)

If you are looking for more “traditional” target languages, I would recommend C or Javascript (BTW, Javascript - even the target for some Perl6 compilers). Or try some kind of high-level assembler.

0
source

Source: https://habr.com/ru/post/1758324/


All Articles