📄 4.9.1.0.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<BODY>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.8.1c.htm'" width="24" height="24" ></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.9.1.0b.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>4.9 分析器的生成器Yacc
</b></font>
<br><br>
<font class="title2"><b> 4.9.0 引言
</b></font>
<table><tr><td> </td>
<td class="content">
<p>一个翻译器可用Yacc按图4.28说明的方式构造出来。首先,书写一个包含翻译器的Yacc源程序的文件,如translate.y。使用UNIX系统的命令<br>
yacc translate.y</p>
把文件translate.y翻译为C程序,叫作y.tab.c,使用的方法是算法4.15描述的LALR方法。程序y.tab.c包含用C写的LALR分析器和其它用户书写好的C的函数。为了使LALR分析表少占空间,使用了紧凑技术压缩表的大小。用命令<br>
<p> cc y.tab.c -ly
</p>
编译y.tab.c,结果得到目标程序a.out,其中的ly表示使用包含LR分析程序的库(名字ly随系统而定)。如果需要其它过程,它们可以和y.tab. c一起编译或装入,就和使用任何C程序一样。</p>
</td></tr></table>
<center><img src="images/4.28.gif"></center><br>
<center class="content">图4.28 用Yacc建立翻译器</center>
<table width=100%><tr><td>    </td>
<td class="content">
<br>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.8.1c.htm'" width="24" height="24" ></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.9.1.0b.htm'" width="26" height="24"></img></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -