A
A
Avery0072014-02-09 11:06:40
C++ / C#
Avery007, 2014-02-09 11:06:40

Is it possible to write a PHP interpreter in C#?

Interested in the question, is it possible to write a PHP interpreter with OOP support and half of the standard library (working with files, mysql, ini, xml, json, strings, arrays) in C# in 1.8 months?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-02-09
@Avery007

Well, let's think and look. You can write a lexer / parser in ast in a week if you have at least a little experience in this. Then you need to somehow simplify the tree, translate it into opcodes (with the set of functionality that you described, it is no longer profitable to execute the tree recursively, because there is too much to implement), this will already take 2-3 months, and this is offhand, if you throw out the OOP, then you can keep within weeks 3. Then comes the turn of the virtual machine - everything is simple here. opcode number - its implementation - result. This case can be written quite quickly, in a week or two.
everything described above is very optimistic, provided that you know how php itself is implemented, taking into account the fact that some functionality will have to be sacrificed. So, it is very unlikely that you will have time in 1.8 months, although it is possible (albeit difficult).
ps Once upon a time, for the sake of learning, I wrote a javascript interpreter in .NET (very curtailed), which took about 240 hours. But as for me, prototypal inheritance is a little easier to implement.
pps In my opinion, you should pay attention to llvm, there are badly working translators of zend's opcodes in IR, ready-made translators of php itself (though greatly curtailed) into llvm's IR...

O
OnYourLips, 2014-02-09
@OnYourLips

I think it's possible.
But the team must have experience.

L
lookid, 2014-02-09
@lookid

Everything will come down to copy-paste of huge pieces of code and a plea that it would not fall on the defense.
Here's an example of Jint - Javascript Interpreter for .NET: jint.codeplex.com
You can download wc -l through the directories and figure out how much you'll just "type".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question