如何通过解析 C 程序并将其转换为要显示的电路图来进行反向建模
如何通过解析 C 程序并将其转换为要显示的电路图来进行反向建模。
示例
除了这是伪代码。
How can I do modeling in reverse by parsing a C program and turning it in to a circuit diagram to be displayed.
Example
Except this is psedocode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
乍一看,我会说你需要从头开始构建一个 C 编译器(或选择一个),并检查解析树,寻找可以用简单符号列表表示的结构。完成此操作后,您需要一个渲染引擎来获取检测到的构造列表并将它们排列在漂亮的图片中。
一些随机观察:
有很多 C 概念无法以简单化的方式呈现(即指针)
Doxygen 将是寻找想法的好地方(做一个漂亮的函数调用结构图)
偏离正题,您可能想看看IEC 61131-3 PLC 编程语言。这些是图形化的语言,提供了 5 种不同的方式来描述程序控制,并重点关注逻辑的表示
At a first guess I would say you need to construct a C compiler from scratch (or co-opt one) and inspect the parse tree looking for constructs that you can represent with your list of simple symbols. Once you have done that you need a rendering engine to take the list of detected constructs and lay them out in a pretty picture.
Some random observations:
There are many C concepts that can't be rendered in a simplistic manner (ie pointers)
Making your pic look pretty will be a bitch
Doxygen would be a good place to look for ideas (the do a nice function call structure graph)
Going off on a tangent you might like to look at IEC 61131-3 programming languages for PLCs. These are graphically laid out languages that provide 5 different ways of describing program control and focus heavily on representations of logic