理论上,可逆解析器的例子? [英] Theory, examples of reversible parsers?

查看:59
本文介绍了理论上,可逆解析器的例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

外面的人是否了解解析器背后的示例和理论,这些示例和解析器将采用(也许是)抽象语法树并生成代码,而不是相反.从数学上讲,至少在直觉上,我相信code-> AST的功能是可逆的,但是我试图找到它的工作/示例……除了像《龙书》之类的常用资源之外.有什么想法吗?

Does anyone out there know about examples and the theory behind parsers that will take (maybe) an abstract syntax tree and produce code, instead of vice-versa. Mathematically, at least intuitively, I believe the function of code->AST is reversible, but I'm trying to find work/examples of this... besides the usual resources like the Dragon book and such. Any ideas?

推荐答案

这种东西称为访问者".是遍历树并做任何必须做的事情,例如优化或生成代码.

Such thing is called a Visitor. Is traverses the tree and does whatever has to be done, for example optimize or generate code.

这篇关于理论上,可逆解析器的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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