# 电子工程代写|编译器代写Compilers代考|CPS843

## 电子工程代写|编译器代写Compilers代考|Simple Syntax-Directed Definitions

The syntax-directed definition in Example $2.10$ has the following important property: the string representing the translation of the nonterminal at the head of each production is the concatenation of the translations of the nonterminals in the production body, in the same order as in the production, with some optional additional strings interleave d. A syntax-directed definition with this property is termed simple.

Example 2.11: Consider the first production and semantic rule from Fig. 2.10:
Here the translation expr.t is the concatenation of the translations of expr and term, followed by the symbol +. Notice that expri and term appear in the same order in both the production body and the semantic rule. There are no additional symbols before or between their translations. In this example, the only extra symbol occurs at the end.

When translation schemes are discussed, we shall see that a simple syntaxdirected definition can be implemented by printing only the additional strings, in the or der they appear in the definition.

## 电子工程代写|编译器代写Compilers代考|Translation Schemes

A syntax-directed translation scheme is a notation for specifying a translation by attaching program fragments to productions in a grammar. A translation scheme is like a syntax-directed definition, exœpt that the order of evaluation of the semantic rules is explicitly specified.

Progr am fragments embedded within production bodies are calle $\mathrm{s}$ em antic actions. The position at which an action is to be executed is shown by enclosing it between curly braces and writing it within the production body, as in
$$\text { rest } \rightarrow+\text { term }\left{\operatorname{print}\left({ }^{\prime}+^{\prime}\right)\right} \text { rest }{1}$$ We shall see such rules when we consider an alternative form of grammar for expressions, where the nonterminal rest represents “everything but the first term of an expression.” This form of grammar is discussed in Section 2.4.5. Again, the subscript in rest $t{1}$ distinguishes this instance of nonterminal rest in the production body from the instance of rest at the head of the production.
When drawing a parse tree for a translation scheme, we in dicate an action by constructing an extra child for it, connected by a dashed line to the node that corresponds to the head of the production. For example, the portion of the parse tree for the above production and action is shown in Fig. 2.13. The node for a semantic action has no children, so the action is performed when that no de is fir st seen.

## 电子工程代写|编译器代写Compilers代考|Simple Syntax-Directed Definitions

Example 中的语法导向定义2.10具有以下重要属性：表示每个产生式开头的非终结符的翻译的字符串是产生式主体中非终结符的翻译的串联，与产生式中的顺序相同，带有一些可选的附加字符串 interleave d . 具有此属性的语法导向定义称为简单。

## 电子工程代写|编译器代写Compilers代考|Translation Schemes

\text { rest } \rightarrow+\text { term }\left{\operatorname{print}\left({ }^{\prime}+^{\prime}\right)\right} \text { rest }{1}\text { rest } \rightarrow+\text { term }\left{\operatorname{print}\left({ }^{\prime}+^{\prime}\right)\right} \text { rest }{1}当我们考虑表达式的另一种语法形式时，我们将看到这样的规则，其中非终结符表示“除了表达式的第一项之外的所有内容”。这种语法形式在 2.4.5 节中讨论。同样，下标静止吨1将产生式主体中的非终结休止实例与产生式头部的休止实例区分开来。

myassignments-help数学代考价格说明

1、客户需提供物理代考的网址，相关账户，以及课程名称，Textbook等相关资料~客服会根据作业数量和持续时间给您定价~使收费透明，让您清楚的知道您的钱花在什么地方。

2、数学代写一般每篇报价约为600—1000rmb，费用根据持续时间、周作业量、成绩要求有所浮动(持续时间越长约便宜、周作业量越多约贵、成绩要求越高越贵)，报价后价格觉得合适，可以先付一周的款，我们帮你试做，满意后再继续，遇到Fail全额退款。

3、myassignments-help公司所有MATH作业代写服务支持付半款，全款，周付款，周付款一方面方便大家查阅自己的分数，一方面也方便大家资金周转，注意:每周固定周一时先预付下周的定金，不付定金不予继续做。物理代写一次性付清打9.5折。

Math作业代写、数学代写常见问题

myassignments-help擅长领域包含但不是全部: