Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu LR(1) item, LALR table?

Dikenal juga sebagai: LR(1) item · LALR table

Definition 3.8 University Computer Science — Year 3 · Bab 3 — Bottom-Up Parsing

An LR(1) item [A→β⋅δ, a][A \to \beta \cdot \delta,\ a] is an LR(0) item with a look-ahead terminal aa: the item is valid for γ\gamma if Start⇒rm∗αAw⇒rmαβδw\mathit{Start} \Rightarrow^*_{\mathrm{rm}} \alpha A w \Rightarrow_{\mathrm{rm}} \alpha\beta\delta w with γ=αβ\gamma = \alpha\beta and ww starting with aa (or a=$a = \$ if ww is empty). The closure adds [B→⋅ η, b][B \to \cdot\,\eta,\ b] for every b∈FIRST(δ′a)b \in \mathrm{FIRST}(\delta' a) when an item [A→β⋅Bδ′, a][A \to \beta \cdot B\delta',\ a] is present; the canonical LR(1) automaton is built from these items as the LR(0) one is, and a reduction by [A→β ⋅, a][A \to \beta\,\cdot,\ a] goes in column aa only. The core of a set of LR(1) items is the set of their LR(0) items. The LALR table is built from the LR(1) automaton by merging the states with the same core, taking the union of their look-aheads.

The four pairs of LR(1) states of the assignment grammar that share a core (each box shows the item that names the state; the states of L -> * . R also hold closure items). Reached through the left side, before =, the look-aheads are = and $; after =, only $. Merging takes the union and creates no conflict: 14 LR(1) states become 10.
The four pairs of LR(1) states of the assignment grammar that share a core (each box shows the item that names the state; the states of L -> * . R also hold closure items). Reached through the left side, before =, the look-aheads are = and $; after =, only $. Merging takes the union and creates no conflict: 14 LR(1) states become 10.
Baca dalam konteks →