博客首页
注册
建议与交流
排行榜
加入友情链接
推荐
投诉
搜索:
帮助
hope_process
想清楚自己要走的路,走自己的路,绝不为其他诱惑动心,留足
heixia108.cublog.cn
管理博客
发表文章
留言
收藏夹
· OS
· 哲学
· 常去网站
· 资料库
· compiler
· 搜索引擎
· Linux
· C++
· 算法
· 网络技术与安全
· MySQL
· OpenGL
· java
· Perl
· 病毒学习
· N-blog
· USB
博客圈
音乐
相册
· 收藏
文章
· 精典转载
· linux
· C/C++
· Java
· LDD
· compiler
· 算法
· OS
}
· oldlinux
· 病毒学习
· 搜索引擎
· 网络技术与安全
· 人物
· 隐藏文件夹
}
· Lisp
· Perl
· OpenGL
· 数据挖掘与AI
· 软件工程
· 硬件相关
· Windows
· 心情
· Enhlish
· 学习资料
首页
关于作者
既然目标是地平线 留给世界的只能是背影
||
<<
>>
||
我的分类
文章列表 - compiler
Tiny 代码生成及“虚拟机”
至此,一个简单的编译器已经做好了,学到了不少,不过真正的编译器才刚刚开始。<br><br>有点遗撼的是:在代码生成的过程中,并没有采用回填技术,而是简单地增加标号,然后在tm“虚拟机”中重新根据标号整理顺序<br>如<br>if x < 9 then <br> write x<br>end<br><br>生成如下:<br><br>* TINY Compilation to TM Code<br>* File: test.tm<br>* Standard prelude:<br> 0: LD 6,0(0) load maxaddress from location 0<br> 1: S……
查看全文
发表于:2008-06-10 ┆
阅读(98)
┆
评论(0)
Tiny 语法及语义分析
有一个函数需要说明<br><br> <table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);">TreeNode <span style="color: rgb(0, 0, 204);">*</span> stmt_sequence<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 204);">)</span><br> <span style="c……
查看全文
发表于:2008-06-08 ┆
阅读(88)
┆
评论(0)
Tiny 词法分析
此Tiny语言很简单只有 if then else end repeat until read write 几个保留字。 <br> <br> 要注意的问题:<br><br> 1. 要加上对 '/r'的处理(winodws下文件有回车符)<br><br> 2. main.o: main.c globals.h util.h scan.h parse.h analyze.h cgen.h <br> $(CC) $(CFLAGS) -c main.c<br> <br> $@表示 main.o<br> $<表示 main.c<br> &n……
查看全文
发表于:2008-06-08 ┆
阅读(96)
┆
评论(0)
能生成中间代码了
哎,不容易!<br><br> 此生成中间代码过程中主要采用的是回填(backpatch)技术<br><br> 支持 <br> 1/ if then else<br> 2/ switch case<br> 3/ while do<br> 4/ repeat until<br> 5/ for i := e to e do <br> 6/ break and continue in loop structure.<br> 7/ function call in expression<br> 8/ boolean expression translates in control flow <br> 9/ array element<br><br> 这门课就要结束了,可是还没能生成目标代码<img src="http://……
查看全文
发表于:2008-05-21 ┆
阅读(128)
┆
评论(0)
XML 文档
<div><p class="copyright">Copyright © 2004 本文遵从GNU 的自由文档许可证(Free Document License)的条款,欢迎转载、修改、散布。</p></div><div><p class="pubdate">发布时间:2004年12月03日</p></div><div><p class="pubdate">最近更新:2006年02月17日,新增CSS内容</p></div><div><div class="abstract"><p class="title"><b>Abstract</b></p><p>XML技术是Internet技术的又一次革命。本笔记记录标记语言的历史和发展,还有我的学习历程。</p></div></div><hr><div class="toc"><p><b>Table of Contents</b></p><dl><dt><sp……
查看全文
发表于:2008-04-23 ┆
阅读(143)
┆
评论(0)
tiger(3) 语法分析
残缺也是一种美,这个文法冲突始终没有解决,不过在“抽象语法”模块中将得到解决。<br><br>==> 现在发现原来这里面暗藏着太多的“杀机”,难怪...(其实有些文件的语法是错的!:( )<br><br>测试结果:<br><br> <table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 204);">[</span>heix……
查看全文
发表于:2008-04-08 ┆
阅读(160)
┆
评论(0)
调试 文法 很痛苦!
在tiger语法分析的过程中,文法的设计出现了reduce confict,调了几个小时了还是没有什么进展,关键是还不知道怎么用yacc调试,哎,<img src="http://www.cublog.cn/images/face/013.gif">,先休息一会,明天起来继续!
查看全文
发表于:2008-04-04 ┆
阅读(155)
┆
评论(0)
flex %s %x
发现学英语的好处了,用中文搜到%s,%x的区别是相当的困难!<br> <br><table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"> <span style="color: rgb(0, 0, 204);"></span><span style="color: rgb(0, 0, 204);"></span><span style="color: rgb(0, 0, 204);"></span><span style="color: rgb(0, 0, 204);"></sp……
查看全文
发表于:2008-03-22 ┆
阅读(149)
┆
评论(0)
自动机
如果你用<span style="color: rgb(255, 1, 2);">自动机</span>的思想理解和编写程序,或许思路会更清淅。<br><br>你可以试着用自动机去理解KMP,嵌套注释等。<br>
查看全文
发表于:2008-03-19 ┆
阅读(128)
┆
评论(0)
正规表达式 注意
1.定义 DIGITS 为 [0-9]<br> 后引用时要加上括号 {DIGITS}<br><br>2.待续。。。<br>
查看全文
发表于:2008-03-19 ┆
阅读(125)
┆
评论(0)
tiger(2) 词法分析
该词法分析能处理嵌套注释<br><br> <table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(255, 0, 255);">"/*"</span> <span style="color: rgb(0, 0, 204);">{</span> <span style="color: rgb(0, 0, 255);">char</span> c<span style="color: rgb(0, 0, 204);">;</span><br> ……
查看全文
发表于:2008-03-19 ┆
阅读(121)
┆
评论(0)
tiger(1) 直线式程序解释器
昨晚调了一晚的程序,没有出结果,于是今天起了个早床。。。搞定了:)<br><br> 另外觉得gcc的提错方式还可以改一下,不小心敲错一个函数后,eg:<br> t1 = interStm( s->u.compound.stm1 , t); //掉了一个p<br> // t1 = interpStm( s->u.compound.stm1 , t);<br> 提示错误,类型转换不兼容<img src="http://www.cublog.cn/images/face/033.gif"> 这样很难查错,提示没有定义该函数可能会更好。<br><br> 该程序解释一个语句:<br> A_CompoundStm(A_AssignStm("a",<br> ……
查看全文
发表于:2008-03-18 ┆
阅读(130)
┆
评论(0)
AT&T的宏指令 .p2align[wl]
<h2><a name="SEC113" href="http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_node/as_toc.html#TOC113"><code></code></a></h2><h2><a name="SEC113" href="http://www.gnu.org/software/binutils/manual/gas-2.9.1/html_node/as_toc.html#TOC113"><code>.p2align[wl] <var>abs-expr</var>, <var>abs-expr</var>, <var>abs-expr</var></code></a></h2> <p> <a name="IDX358"></a> <a name="IDX359"></a> Pad the location counter (in the current subsection) to a particular storage boundary. The first ex……
查看全文
发表于:2008-03-16 ┆
阅读(118)
┆
评论(0)
对比switch和if-else
在<a href="http://blog.chinaunix.net/u1/38279/showart.php?id=497312" target="_blank">理解switch的内部实现</a><br>中说到了if-else 与 switch 的效率问题,先看if-else<br> <br><br> <table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 255);">/*与上文(switch)中相同语义*/<br></s……
查看全文
发表于:2008-03-16 ┆
阅读(180)
┆
评论(0)
理解switch的内部实现
<table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 255);">/* switch1.c */</span><br> <br> <span style="color: rgb(0, 0, 255);">int</span> switch_eg<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 255);">int</span> x<span style=……
查看全文
发表于:2008-03-16 ┆
阅读(261)
┆
评论(0)
简单的c程序==>机器级代码
<table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 255);">/* code.c */<br></span></span></code></p><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 255);">int</span> accum <span style="col……
查看全文
发表于:2008-03-16 ┆
阅读(127)
┆
评论(0)
<深入理解计算机系统>
对于写编译器和更好的理解计算机都是很不错的一本书!<br><br> 该书代码下载地址 <a href="http://csapp.cs.cmu.edu/public/code.html" target="_blank">点这--></a><br><br> 此书网站 <a href="http://csapp.cs.cmu.edu/public/students.html" target="_blank">在这--></a><a href="Student%20Site%0AComputer%20Systems:%20A%20Programmer" s="" perspective="" (cs:app)="" target="_blank"></a><br><br> <br><div align="center"><img src="http://blogimg.chinaun……
查看全文
发表于:2008-03-16 ┆
阅读(160)
┆
评论(2)
complier网络资源
1.<a href="http://dragonbook.stanford.edu/" target="_blank">龙书</a><br><br>2.<a href="http://www.cs.princeton.edu/%7Eappel/modern/c/" target="_blank">虎书</a><br><br>3.<a href="http://compilers.iecc.com/crenshaw/" target="_blank">Let's Build a Compiler, by Jack Crenshaw</a><br><br>4.<a href="http://www.cbel.com/Compilers_Programming/" target="_blank">Compilers Programming 集大成于一身</a>
查看全文
发表于:2008-03-15 ┆
阅读(118)
┆
评论(0)
Lex-Yacc版计算器 version 0.02
在这个版本中新增了变量和数学函数功能,不过词法分析不是用lex写的(下版用lex写),还有Makefile写得相当的丑<br><br><br><table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 204);">测试如下<br></span></span></code></p><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0……
查看全文
发表于:2008-03-12 ┆
阅读(171)
┆
评论(0)
Lex-Yacc版计算器 version 0.01
不同于前面的手工打造,这次用到了工具Flex,Yacc,整个程序更加清淅直观,在version 0.02中将添加变量功能和函数功能。<br><br><table style="border-collapse: collapse;" bgcolor="#f1f1f1" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0" width="95%"><tbody><tr><td><p style="margin: 5px; line-height: 150%;"><code><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 204);">测试如下:<br></span></span></code></p><p style="margin: 5px; line-height: 150%;"><co……
查看全文
发表于:2008-03-11 ┆
阅读(132)
┆
评论(0)