生成PHP代码(从解析器令牌) [英] Generating PHP code (from Parser Tokens)

查看:90
本文介绍了生成PHP代码(从解析器令牌)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在用于从解析器令牌<重新生成PHP代码的可用解决方案 token_get_all ?也欢迎使用其他生成PHP代码的解决方案,最好使用关联的词法分析器/解析器(如果有)。

Is there any available solution for (re-)generating PHP code from the Parser Tokens returned by token_get_all? Other solutions for generating PHP code are welcome as well, preferably with the associated lexer/parser (if any).

推荐答案

如果我我没弄错 http://pear.php.net/package/PHP_Beautifier 使用token_get_all()然后重写流。它使用 t_else t_close_brace 之类的方法来输出每个令牌。也许您可以为了简单而劫持它。

If I'm not mistaken http://pear.php.net/package/PHP_Beautifier uses token_get_all() and then rewrites the stream. It uses heaps of methods like t_else and t_close_brace to output each token. Maybe you can hijack this for simplicity.

这篇关于生成PHP代码(从解析器令牌)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆