HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Compile a programming language with itself

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
itselfcompilewithprogramminglanguage

Problem

I'm a computer science student. I want to create my own programming language (A basic language with few instructions).

I know how to do a syntactic analyser, I already did it in Perl. In an article, I read something about the compiler, a compiler is done in itself.

For example the C compiler is written in C. How it's possible?
I can make my own language but I don't know how I could execute it? Any idea?

It's really a good question and I can write a blog the project.

Solution

The trick is bootstrapping. You first write a compiler for your language (or a subset thereof) in some other language. Then you write a compiler for your language (or a large subset of the one you can already handle) in your language. You use the former compiler to compile the new compiler, and then the new compiler can compile itself.

Context

StackExchange Computer Science Q#16248, answer score: 15

Revisions (0)

No revisions yet.