Изменения

Перейти к: навигация, поиск

Алгоритм Эрли

182 байта убрано, 23:27, 14 мая 2019
Псевдокод: Исправил псевдокод
<font color=green>// Инициализация </font>
<tex> D_{0} = \lbrace [S' \rightarrow \cdot \ S, 0] \rbrace </tex>
'''for''' <tex>i = 1</tex> '''to''' <tex>len(w) - 1</tex>
<tex>D_i</tex> = <tex>\varnothing </tex>
<font color=green>// Вычисление ситуаций </font>
'''for''' <tex>j = 0</tex> '''to''' <tex>len(w) - 1</tex>
<tex>\mathtt{scan}(D, j, G, w)</tex>
'''while''' <tex>D_j</tex> изменяется
'''return''' ''false''
<font color=green>// Первое правило </font>
'''function''' <tex>\mathtt{scan}(D, j, G, w)</tex>:
'''if''' <tex>j</tex> == <tex>0</tex>
'''for''' <tex>[A \rightarrow \alpha \cdot a \beta, i] \in D_{j - 1} </tex>
'''if''' <tex>a</tex> == <tex>w_{j - 1}</tex>
<tex>D_{j}</tex> <tex> \cup</tex>= <tex>[A \rightarrow \alpha a \cdot a \beta, i]</tex> <font color=green>// Второе правило </font>
'''function''' <tex>\mathtt{complete}(D, j, G, w)</tex>:
'''for''' <tex>[B \rightarrow \eta \ \cdot, i] \in D_{j} </tex>
'''for''' <tex>[A \rightarrow \alpha \cdot B \beta, kj] \in D_{i} </tex> <tex>D_{j}</tex> <tex> \cup</tex>= <tex>[A \rightarrow \alpha B \cdot \beta, kj]</tex>
<font color=green>// Третье правило </font>
'''function''' <tex>\mathtt{predict}(D, j, G, w)</tex>:
'''for''' <tex>[A \rightarrow \alpha \cdot B \beta, i] \in D_{j} </tex>
390
правок

Навигация