[PL] Syntax Analysis : Ringsom Operator, LL Parsing Table

parkheeddongยท2023๋…„ 4์›” 18์ผ
0

Compiler / Programming Language

๋ชฉ๋ก ๋ณด๊ธฐ
14/32
post-thumbnail

1. Ringsom Operator

โœ”๏ธ If ๐œบ โˆ‰ A then A โŠ• B = A

โœ”๏ธ If ๐œบ โˆˆ A then A โŠ• B = (A - {๐œบ}) U B

Example

{a, b, c} โŠ• {c, d} = {a, b, c}
{a, b, c, ๐œบ} โŠ• {c, d} = {a, b, c, d}
{a, b, ๐œบ} โŠ• {c, d, ๐œบ} = {a, b, c, d,๐œบ}

2. Generate LL Parsing Table

Firstํ•จ์ˆ˜, Follow ํ•จ์ˆ˜์™€ Ringsom operator์„ ์ด์šฉํ•˜์—ฌ LOOKAHEAD'๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค.

LOOKAHEAD์— Production rule์„ ๋„ฃ๊ณ , First์™€ Follow ํ•จ์ˆ˜์˜ Ringsom Operator์„ ๊ณ„์‚ฐํ•˜์—ฌ Parsing Table์„ ๋งŒ๋“ ๋‹ค.

เน Calculate LOOKAHEAD

โฌ› S -> aBA|BB|ABc, A->dA|b, B-> ๐œบ
โฌ› FIRST(S) = {a,๐œบ,d,b}, FIRST(A) = {d,b}, FIRST(B) = {๐œบ}
โฌ› FOLLOW(S) = {$}, FOLLOW(A) = {c, $}, FOLLOW(B) = {c} U {d,b} = {c, d, b, $}

LOOKAHEAD(S -> aBA) = FIRST(aBA) โŠ• FOLLOW(S) = {a}

LOOKAHEAD(S -> BB) = FIRST(BB) โŠ• FOLLOW(S) = {$}

LOOKAHEAD(S -> ABc) = FIRST(ABc) โŠ• FOLLOW(S) = {d,b}

LOOKAHEAD(A -> dA) = FIRST(dA) โŠ• FOLLOW(A) = {d}

LOOKAHEAD(A -> b) = FIRST(b) โŠ• FOLLOW(A) = {b}

LOOKAHEAD(B -> ๐œบ) = FIRST(๐œบ) โŠ• FOLLOW(B) = {$, d, b, c}

0๊ฐœ์˜ ๋Œ“๊ธ€