Making a Compiler with PHP

+1 Oussama Fahchouch · June 17, 2015
Is it hard task for a beginner with just 1 year experience of programming to make a compiler in PHP? 

I am learning application development at college, and i want to make a compiler to learn..

Post a Reply


Oldest  Newest  Rating
0 Sheldon Juncker · July 20, 2015
Clark, you're not understanding what the question is. It sounds like he wants to use the PHP language to create a compiler for another language (which could be PHP if he wanted). A compiler can be written in langauge A, accept as input language B and output language C. It doesn't really matter what A, B, and C are.

This is a very doable task, but you will want to do some research on compiler design. I would suggest that you read the famous "Dragon Book" which is the number one resource for anyone attempting to write a compiler. I own the book and it is excellent.

The actual title is Compilers: Principles, Techniques, and Tools (2nd Edition). You can get it on Amazon, or you can probably find a PDF somewhere online.

You should note that creating a compiler is not an easy task by any means. You will need to know PHP well and you will also need an understanding of the language that your compiler will output whether it be Assembly or any other language. 

Good luck!
0 Mete Öncü · July 15, 2015
I guess Oussame want to write a compiler which will be able to understand in an imaginary coding style and it is not compulsory that compiler translates codes to machine language.

It's an imaginary coding style. & means it's a variable, may means if,

may[&name=="mete]->print["it's me"] x print["it is not me"]

and the supposed compiler detects the imaginary codes and runs in php format.

Just like javascript compiles jquery.
0 Oussama Fahchouch · July 11, 2015
Clark, i want to make a compiler because it's possible. I want to learn. I won't use the compiler, because there is a better one already doing it's job.

I posted this question because my teacher told me to build one in php, so that i could learn.

U missed the point i guess, that's why i told you to read my post again.


Sachin, it would be nice if i could do that with php, but the teacher did ask me just to make a random compiler in php ( because of learning ).

0 Sachin Kumar · July 8, 2015
Well Clark, I guess he is talking about to make compiler not for PHP which actually doesn't  need any compiler. He want to create a compiler for languages like c++/java and all.
m I right?? Ouassama?
0 Oussama Fahchouch · June 20, 2015
That's why i want to make one, because i want to learn how they are made..

Please read my thread before you answer next time.

I want to make a compiler in PHP because i want to learn how to, not because i want to use it.

Sorry, peace.
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.