使用lex和解析C处理文件的程序方法是什么? [英] What is the procedule way to handle files with lex and parse C?

查看:240
本文介绍了使用lex和解析C处理文件的程序方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解标记部分。我有lex读取文件,拆分标记,相应地标记它们,并在控制台中显示它。这之后的过程是什么?



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



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



3 )如何将lexed输入传递给解析器,获取treenode,并开始匹配,或者链接部分?



必须要有一些善良的灵魂来帮助我连接点。哈哈。



我的尝试:



我试过了很少有编译器书籍,但他们的结构方式,他们遗漏了链接部分,以及许多在线网站。

解决方案

只是谷歌搜索你可能会找到很多步骤关于这个主题的逐步教程。例如,请参阅:使用Flex,Bison和LLVM编写自己的玩具编译器(gnuu。 org) [ ^ ]。

I understand the tokenizing part. I have the lex reading the file, splitting the tokens, labeling them accordingly, and displaying it in the console. What is the process after this?

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 make the symbol table at this point?

3)How do I pass the lexed input to the parser, get the treenode, and start matching, or the linking part of this?

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

What I have tried:

I have tried a few compiler books but the way they structure it, they leave out the linking part, as well as many of the sites online.

解决方案

Just Googling you may find many step-by-step tutorials on this very topic. See, for instance: Writing Your Own Toy Compiler Using Flex, Bison and LLVM (gnuu.org)[^].


这篇关于使用lex和解析C处理文件的程序方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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