I
I
Ivan Balashov2020-11-15 10:46:58
Programming
Ivan Balashov, 2020-11-15 10:46:58

How to create a programming language?

I wanted to do something new and unusual, I decided to create a YaP. Which language is best suited for this purpose (I heard about assemblers, but there is little material on them, I am not familiar with machine code. I would also like to see links to articles with certain languages ​​that show the creation of a PL in practice.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
G
Griboks, 2020-11-15
@vanoren

There are two main approaches here:
1) You make your syntax with automatic translation and generation of additional code into another language, for example, in js or c.
2) You make a virtual machine that runs your language. There is no anchoring to the underlying language, so you can do things like generic variables, super-mega dynamic, and so on. However, you will have to implement your machine in any other language.
Well, you can also read about strict / non-strict, static / dynamic typing, compilation / interpretation. These are all conditional things, but they help to understand what you want from your language.

P
Pashenka, 2020-11-15
@like-a-boss

All the creators of the PL started just like that - with a question on the toaster.

0
0nkery, 2020-11-15
@0nkery

https://monkeylang.org/ is a good tutorial on how to create a simple imperative language.
craftinginterpreters.com is more complex and complete material (something like Java is the result).

V
Vasily Bannikov, 2020-11-15
@vabka

1. We decide what we want to get, what task our new language will solve.
2. We make sure that the niche is not yet occupied
3. We write the grammar of the language in ANTLR
4. We parse the resulting abstract syntax tree
5. We generate LLVM-IR / JVM / .NET IL bytecode from AST or even immediately start execution.
6.???
7. PROFIT!
We created our own language with our own grammar and compiler/interpreter.
Maybe it even works and isn't completely useless.
It remains to write plugins for popular code editors so that writing code is not too painful.

K
koperagen, 2020-11-15
@koperagen

Well, the creation tutorials have already been mentioned. I will add Compilers : principles , technologies and tools

S
Saboteur, 2020-11-15
@saboteur_kiev

If you are so confused about where to start, come up with a simpler task for now.
ps It doesn't matter AT ALL in which language to write a programming language, especially for a training personal project.
Well, at least read about compilers and interpreters to decide.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question