262
 правки
Изменения
Нет описания правки
<code>
  Set<Item> closure(Set<Item> I):
      '''bool''' changed;      Set<Item> $J$=$I$;   
      '''repeat'''
          changed = '''false''';
          '''for''' $[A\rightarrow\alpha\cdot B\beta, a]\in I$
              '''for''' $(B\rightarrow\gamma)\in G'$
                  '''for''' $b\in FIRST(\beta\alpha)$
                      J.add($[B\rightarrow\cdot\gamma,b]$);
                      changed = '''true'''
      '''until''' not changed;      '''return''' J;
</code>
<code>
  Set<Item> goto(Set<Item> I, X):
      Set<Item> $J$=$\varnothing$;   
      '''for''' $[A\rightarrow\alpha\cdot X\beta, a]\in I$
          J.add($[A\rightarrow\alpha X\cdot\beta, a]$);      '''return''' $closure(J)$;
</code>
<code>
  Set<Set<Item>> items($G'$):
      '''bool''' changed;      Set<Set<Item>> $C$ = $\{closure({S'\rightarrow\cdot S,\char36})\}$;   
      '''repeat'''
          changed = '''false''';
          '''for''' Set<Item> $I\subset C$
              '''for''' $X \in symbols(G')$ <font color="green">//по всем символам грамматики</font>
                  '''if''' $goto(I,X)\neq\varnothing$ and $goto(I,X)\not\subset C$
                      C.add($goto(I,X)$);
                      changed = '''true'''
      '''until''' not changed;      '''return''' C;
</code>
</wikitex>
