ÄÄÆÄÀÏ·¯ °ÀÇ
[°ÀDZ³Àç]
ÄÄÆÄÀÏ·¯ ÀÔ¹®, ¿À¼¼¸¸ Àú, Á¤ÀÍ»ç --- °ÀdzëÆ®
[Âü°íµµ¼]
- ÄÄÆÄÀÏ·¯ µðÀÚÀÎ: À̷аú ½ÇÁ¦, À¯°üÁ¾-À¯±â¿µ-Ȳ´ëÁØ, ÈñÁß´ç
- lex & yacc, J. R. Levine et. al, O'Reilly & Associates, Inc.
- Principles of Compiler Design, Aho and Ullman, Addison Wesley
- A Small C Compiler, J. E. Hendrix, M & T Publishing Inc.
- Machines, Languages, and Computation, Denning, Dennis and Qualitz, Prentice Hall
[½Ç½À ÇÁ·Î±×·¥]
1. °£´ÜÇÑ ¹®¹ý¿¡ ´ëÇÑ ¾ð¾îÀÎ½Ä ÇÁ·Î±×·¥
¿¹Á¦ ÇÁ·Î±×·¥ lrs0.c¸¦ ÂüÁ¶ÇÏ¿©
(1) getchar() ´ë½Å¿¡ ½ºÆ®¸µÀ» ¹®Àڹ迿¡ ÀÐ¾î¼ Ã³¸®Çϵµ·Ï ¼öÁ¤ÇϽÿÀ.
(2) 2ÀåÀÇ ¿¹8, ¿¹9, ¿¬½À¹®Á¦(2.5, 2.6, 2.8, 2.9)¿¡ ´ëÇÑ ¾ð¾îÀÎ½Ä ÇÁ·Î±×·¥À» ÀÛ¼ºÇϽÿÀ.
2. ÁÖ¾îÁø ¹®¹ý¿¡ ¸Â´Â ½ºÆ®¸µÀ» Ãâ·ÂÇÏ´Â ÇÁ·Î±×·¥
¿¹Á¦ ÇÁ·Î±×·¥ lgs0.c°ú ¼öÁ¤µÈ ½ÇÇàÆÄÀÏ lgs2.zip, µ¥ÀÌÅÍ ÆÄÀÏ grammar.txt¸¦ ÂüÁ¶ÇÏ¿©
<Âü°í> ÅؽºÆ® ÆÄÀÏÀ» saveÇÏ·Á¸é ¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ°¿¡¼ "Save Link As...(´Ù¸¥ À̸§À¸·Î ÀúÀå)"À» ¼±ÅÃ
(1) 2ÀåÀÇ ¿¹8, ¿¹9, ¿¬½À¹®Á¦(2.5, 2.6, 2.8, 2.9)ÀÇ ¹®¹ýµé¿¡ ´ëÇØ Å×½ºÆ®ÇϽÿÀ.
(2) ½ºÅÿ¡ µé¾îÀÖ´Â sentential form Áß¿¡¼ ±æÀÌ°¡ ªÀº °ÍºÎÅÍ
±ä ¼ø¼·Î ½ºÆ®¸µÀ» »ý¼ºÇϵµ·Ï ÇÁ·Î±×·¥À» ¼öÁ¤ÇϽÿÀ.
(3) ÇÔ¼ö expand()¿¡ Æ÷ÇԵǾî ÀÖ´Â ¹®¹ýÀ» µ¥ÀÌÅÍ ÆÄÀÏ¿¡¼ Àоî¼
ó¸®Çϵµ·Ï ¼öÁ¤ÇϽÿÀ.
(4) ƯÁ¤ ÀԷ½ºÆ®¸µÀ» ÀνÄÇÒ ¶§±îÁö ½ºÆ®¸µµéÀ» »ý¼ºÇϵµ·Ï ¼öÁ¤ÇϽÿÀ.
3. p.82 ¾Ë°í¸®Áò¿¡ ÀÇÇØ DFA¸¦ ÀνÄÇÏ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇϽÿÀ.
(¿¹Á¦ ÇÁ·Î±×·¥ dfa.c¸¦ ÂüÁ¶ÇÏ¿© ÀÔ·ÂÀ» getchar() ´ë½Å¿¡ ½ºÆ®¸µÀ» ÀÔ·ÂÇÏ´Â ¹æ¹ýÀ¸·Î ¼öÁ¤)
4. NFA¸¦ DFA·Î º¯È¯ÇÏ´Â ÇÁ·Î±×·¥(nfa2dfa.c)À» ÂüÁ¶ÇÏ¿© epsilon NFA¸¦ DFA·Î
º¯È¯ÇÏ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇϽÿÀ. [´ä] Enfa2dfa.c
5. DFAÀÇ »óżö¸¦ ÃÖ¼ÒÈÇÏ´Â ÇÁ·Î±×·¥(dfa-opt.c, ½ÇÇàÆÄÀÏ dfa-opt.exe)À» ÂüÁ¶ÇÏ¿©
»óżö Á¦¾àÀ» ¹ÞÁö¾Ê°í ó¸®µÉ ¼ö ÀÖµµ·Ï ¼öÁ¤ÇØ º¸½Ã¿À.
6. ¾î¶² DFA¿¡ ´ëÇØ inaccessible states¸¦ Á¦°ÅÇÏ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇϽÿÀ.
7. Á¤±ÔÇ¥Çö(Regular Expression), ¿¹: a*b + b*a,À» epsilon NFA·Î º¯È¯ÇÏ´Â ÇÁ·Î±×·¥À» ÀÛ¼ºÇϽÿÀ.
[±â¸»°úÁ¦ ÇÁ·Î±×·¥ ÁÖÁ¦]
¾Æ·¡ ÁÖÁ¦ Áß¿¡¼ 1°³¸¦ ¼±ÅÃÇÏ¿© Á¦¾È¼, Áß°£º¸°í¼, ÃÖÁ¾º¸°í¼ ÀÛ¼ºÇÏ¿© Á¦Ãâ
1. LEX ÇÁ·Î±×·¥ ÀÛ¼º
LEX »ç¿ë¹ý ¹× À§ 3-7¹ø ÇÁ·Î±×·¥À» Çϳª·Î ÅëÇÕÇÏ¿© Á¤±ÔÇ¥ÇöÀ¸·ÎºÎÅÍ DFA¸¦ ±¸ÇÏ´Â LEX ÇÁ·Î±×·¥À» ÀÛ¼º
(1) Á¤±ÔÇ¥Çö --> epsilon NFA
(2) epsilon NFA --> DFA
(3) DFA --> minimized DFA
(4) minimized DFA¿¡ ÀÇÇØ ÀԷ½ºÆ®¸µÀ» accept ¶Ç´Â reject ±â´É Ãß°¡
(5) 2Â÷¿ø ¹è¿·Î ÀúÀåµÈ minimized DFA¸¦ C source code·Î Ãâ·ÂÇÏ´Â ±â´É Ãß°¡
(6) LEX ÀԷ°ú À¯»çÇÑ ÇüÅ·ΠÀÔ·ÂÀ» ¹Þ¾Æ yylex() ÇÔ¼ö¸¦ »ý¼º
2. YACC ÇÁ·Î±×·¥ ÀÛ¼º
YACC »ç¿ë¹ý ¹× 6,7,8Àå ³»¿ëÀ» °øºÎÇÏ¿© ÆĽÌÇ¥¸¦ ¸¸µé¾î ÁÖ´Â ÇÁ·Î±×·¥ ÀÛ¼º
3. ÀÓÀÇÀÇ CFG¿¡ ´ëÇØ properÇÑ ¹®¹ýÀ¸·Î º¯È¯ÇÏ´Â ÇÁ·Î±×·¥ ÀÛ¼º
(1) non-terminating nonterminal°ú inaccessible symbol Á¦°Å
terminating nonterminal, accessible symbolÀ» ±¸ÇÑ´Ù.
(2) epsilon »ý¼º±ÔÄ¢ Á¦°Å
(3) ´ÜÀÏ »ý¼º±ÔÄ¢ Á¦°Å
(4) cycle-free ¹®¹ýÀ¸·Î º¯È¯
4. ÀڱⰡ ¼³°èÇÑ ¾ð¾î¿¡ ´ëÇÑ Compiler ±¸Çö
ÀڱⰡ ½º½º·Î ¼³°èÇÑ ¾ð¾î·Î ÀÛ¼ºÇÑ ÇÁ·Î±×·¥¿¡ ´ëÇØ ±â°è¾î(¾î¼Àºí¸®¾î) Äڵ带 »ý¼ºÇÏ´Â ÇÁ·Î±×·¥
(1) »õ·Î¿î ¾ð¾î ¼³°è
(2) lex¸¦ ÀÌ¿ëÇÏ¿© ¾îÈֺм®
(3) yacc¸¦ ÀÌ¿ëÇÏ¿© parsing(±¸¹®ºÐ¼®)
(4) ±¸¹®ºÐ¼® °á°ú¿¡ ´ëÇÑ ¾î¼Àºí¸®¾î ÄÚµå »ý¼º ¹× ½ÇÇà -- ½Ã½ºÅÛ ÇÁ·Î±×·¡¹Ö ½Ã°£¿¡ ¹è¿î ¾î¼Àºí¸®¾î ÄÚµå·Î »ý¼º ¹× ½ÇÇà
5. ÀÎÅÍ³Ý °Ë»ö¿£ÁøÀÇ ºÒ¸° ÁúÀǾ SQL¹®À¸·Î º¯È¯ÇÏ´Â ÇÁ·Î±×·¥
(1) ºÒ¸° ÁúÀǹ® Á¤ÀÇ
(2) lex ÀÌ¿ëÇÏ¿© ÁúÀǹ®¿¡ ´ëÇÑ ¾îÈֺм®
(3) yacc¸¦ ÀÌ¿ëÇÏ¿© parsing
(4) parsing °á°ú¿¡ ´ëÇØ SQL¹® »ý¼º
6. MFC¸¦ ÀÌ¿ëÇÏ¿© °£´ÜÇÑ ¿¡µðÅÍ ÇÁ·Î±×·¥ ÀÛ¼º(¾Æ·¡ ±â´ÉÀÌ Ãß°¡µÇ¾î¾ß ÇÔ)
(1) Á¤±ÔÇ¥ÇöÀ¸·Î ½ºÆ®¸µÀ» °Ë»öÇÏ´Â ±â´É
(2) °è»ê±â ±â´É -- LEX, YACC¸¦ ÀÌ¿ëÇÏ¿© ±¸ÇöÇØ¾ß ÇÔ
[±â¸»·¹Æ÷Æ®] ÁÖÁ¦ Áß¿¡¼ Çϳª¸¦ ¼±ÅÃÇÏ¿© Á¦¾È¼, Áß°£º¸°í¼, ±â¸»º¸°í¼ Á¦Ãâ
[¿¬½À¹®Á¦ Ç®ÀÌ]
Á¦2Àå -- ¹®¹ý °ü·Ã ¹®Á¦ Ç®ÀÌ
Á¦3Àå -- 3.1ºÎÅÍ 3.10±îÁö
Á¦4Àå -- lex ÀÔ·ÂÆÄÀÏ ÀÛ¼º
Lex¿Í Yacc
- Lex/Yacc »ç¿ë¹ý -- Lex_Yacc.htm, flex.pdf, lex.pdf
- Lex/Yacc examples --- ¿©±â ÂüÁ¶ (word count)
- Lex¿Í Yacc »ç¿ë¹ý Âü°í¼ --- À¯´Ð½º ÇÁ·Î±×·¡¹Ö ȯ°æ, Á¦8Àå, À̱âö-ǥâ¿ì ¿ª, »ý´ÉÃâÆÇ»ç
- PC¿ë lex¿Í yacc --- download ÀÎÅͳݿ¡¼ "pcyacc" ¶Ç´Â "pclex"¸¦ °Ë»ö
- Lex/Yacc »ç¿ë¹ýÀÌ ¾î·Æ´Ù°í ´À³¢¸é ÀÌ·¸°Ô Çغ¸¼¼¿ä.