Yanp

ahead集合の作成 🔗

1つのノードに対しhead集合を元に空規則が還元した後に続くhead集合を集約する。これをahead集合とする。
還元規則の判定にnullable集合を使用する。

start : . avoid bvoid
      | . avoid 'C'
      | . bvoid 'D'
      | . 'X'
avoid : . 'A'
      | .
bvoid : . 'B'
      | .

↓

avoidのahead集合は 'B'、'C' となる
bvoidのahead集合は 'D' となる

ahead集合の作成は次の疑似コードで表す。

reduceable = 空規則を抽出

foreach (look in 次の記号がreduceableに含まれる行)
    top = lookの左辺
    foreach (x in lookの次の要素から)
        if (xが終端記号)
            topのahead集合にxを追加
        else
            topのahead集合にtopのhead集合を追加
            if (xがnullable集合に含まれなければ) break