解析问题?平原C. [英] Parsing question? Plain C

查看:98
本文介绍了解析问题?平原C.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解令牌化。我可以让lex读取文件,拆分标记,并在控制台中显示它。这之后的过程是什么?如何检索标记化信息或将其传递给解析器,并与treenode连接?我打印的代码打印出读取的整个缓冲区,然后将每个缓冲区分成标记,然后标记它们。



1)此时我是否尝试从预处理器和lex再次拉出定义?哪个会出现在lex.h文件中,或者出现在像Dr.Dobbs这样的def文件中?



2)我是否调用了token.h和treenode.h以及开始尝试匹配它们?



3)此时我是否制作符号表?



必须有某种灵魂能帮助我连接点。哈哈。



我尝试过:



I understand tokenizing. I can get the lex to read the file, split the tokens, and display it in the console. What is the process after this? How do I retrieve the tokenized information or pass it to the parser, and connect with the treenode? The code I have prints the whole buffer that is read, and then breaks each into tokens, and labels them, according.

1)At this point do I try to pull the defines from preprocessor and lex again? Which would be in the lex.h file, or in a def file like Dr.Dobbs?

2)Do I call the token.h and treenode.h and start trying to match them?

3)Do I make the symbol table at this point?

There has to be some kind soul that will help me connect the dots. Lol.

What I have tried:

.

推荐答案

您可以使用 strtok 功能进行解析C。
You can use the function strtok for parsing in C.


这些程序的名称是'compiler'。

编写编译器不适合初学者,它是高级主题。

如果你想了解编译器,我推荐龙书:

龙书 - 维基百科 [ ^ ]

编译器:原理,技术和工具 - 维基百科 [ ^ ]
The name for those programs is 'compiler'.
Writing a compiler is not for beginners, it is advanced topic.
if you want to learn about compilers, I recommend the dragon book:
Dragon Book - Wikipedia[^]
Compilers: Principles, Techniques, and Tools - Wikipedia[^]


这篇关于解析问题?平原C.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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