A
A
Alexey Cheban2014-01-31 23:52:17
Programming
Alexey Cheban, 2014-01-31 23:52:17

What is needed to create a new programming language, what tools and what programming languages ​​will need to be involved in creating a new language?

What programs are needed to create a new programming language. What programs are needed to create a new compiler or interpreter.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
T
tsarevfs, 2014-02-01
@tsarevfs

The compiler can be written in any language. The code will consist of several modules.
1. Lexer - converts the source text into a sequence of tokens.
a = b + 1; will turn it into something like {variable("a"), assign, variable("b"), add, number("1")}
2. The parser is based on the grammar . Converts a sequence of tokens into a tree.

.       assign
      /          \
var('a')       add
               /     \
          var('b')   number(1)

3. Next, bypassing the resulting tree, we generate code .
Various methods are described in the dragonbook .

F
fenrirgray, 2014-02-01
@fenrirgray

A new programming language can be written in any other existing programming language. Accordingly, the means depend on the language.

N
Nikolai Turnaviotov, 2014-02-01
@foxmuldercp

Attention to the question - "WHY?"?
when creating this or that instrument, some goal was pursued, no matter what it is a wheel, a whistle or a handle.
What is your goal?

A
alexanius, 2014-02-01
@alexanius

Depends on what part you want to pay special attention to. If you just create your own language with an unusual syntax, then write a frontend to llvm (or gcc, or jvm, or parrot, or whatever you like). If you want to practice code generation - respectively backend to llvm or whatever you chose there. If you want your own copier, you will also have to make your own optimizer and code generator. But if this is for you to learn, then just try to participate in the development of llvm / gcc. If there is absolutely nothing to do - read how they work and try to do something like that.

L
lookid, 2014-02-01
@lookid

You can see Lua sources. In earlier versions, there are not many of them and everything is very clear.
The scripting language consists of: lex-yacc-bison, which generate a parser for you + your implementation of algorithm data structures.
If you want to get attached to some platform, then write a frontend to llvm.
But in general ... if just for fun, then there is no point in this. You won't get any experience. You haven't been patching continuously for the last 10 years in gcc or python. And parsing lines and atof / atoi are in the 1st year of the university.

A
Anton, 2014-01-31
@FAQEnD

www.cyberforum.ru/cpp-beginners/thread41218.html
here is an interesting topic

L
Leonid, 2014-02-01
@leonid-lapidus

The answer to your question is: in the beginning, any language will do, and then in the language itself being created - this is how Pascal was written. The method is called unrolling.
On the topic, I highly recommend T. Pratt and M. Zelkowitz - Development and implementation of programming languages ​​(not for sale, but to understand what I mean: www.ozon.ru/context/detail/id/1158230 ).
Here's another one I found for you: trpl.narod.ru/t-books/_TRYAPBOOK_pdf.pdf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question