全部书籍

专业

应用 关于 Coach 登录 开始阅读

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

Computer Science · 术语表

什么是 LR(1) item, LALR table?

又称: LR(1) item · LALR table

Definition 3.8 University Computer Science — Year 3 · 第 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.
在原文中阅读 →