yacc: yet another compiler compiler
yacc:另一个编译器的编译器
Lex and yacc are a matched pair of tools.
lex和yacc是一对配对工具。
Imagine a yacc grammar something like this.
设想一个类似这样的yacc语法。
Programs using yacc, but not lex, are rarer.
使用yacc而不使用lex的程序比较罕见。
Lex and yacc are tools for building programs.
lex和yacc是编译程序的工具。
This is where the UNIX lex and yacc tools are useful.
在这种情况下,UNIXlex和yacc工具就很有用处了。
Lex and yacc are very good at parsing reasonably simple file formats.
lex和yacc非常擅长解析相当简单的文件格式。
Lex and yacc can be used to parse fairly simple and regular grammars.
lex和yacc可以用来解析相当简单和规则的语法。
The code provided should work in all major versions, such as MKS yacc.
给出的代码应该适用于所有主流版本,比如MKSyacc。
When yacc gets the "c" or "z," it knows enough to determine which rule to use.
当yacc获得“c”或“z”时,它所知道的足以确定将使用哪一个规则。
For instance, code in many programming languages can be read using lex and yacc.
例如,可以使用lex和yacc读取很多编程语言的代码。
In this tutorial, you'll examine how to use lex and yacc, first to build a calculator.
在本教程中,首先您将研究如何使用lex和yacc来构建一个计算器。
External DSLs build a new language grammar, requiring tools like lexx and yacc or Antlr.
外部DSLs可构建一个新语法,构建时需要使用lexx和yacc或Antlr等工具。
The first section of a yacc file defines the objects that the parser will manipulate and generate.
yacc文件的第一部分定义了解析器将要处理和生成的对象。
In fact, while lex and yacc are almost always mentioned in the same breath, they can be used separately.
实际上,尽管lex和yacc几乎总是被同时提到,但是它们可以单独使用。
Here's a simple example of a program that can be written in a page of yacc and a half-page of lex code.
这里是一个简单的示例程序,只需要一页yacc代码和半页lex代码就可以编写完该程序。
The general way this is done is to define a data type to contain objects that yacc will be manipulating.
通常解决此问题的方法是定义一个容纳yacc将要处理的对象的数据类型。
The first article will introduce lex and yacc in more general terms, exploring what they do and how they do it.
第一篇文章将使用更为通用的术语介绍lex和yacc,研究它们可以做什么以及怎样去做。
By using the lex and yacc tools, you can build a parsing engine that processes text according to specific rules.
通过使用lex和yacc工具,您可以构建一个分析引擎,根据特定的规则来处理文本。
This means that if yacc would have to read two tokens before it knew which action to take, it would be unable to parse this grammar.
这就意味着,如果yacc 在知道采取哪个动作之前,必须读取两个标记,那么它将无法解析该语法。
By default, the yacc-generated parser will start by trying to parse an instance of the first rule found in the rules section of the file.
默认情况下,yacc生成的解析器将首先尝试去解析在文件的规则部分得到的第一个规则的实例。
As a special case (implicit in yacc, rather than stated in the grammar), a 0 token indicates that there are no more tokens, and ends parsing.
作为一种特殊情况(在yacc中是隐式的,没有在语法中声明),0标记表示不再有任何标记,解析结束。
It used to be that using multiple parsers within a single program required a fair amount of careful tuning of the files generated by lex and yacc.
以前,在一个程序中使用多个解析器时,需要非常小心地调整lex和yacc生成的文件。
Their output is itself code, which needs to be fed into a compiler; typically, additional user code is added to use the code generated by lex and/or yacc.
它们的输出本身是代码,需要提供给编译器;通常,要增加另外 的用户代码来使用lex和/或 yacc生成的代码。
Conveniently, this has been corrected: modern versions of both lex and yacc allow you to specify a prefix to use on the names of symbols in generated code.
这一点已经得到了修正,而且更加便利:lex和yacc的最新版本都允许您在生成代码的符号名称上指定一个前缀。
In this case, the only token yacc would have available to decide which of these two actions to take would be the letter "b," which is the same in both rules.
在这种情况中,要决定采取两个动作中的哪一个动作,yacc可以使用的惟一记号是字母“b”,而它在两个规则中是相同的。
The GNU versions of lex and yacc are flex and bison and, as with all things GNU, have excellent documentation including complete user manuals in a variety of formats.
lex和yacc的GNU版本是flex和bison,与所有的GNU软件一样,它们也都有非常好的文档,包括各种格式的完全用户手册。
Building on the ground we covered in part 1 of this two-part series, this article covers a couple of concrete applications of lex and yacc and discusses some common pitfalls.
在由两部分构成的系列文章的第1部分所涉及的内容基础之上,本文讨论了两个具体的lex和yacc应用程序,并讨论了一些常见的缺陷。
This can create a problem when porting code from one system to another: generally, you are best off re-running lex and yacc on a new platform, rather than porting the generated code.
当将代码从一个系统移植到另一个系统时,这会产生问题:通常,您最好在新的平台上重新运行lex和yacc,而不要移植生成的代码。
Using the calculator as an example, you'll further examine the output and information generated by the lex and yacc system and study how to use it to parse other types of information.
使用该计算器作为示例,您将进一步研究lex和yacc系统生成的输出和信息,并学习如何使用它来分析其他类型的信息。
应用推荐