enum Symbol {
asNonterminal: Nonterminal
asTerminal: Terminal
}
struct Item {
getLHS: Nonterminal
getLeft: ListOf Symbol
getRight: ListOf Symbol
}
canonical_collection: C0 := extern
states: ListOf (SetOf Item)
{
return (canonical_collection.states)
}
goto(state: State, symbol: Symbol): Maybe State
{
return (canonical_collection.goto(state, symbol))
}
goto'(state: State, sentential_form: ListOf Symbol): Maybe State
{
for (i: Int := 0; sentential_form[i] != Nil; i++)
{
state := goto(state, sentential_form[i])
if (state == Nothing)
break
}
return state
}
getPRED(state: State, sentential_form: ListOf Symbol): SetOf Symbol
{
result: SetOf Symbol := empty
for (state' in canonical_collection.states)
{
switch (goto'(state', sentential_form))
{
case (Just state''):
if (state == state'')
{
result := insert(result, state'')
}
break
case Nothing:
}
}
return result
}
getLA(state: State, item: Item): SetOf Terminal
{
if (state == state0 && item == Item { getLHS := s', getLeft := [], getRight := [asNonterminal s] })
{
return (singleton(EOF))
}
else
{
result: SetOf Terminal := empty
for (state' in getPRED(state, item.getLeft))
{
for (item' in state')
{
if (item'.getRight[0] == item.getLHS)
{
result := union(result, getFIRST(&item'.getRight[1]) <+> getLA(state', item'))
}
}
}
return result
}
}
아 드디어 답변이구나 고맙다. 곰곰히 생각해보면서 이해하도록 노력해야겠다
근데 이거 그대로 C로 바꾸면 무한루프 걸림 ㅋㅋ
알았어. 하튼 정말 고맙다. 이렇게 힘들게 의사코드로 알고리즘 올려준 거 정말 고마워
또 물어봐도 됨
다른 건 대충 이해가 되는데 singleton(EOF) 이건 무슨 뜻이야? 싱글러턴을 인터넷으로 찾아보니깐 무슨 뜻인지는 알겠는데 singleton하고 eof는 왜 같이 쓰인 거야
$만을 원소로 가지는 집합
아 그렇구나 답변 고마워
한가지만 더 물어볼께 sentential_form이 뭔지 좀 헷갈리는데 게다가 sentential_form이 배열로 사용되는데 왜 배열로 사용되는 거야?
앗 미안 리스트로 봐주라 - dc App
아 그래 답변 정말 고마워
문장형태는 기호들의 나열 - dc App
기호는 논터미널 또는 터미널 - dc App
자세한 답변 역시 감사
마지막으로 <+> 대체 무슨 뜻이야? 구글에서 검색해보니깐 하스켈 관련해서 영어자료 한 다만 나오는데 도무지 무슨 뜻인지 잘 모르겠
<+>
union(result, getFIRST(&item'.getRight[1]) <+> getLA(state', item'))<===<+> 이게 무슨 뜻이야?
getLA함수에서 union 안에 +왼쪽 오른쪽으로 크다 작다 기호(관계연산자)가 있자나 이 세 기호(크다,작다,+)가 뜻하는 바가 뭐야? 크롬 브라우저인데 크다 작다 관계연산자가 제대로 안 적어지는 거 같아서 글로 질문한다 무슨 말인지 이해가 됐을려나
http://m.dcinside.com/board/programming/1064696
- dc App