I am super novice to this topic, so my apologies if my question looks completely nonsense to you all!

Imagine you want to create a new programing language that transpiles to a more common high/low-level language such as C, LLVM IR, Cranelift, MLIR, libFirm, GIMPLE ... how would you do that and what are the steps towards that goal?

  • I can imagine that the first step is to have a context-free grammar using BNF or any of its variants/flavors (hence the question here). Data types/structures, classes, functions, operators, loops, if-statements, ... should be probably represented by regular expressions. One may reuse some of the pieces already used in other programming languages. For example here the ANTLR grammar for many different languages.

  • Next step one may use tools such as lex, Flex, Yacc, GNU Bison, ANTLR ... to generate/develop a parser automatically.

I have no clue what could be the next steps and if there are tools to automate the rest of the toolchain. For example given the RegEx representation of the basic building blocks of the language, generate a transpiler automatically. I would appreciate it if you could Eli5 how a new programing language and its toolchain is made.

  • 1
    $\begingroup$ The first thing (imho) would be to have an answer to the question, "What new and interesting feature will I be implementing which will make my language easier / more powerful / safer / other ____ (fill in the blank)?" With rare exceptions, syntax is the least important feature of a programming language. $\endgroup$ – rici Jun 22 '20 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.