There are others that had the same idea with other languages. For instance, take a look at CoffeeScript, which is basically the same idea but for Javascript.
You can make this work, but you'll have to take into consideration the conversion process. If you're looking for performance you do not want this to be done realtime on each request. Because adding layers of complexity will simply slow down your code. Even if it's just by the tiniest bit. To rememdy this CoffeeScript offers a command line 'compiler' for pre-compilation but also allows for a lazy loading situation - which works nicely for development purposes. Such a setup might work for you aswell.
发布评论
评论(1)
如果有的话,这是一个非常有趣的学习项目。
还有其他人对其他语言也有同样的想法。例如,看一下 CoffeeScript,它基本上是相同的想法,但针对的是 Javascript。
您可以做到这一点,但您必须考虑转换过程。如果您正在寻求性能,您不希望针对每个请求实时完成此操作。因为增加复杂性只会减慢代码速度。哪怕只是最微小的一点。为了弥补这一点,CoffeeScript 提供了一个用于预编译的命令行“编译器”,但也允许延迟加载情况 - 这非常适合开发目的。这样的设置可能也适合您。
您需要查看 PHP_LexerGenerator 和 PHP_ParserGenerator 用于实现您的解析器。即使后者不再维护:)
祝你好运! ;)
If anything, this is a very fun learning project.
There are others that had the same idea with other languages. For instance, take a look at CoffeeScript, which is basically the same idea but for Javascript.
You can make this work, but you'll have to take into consideration the conversion process. If you're looking for performance you do not want this to be done realtime on each request. Because adding layers of complexity will simply slow down your code. Even if it's just by the tiniest bit. To rememdy this CoffeeScript offers a command line 'compiler' for pre-compilation but also allows for a lazy loading situation - which works nicely for development purposes. Such a setup might work for you aswell.
You'll want to look at PHP_LexerGenerator and PHP_ParserGenerator for implementing your parser. Even if the latter is no longer maintained :)
Good luck! ;)