Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu Ambiguous grammar, weak equivalence?

Dikenal juga sebagai: ambiguous grammar · weak equivalence (grammars)

Definition 23.6 University Computer Science — Year 2 · Bab 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).
Baca dalam konteks →