全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Ambiguous grammar, weak equivalence?

又称: ambiguous grammar · weak equivalence (grammars)

Definition 23.6 University Computer Science — Year 2 · 第 23 章 — Context-Free Grammars and Pushdown Automata

A grammar is ambiguous if some word has two different parse trees. Two grammars are weakly equivalent if they generate the same language, whatever trees they give.

Two parse trees of a + a * a in the grammar E E + E E * E (E) a. Left: a + (a * a); right: (a + a) * a. Two parse trees of a + a * a in the grammar E E + E E * E (E) a. Left: a + (a * a); right: (a + a) * a.
Two parse trees of a+a∗aa + a * a in the grammar E→E+E∣E∗E∣(E)∣aE \to E + E \mid E * E \mid (E) \mid a. Left: a+(a∗a)a + (a * a); right: (a+a)∗a(a + a) * a.
The dangling else: in iixex, the else belongs to the inner if (left) or to the outer one (right). The dangling else: in iixex, the else belongs to the inner if (left) or to the outer one (right).
The dangling else: in iixexiixex, the else belongs to the inner if (left) or to the outer one (right).
在原文中阅读 →