Personalizable programming language you can use to convert to others

programming-languagessyntax

Is there a programming language in which you can set your own syntax configurations and it would convert the code to a language you choose?

For instance, you would choose specific configurations like "Python's indexed blocks", [a,b,c] initializes arrays, ^ for exponentiation and others. A script would convert it to your choice language's equivalent.

Best Answer

Yes, but probably not in the way you’re thinking.

Lisp and its relatives have powerful macro systems that let you perform arbitrary transformations on your source, so in principle you can use macros (and reader macros, at the character level) to make just about any extensions you like. Concatenative languages (and languages by authors in related areas) have the potential for similar metaprogramming power. A good example of this is Forth, in which a lot of syntactic constructs (such as comments) can be user-defined. For a contemporary, non-esoteric example, there is an effort to give Perl 6 improved support over Perl 5 for user-defined syntax as well.