gperf
Utiltity»ç¿ëÀÚ¼³¸í¼
GNU GPERF Utilty »ç¿ëÀÚ¼³¸í¼ Douglas C. Schmidt ¸¶Áö¸· ¾÷µ¥ÀÌÆ®³¯Â¥: 1998³â 4¿ù14ÀÏ ¹öÀü2.7 Copyright (C) 1989-1998 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
section entitled "GNU gperf
General Public License" is included exactly as
in the original, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that the section entitled "GNU gperf
General Public License" may be
included in a translation approved by the author instead of in the original
English.
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
The precise terms and conditions for copying, distribution and modification follow.
NO WARRANTY
If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
one line to give the program's name and a brief idea of what it does. Copyright (C) 19yy name of author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
That's all there is to it!
gperf
°øÇåÀڵ鿡°Ôgperf
¿Ïº® Çؽà ÇÔ¼ö »ý¼º±â À¯Æ¿¸®Æ¼´Â ´õ±Û¶ó±× C. ½´¹ÌÆ®¾¾¿¡ ÀÇÇØ GNU C++·Î °³¹ßµÇ¾ú½À´Ï´Ù.
ÀÌ°ÍÀº ¶ÇÇÑ À̽ļºÀÌ ¸Å¿ì ÁÁÀº "¿¾ ½ºÅ¸ÀÏÀÇ" C ¹öÀü¿¡¼µµ À¯È¿ÇÕ´Ï´Ù. ¿Ïº® Çؽ¬ ÇÔ¼ö »ý¼º±â¸¦
À§ÇÑ ÀϹÝÀûÀÎ ¾ÆÀ̵ð¾î´Â 1984³â ÁîÀ½¿¡ C·Î ÀÛ¼ºµÈ Ä«À̾² º¸½ºÆ½ÀÇ ¾Ë°í¸®ÁòÀ¸·ÎºÎÅÍ ÈùÆ®¸¦ ¾ò¾ú°í
1984³â ÁîÀ½¿¡ net.sources¿¡ ¹èÆ÷µÇ¾ú½À´Ï´Ù. ÇöÀçÀÇ ÇÁ·Î±×·¥Àº Ä«À̾²ÀÇ ±âº» ¾ÆÀ̵ð¾îÀÇ Ä¿´Ù¶õ
¼öÁ¤°ú °È, È®ÀåÀÇ °á°ú¹°À̸ç, ¾îºóÀÇ Ä¶¸®Æ÷´Ï¾Æ ÁÖ¸³´ëÇп¡¼ ¸¸µé¾îÁ³½À´Ï´Ù. ¹ö±×³ª ÆÐÄ¡, Á¦¾È
˼ <bug-gnu-utils@gnu.org>
¿Í <schmidt@ics.uci.edu>
·Î ÇØ ÁֽʽÿÀ.
gpef
ÀÇ Áú°ú ±â´ÉÀ» Çâ»óÇϴµ¥ µµ¿òÀÌ µÈ ¸¹Àº ÆÁ°ú ¿µ°¨À»
Á¦°øÇÏ¿´½À´Ï´Ù.
gperf
´Â C++·Î ÀÛ¼ºµÈ ¿Ïº® Çؽà ÇÔ¼ö »ý¼º±âÀÔ´Ï´Ù. ±×°ÍÀº n°³ ¿ä¼ÒÀÇ »ç¿ëÀÚÁ¤ÀÇµÈ Å°¿öµå ¼Â W¸¦
¿Ïº® Çؽ¬ ÇÔ¼ö F·Î º¯È¯½Ãŵ´Ï´Ù. F´Â À¯´ÏÅ©ÇÏ°Ô W¾ÈÀÇ Å°¿öµåµéÀ» 0¿¡¼ k»çÀÌÀÇ ¹üÀ§¾È¿¡ ¸ÅÇÎ
½Ãŵ´Ï´Ù.k´Â nº¸´Ù Å©°Å³ª °°½À´Ï´Ù. ¸¸¾à k°¡ n°ú °°´Ù¸é F´Â ÃÖ¼ÒÀÇ ¿Ïº® Çؽà ÇÔ¼öÀÔ´Ï´Ù. gperf
´Â
0..k ¿ä¼Ò ½ºÅÂƽ ·è¾÷ Å×À̺í°ú CÇÔ¼öÀÇ Â¦À» »ý¼ºÇÕ´Ï´Ù.
ÀÌ ÇÔ¼öµéÀº ÁÖ¾îÁø ¹®ÀÚ¿ s°¡ W¾È¿¡ ¹ß°ßµÇ´ÂÁö, ·è¾÷ Å×À̺í¾ÈÀ¸·Î Àû¾îµµ ÇÑ°³ÀÇ ÇÁ·Îºê¸¦
»ç¿ëÇÏ¿© °áÁ¤ÇÕ´Ï´Ù.
ÇöÀç geprf
´Â GNU C, GNU C++, GNU Pascal, GNU Module 3, GNU indent¸¦ Æ÷ÇÔÇÏ´Â ¼ö°³ÀÇ Á¦Ç°°ú
¿¬±¸ÁßÀÎ ÄÄÆÄÀÏ·¯, ±×¸®°í ¾ð¾î ó¸® Åø¾ÈÀÇ »çÀü ºÐ¼®±â¸¦ À§ÇØ ¿¹ºñ Å°¿öµå Àνı⸦ »ý¼ºÇÕ´Ï´Ù.
geprf
ÀÇ ¿ÏÀüÇÑ C++ ¼Ò½º ÄÚµå´Â ics.uci.edu
¿Í ftp.santafe.edu
ÀÇ À͸í ftp ¸¦ ÅëÇØ ¾òÀ»¼ö ÀÖ½À´Ï´Ù.
gperf
´Â ¶ÇÇÑ ¼ö³âµ¿¾È GNU libg++ ¶óÀ̺귯¸®¿Í ÇÔ²² ¹èÆ÷µÇ¾ú½À´Ï´Ù. À̽ļºÀÌ ¶Ù¾î³ª°í µ¿ÀÏÇÑ
±â´ÉÀÇ gperf
K&R C ¹öÀüÀÌ comp.sources.unix¿¡ º¸°üµÇ¾î ÀÖ½À´Ï´Ù. ³¡À¸·Î, gperf
ÀÇ µðÀÚÀÎÀ»
¼³¸íÇÑ ¼³¸í¼¿Í ÀÚ¼¼È÷ ±â·ÏµÈ ½ÇÇ༰¡ Second USENIX C++ ÄÁÆÛ·±½º ÀÇ»ç·Ï¿¡ Æ÷ÇԵǾî ÀÖ½À´Ï´Ù.
gperf
½ºÅÂƽ °Ë»ö ±¸Á¶´Â ƯÁ¤ÇÑ ±âº» ¿ÀÆÛ·¹À̼Ç, Áï ÃʱâÈ,ÀԷ±׸®°í
Á¶È¸¸¦ °¡Áö´Â Àý´ë µ¥ÀÌŸ ŸÀÔÀÔ´Ï´Ù. °³³äÀûÀ¸·Î, ¸ðµç ÀÔ·ÂÀº Á¶È¸ÀÌÀü¿¡ ¹ß»ýÇÕ´Ï´Ù.
½ÇÁ¦·Î,gperf
´Â °Ë»ö ÁýÇÕ Å°¿öµåµéÀ» Æ÷ÇÔÇÏ´Â ½ºÅÂƽ
¾î·¹ÀÌ¿Í
»ç¿ëÀÚ¿¡ ÀÇÇØ °áÁ¤µÇ´Â ÀÓÀÇ·Î °ü°èµÇ´Â ¼Ó¼ºµéÀ» »ý¼ºÇÕ´Ï´Ù. ±×·¡¼ º»ÁúÀûÀ¸·Î ÀÔ·ÂÀ» À§ÇÑ
½ÇÇà ½Ã°£ °ªÀÌ ¾ø½À´Ï´Ù. ±×°ÍÀº ½ºÅÂƽ °Ë»ö ÁýÇÕÀÇ Ç¥ÇöÀ» À§ÇÑ À¯¿ëÇÑ µ¥ÀÌŸ ±¸Á¶ÀÔ´Ï´Ù.
½ºÅÂƽ °Ë»ö ÁýÇÕµéÀº ¼ÒÇÁÆ®¿þ¾î ½Ã½ºÅÛ ¾îÇø®ÄÉÀ̼Ǿȿ¡¼ ÀÚÁÖ ¹ß»ýÇÕ´Ï´Ù.
ÀϹÝÀûÀÎ ½ºÅÂƽ °Ë»ö ÁýÇÕµéÀº ÄÄÆÄÀÏ·¯ ¿¹¾à¾î, ¾î¼Àºí·¯ ÀÔ·Â opcode,±×¸®°í ³»Àå ½© ÀÎÅÍÇÁ¸®ÅÍ
¸í·É¾îµéÀ» Æ÷ÇÔÇÕ´Ï´Ù.
°Ë»ö ÁýÇÕ ¸â¹öµéÀº Å°¿öµå¶ó°í ºÒ¸®´Âµ¥, º¸Åë ÇÁ·Î±×·¥ÀÇ Ãʱâȵ¿¾È¿¡ ±¸Á¶¿¡ ´Ü Çѹø
ÀԷµǸç, ½ÇÇà½Ã¿¡ ÀϹÝÀûÀ¸·Î ¼öÁ¤µÇÁö ¾Ê½À´Ï´Ù.
¼öÀûÀÎ ½ºÅÂƽ °Ë»ö ±¸Á¶ÀÇ ±¸ÇöÀº ¾î·¹À̳ª, ¸µÅ©µÈ ¸®½ºÆ®, ¹ÙÀ̳ʸ® °Ë»ö ³ª¹«±¸Á¶,µðÁöÅÐ ±¸Á¶ ½Ãµµ, ±×¸®°í Çؽà Å×À̺í·Î Á¸ÀçÇÕ´Ï´Ù. °ø°£ À¯Æ¿¶óÀÌÁ¦À̼ǰú °Ë»ö ½Ã°£ È¿°ú»çÀÌ¿¡¼ ¼·Î ´Ù¸¥ ½Ãµµ´Â ±ÕÇüÀ» ÃëÇÒ°ÍÀ» Á¦°øÇÕ´Ï´Ù.¿¹¸¦ µé¾î, ¼ÒÆÃµÈ n°³ ¿¤·¹¸àÆ® ¾î·¹ÀÌ´Â °ø°£Àû À̵æÀÌ ÀÖ°í, ¹Ý¸é¿¡ ¹ÙÀ̳ʸ®°Ë»öÀ» ÀÌ¿ëÇÏ´Â °Ë»ö ¿ÀÆÛ·¹À̼ǿ¡ ´ëÇÑ Æò±Õ ÄÉÀ̽º ½Ã°£ º¹Àâµµ´Â ·Î±× n¿¡ ºñ·ÊÇÕ´Ï´Ù. ¿ªÀ¸·Î, Çؽà Å×ÀÌºí ±¸ÇöÀº ÀÚÁÖ ÀÏÁ¤ÇÑ ½Ã°£³»¿¡ Å×ÀÌºí ¿£Æ®¸®¸¦ À§Ä¡½ÃÅ°Áö¸¸, ÀϹÝÀûÀ¸·Î ¿©ºÐÀÇ ¸Þ¸ð¸®¸¦ ´õ Áö¿ì¸ç, ´õ ³ª»Û ÄÉÀ̽º ¼º´ÉÀ» º¸ÀÔ´Ï´Ù.
ÃÖ¼Ò ¿Ïº® Çؽà Æã¼ÇÀº ½ºÅÂƽ °Ë»ö ÁýÇÕÀÇ Æ¯º°ÇÑ °æ¿ì¿¡ ´ëÇØ ÃÖ»óÀÇ ¼Ö·ç¼ÇÀ» Á¦°øÇÕ´Ï´Ù. ÃÖ¼Ò ¿Ïº® Çؽà Æã¼ÇÀº µÎ °¡ÁöÀÇ Æ¯Â¡À¸·Î Á¤Àǵ˴ϴÙ:
´ëºÎºÐÀÇ ¾îÇø®ÄÉÀ̼ǿ¡ ´ëÇؼ ÃÖ¼Ò ¿Ïº®Çؽà Æã¼Çµéº¸´Ù ¿Ïº®Çؽà Æã¼ÇµéÀ»
¸¸µé¾î³»´Â °ÍÀÌ ´õ ½±½À´Ï´Ù.´õ ³ª¾Æ°¡, ½ÇÁ¦ ¹®Á¦¿¡¼ ÃÖ¼Ò°¡ ¾Æ´Ñ ¿Ïº® Çؽà Æã¼ÇÀº ÀÚÁÖ ÃÖ¼ÒÀÇ °Íº¸´Ù
´õ »¡¸® ½ÇÇàµË´Ï´Ù. ÀÌ Çö»óÀº µå¹® Å°¿öµå Å×À̺íÀ» ã´Â °ÍÀÌ "³Î" ¿£Æ®¸®¸¦ À§Ä¡½ÃÅ°´Â °¡´É¼ºÀ»
Áõ»ç½ÃÅ°¸ç, µû¶ó¼ ¹®ÀÚ¿ ºñ±³¸¦ °¨¼Ò½ÃÅ°±â ¶§¹®ÀÔ´Ï´Ù.gperf
ÀÇ µðÆúÆ® ÇൿÀº Å°¿öµå
ÁýÇյ鿡 ´ëÇؼ ÃÖ¼Ò¿¡ °¡±î¿î ¿Ïº® Çؽà Æã¼ÇÀ» »ý¼ºÇÕ´Ï´Ù.±×·¯³ª, gperf
´Â
ÃÖ¼Ò¼º°ú ¿Ïº®¼ºÀÇ µî±ÞÀ» ³Ñ¾î »ç¿ëÀÚÀÇ Á¶ÀýÀ» Çã¶ôÇÏ´Â ¸¹Àº ¿É¼ÇÀ» Á¦°øÇÕ´Ï´Ù.
½ºÅÂƽ °Ë»ö ÁýÇÕµéÀº Á¾Á¾ ±ä ½Ã°£µ¿¾È ºñ±³Àû ¾ÈÁ¤¼ºÀ» º¸¿©ÁÝ´Ï´Ù. ¿¹¸¦ µé¾î, ¾Æ´ÙÀÇ 63°³ÀÇ
¿¹¾à¾î´Â °ÅÀÇ 10³âµ¿¾È ÀÏÁ¤ÇÏ°Ô ³²¾Æ ÀÖ½À´Ï.
µû¶ó¼ ¸¸¾à ±× °á°ú·Î¼ ¸Å¿ì ¸¹Àº Ƚ¼ö·Î¼ »ç¿ëµÇ¾îÁø´Ù¸é ÇѹøÃÖÀûÀÇ
°Ë»ö ±¸Á¶¸¦ ¸¸µé¾î°¡´Â ÇÕÀÇµÈ ³ë·Â¸¦ È®Àå½ÃÅ°´Â °ÍÀº ÀÚÁÖ ÇÒ¸¸ÇÑ °¡Ä¡°¡ ÀÖ´Â ÀÏÀÔ´Ï´Ù.gperf
´Â ¼ÕÀ¸·Î ½Ã°ø°£ÀÇ À¯È¿ÇÑ °Ë»ö ±¸Á¶¸¦ ¸¸µé¾î³»´Â°Í°ú °ü·ÃµÇ´Â ´ÜÁ¶·Ó°í °íµÈ ÀÛ¾÷À» ¾ø¾ÖÁÝ´Ï´Ù. ÀÌ°ÍÀº Áß¿äÇÑ ÇÁ·Î±×·¡¹Ö ÇÁ·ÎÁ§Æ®¿¡ ´ëÇؼ À¯È¿ÇÏ°í ½ÇÁ¦ÀûÀÎ µµ±¸¶ó°í Áõ¸íÀÌ µÇ¾ú½À´Ï´Ù. gpef
·ÎºÎÅÍÀÇ °á°ú´Â ÀϹÝÀûÀ¸·Î GNU C, GNU C++, GNU Pascal ±×¸®°í GNU Modula 3¸¦ Æ÷ÇÔÇÏ¿© ¼ö°³ÀÇ Á¦Ç°°ú ¿¬±¸¿ë ÄÄÆÄÀÏ·¯¿¡ »ç¿ëµË´Ï´Ù. ÈÄÀÚÀÇ µÎ°³ÀÇ ÄÄÆÄÀÏ·¯´Â ¾ÆÁ÷ °ø½ÄÀûÀÎ GNU ¹èÆ÷º»ÀÇ ÀϺδ ¾Æ´Õ´Ï´Ù. °¢°¢ÀÇ ÄÄÆÄÀÏ·¯´Â gperf
¸¦ È¿°úÀûÀ¸·Î °¢ÀÚÀÇ ¿¹¾à¾î¸¦ È®ÀÎÇÏ´Â ½ºÅÂƽ °Ë»ö ±¸Á¶µéÀ» ÀÚµ¿ÀûÀ¸·Î »ý¼ºÇϴµ¥¿¡ ÀÌ¿ëÇÕ´Ï´Ù.
gperf
ÀÇ °í·¹º§ ¼¼ú
¿Ïº® Çؽà Æã¼Ç »ý¼º±â geprf
´Â Å°ÆÄÀÏ(¶Ç´Â µðÆúÆ®·Î Ç¥ÁØ ÀÔ·ÂÀ¸·ÎºÎÅÍ)·ÎºÎÅÍ Å°¿öµåÀÇ ÁýÇÕÀ» ÀнÀ´Ï´Ù.
±×°ÍÀº ·è¾÷ Å×À̺í·ÎÀÇ Àû¾îµµ ÇÑ°³ÀÇ ÇÁ·Îºê¸¦ °¡Áö´Â ½ºÅÂƽ Å°¿öµå ÁýÇÕÀÇ ¸â¹ö¸¦ ÀÎÁöÇÏ´Â ¿Ïº® Çؽà Æã¼Ç¸¦ ²ø¾î³»´Â ½Ãµµ¸¦ ÇÕ´Ï´Ù. ¸¸¾à gperf
°¡ ±×·¯ÇÑ Æã¼ÇÀ» »ý¼ºÇϴµ¥¿¡ ¼º°øÇÏ¸é ±×°ÍÀº Çؽ̰ú Å×ÀÌºí ·è¾÷ ÀνÄÀ» ¼öÇàÇÏ´Â C ¼Ò½º ÄÚµå ·çƾ ½ÖÀ» ¸¸µé¾î³À´Ï´Ù. ¸ðµç »ý¼ºµÈ C ÄÚµå´Â Ç¥ÁØ Ãâ·ÂÀ¸·Î ¹æÇâÁö¾îÁý´Ï´Ù. ¾Æ·¡¿¡ Ç¥»çµÈ ¸í·ÉÇà ¿É¼ÇÀº gperf
·ÎÀÇ ÀԷ°ú Ãâ·Â Çü½ÄÀ» °íÄ¡´Â °ÍÀ» °¡´ÉÇÏ°Ô ÇÕ´Ï´Ù.
µðÆúÆ®·Î, gperf
´Â È¿°úÀûÀÎ °ø°£ ÀÌ¿ë¿¡¼ ´ú °Á¶µÈ ½Ã°£È¿À² Äڵ带 »ý¼ºÇÏ·Á°í ½ÃµµÇÕ´Ï´Ù. ±×·¯³ª, °ø°£ÀÇ ÀúÀåÀ» À§ÇØ ½ÇÇà½Ã°£À» ±³È¯À» Çã¶ôÇϰųª ¶Ç´Â ¿ªÀ¸·ÎÀÇ Çã¶ô¸¦ À§ÇØ ¼ö°³ÀÇ ¿É¼ÇÀÌ Á¸ÀçÇÕ´Ï´Ù.
Ưº°È÷, ÀϹÝÀûÀ¸·Î ´õ ºü¸¥ °Ë»öÀ» ¾çº¸ÇÏ¿©, »ý¼ºµÈ Å×À̺í Å©±âÀÇ È®ÀåÀº Èñ¹ÚÇÑ °Ë»ö ±¸Á¶¸¦ ¸¸µé¾î³À´Ï´Ù. ¿ªÀ¸·Î, gperf
¸¦ µ¥ÀÌŸ °ø°£ ÀúÀå »çÀÌÁ ÃÖ¼ÒÈÇÏ´Â C ½ºÀÄ¡
±¸¹® ¹æ¹ý¿¡ Á÷Á¢ÀûÀ¸·Î »ç¿ëÇÒ¼öµµ ÀÖ½À´Ï´Ù. ´õ ³ª¾Æ°¡¼, C ½ºÀÄ¡
ÀÇ »ç¿ëÀº ½ÇÁ¦ÀûÀ¸·Î ¾î´ÀÁ¤µµ ½Ã°£À» ¹úÃæÇÏ¿© Å°¿öµåÀÇ ¼Óµµ¸¦ ³ôÀϼöµµ ÀÖ½À´Ï´Ù. ½ÇÁ¦ÀÇ °á°ú´Â ¹°·Ð C ÄÄÆÄÀÏ·¯¿¡ ÀÇÁ¸ÇÕ´Ï´Ù.
ÀϹÝÀûÀ¸·Î, gperf
´Â ¹®ÀÚ¿¡ °ªÀ» ÁöÁ¤ÇÕ´Ï´Ù. ±×°ÍÀº ¸î°³ÀÇ °ªÀÇ ÁýÇÕÀÌ °¢°¢ÀÇ Å°¿öµå¿¡ À¯ÀÏÇÑ °ªÀ» ÁÖ±âÀü±îÁö ÇؽÌÀ» À§ÇØ »ç¿ëµË´Ï´Ù.
È¿°úÀûÀÎ ¹ß°ßÀû ÇÁ·Î±×·¥Àº Çؽà °ªÀÇ ¹üÀ§°¡ Ä¿Áú¼ö·Ï, gperf
°¡ ¿Ïº® Çؽà Æã¼Ç¸¦ ¹ß°ßÇÏ°í ¸¸µé¾î³»´Â °ÍÀÌ ½¬¾îÁý´Ï´Ù. ½ÇÇèÀº gperf
·ÎºÎÅÍ ´ëºÎºÐÀ» ¾ò¾î³»´Â ÇÙ½ÉÀÔ´Ï´Ù.
gperf
·ÎÀÇ ÀÔ·Â Çü½Ä
Ưº°È÷ `-t' ¿É¼Ç, Áï ¾î¶² ¸í·ÉÇà ¾Æ±Ô¸ÕÆ®¸¦ º¯È¯½ÃÅ´À¸·Î ÀÔ·Â Å°ÆÄÀÏ Çü½ÄÀ» Á¶ÀýÇÒ¼ö ÀÖ½À´Ï´Ù. ÀÔ·Â ÇüÅ´ GNU À¯Æ¿¸®Æ¼ flex
¿Í bison
(¶Ç´Â UNIX À¯Æ¿¸®Æ¼ lex
¿Í yacc
)°ú ºñ½ÁÇÕ´Ï´Ù. ´ÙÀ½Àº ÀϹÝÀûÀÎ Çü½ÄÀÇ °³·«ÀûÀÎ ¸ð½ÀÀÔ´Ï´Ù:
declarations %% keywords %% functions
flex
³ª bison
°ú Ʋ¸®°Ô, gperf
ÀÔ·ÂÀÇ ¸ðµç ¼½¼ÇµéÀº ¿É¼ÇÀ¸·Î µÇ¾î ÀÖ½À´Ï´Ù. ´ÙÀ½ Àýµé¿¡¼ °¢°¢ÀÇ ¼½¼Ç¿¡ ´ëÇÑ ÀÔ·Â Çü½ÄÀ» ±â¼úÇÕ´Ï´Ù.
½ºÆ®·°Æ®(struct)
¼±¾ð°ú C code Æ÷ÇÔ(Inclusion)
Å°¿öµå ÀÔ·Â ÆÄÀÏÀº ¼±ÅÃÀûÀ¸·Î »ç¿ëÀÚ-°ø±ÞÀ» ÁغñÇϱâ À§ÇÑ Á¶Ç×»Ó¸¸ ¾Æ´Ï¶ó ÀÓÀÇÀÇ C ¼±¾ðµé°ú Á¤ÀǵéÀ» Æ÷ÇÔÇϱâ À§ÇÑ ¼½¼ÇÀ» Æ÷ÇÔÇÕ´Ï´Ù. ¸¸¾à `-t' ¿É¼ÇÀÌ È°¼ºÈµÇ¸é, ¹Ýµå½Ã Å°ÆÄÀÏ ÆÄÀϷκÎÅÍÀÇ ¼±¾ðºÎ¾È¿¡ ¸¶Áö¸· ÄÄÆ÷³ÍÆ®·Î¼ C ½ºÆ®·°Æ®
°¡ Á¦°øµÇ¾î¾ß ÇÕ´Ï´Ù. ÀÌ ½ºÆ®·°Æ®¾ÈÀÇ Ã¹¹ø° Çʵå(field)´Â ÀÌ ÇʵåÀÇ À̸§ÀÌ ¾Æ·¡¿¡ ±â¼úµÈ `-K' ¿É¼ÇÀ¸·Î ¼öÁ¤ÇÏ´Â °ÍÀÌ °¡´ÉÇÔ¿¡µµ ºÒ±¸ÇÏ°í `³×ÀÓ(name)'À̶ó°í ºÒ¸®´Â char *
½Äº°ÀÚ°¡ µÇ¾î¾ß ÇÕ´Ï´Ù.
´ÙÀ½¿¡ ÀÔ·ÂÀ¸·Î½á ³âµµÀÇ ´Þ(month)°ú ±×°ÍµéÀÇ ¼Ó¼ºÀ» »ç¿ëÇÑ °£´ÜÇÑ ¿¹°¡ ÀÖ½À´Ï´Ù:
struct months { char *name; int number; int days; int leap_days; }; %% january, 1, 31, 31 february, 2, 28, 29 march, 3, 31, 31 april, 4, 30, 30 may, 5, 31, 31 june, 6, 30, 30 july, 7, 31, 31 august, 8, 31, 31 september, 9, 30, 30 october, 10, 31, 31 november, 11, 30, 30 december, 12, 31, 31
Å°¿öµåµéÀÇ ¸®½ºÆ®¿Í ´Ù¸¥ Çʵå·ÎºÎÅÍÀÇ ½ºÆ®·°Æ®
¼±¾ðÀÇ ºÐ¸®°¡ ¿¬¼ÓµÈ ÆÛ¼¾Æ® ±âÈ£ÀÇ ½Ö %%
À̸ç, À¯´Ð½º À¯Æ¿¸®Æ¼ lex
ó·³ ù¹ø° Ä÷³ÀÇ ¿ÞÆí¿¡ ³ªÅ¸³ªÀÖ½À´Ï´Ù.
GNU À¯Æ¿¸®Æ¼ flex
¿Í bison
°ú ºñ½ÁÇÑ ¹®¹ýÀ» »ç¿ëÇÏ¿©,
»ý¼ºµÈ Ãâ·Â ÆÄÀÏ·Î C ¼Ò½º ÅؽºÆ®¿Í Ãà¾îÀûÀÎ ÄÚ¸àÆ®¸¦ Á÷Á¢ÀûÀ¸·Î Æ÷ÇÔÇÏ´Â °ÍÀÌ °¡´ÉÇÏ´Ù. ÀÌ°ÍÀº ¸®Àü(region) ÀλçÀ̵带 left-justifedµÈ ¼¶ó¿îµù(surrounding)%{
,%}
½ÖÀ¸·Î µÑ·¯½Î´Â °ÍÀ¸·Î ¼ºÃëµË´Ï´Ù. ´ÙÀ½¿¡ ÀÌ·¯ÇÑ Æ¯Â¡À» ÀÏ·¯½ºÆ®ÇÑ ¾Õ¼ÀÇ ¿¹Á¦¿¡ ±âÃÊÇÑ ÀÔ·Â ÇÁ·¹±×¸ÕÆ®(fragment)°¡ ÀÖ½À´Ï´Ù:
%{ #include <assert.h> /* ÀÌ Äڵ弽¼ÇÀº Ãâ·ÂÀ¸·Î °ð¹Ù·Î »ðÀԵ˴ϴÙ.*/ int return_month_days (struct months *months, int is_leap_year); %} struct months { char *name; int number; int days; int leap_days; }; %% january, 1, 31, 31 february, 2, 28, 29 march, 3, 31, 31 ...
ÀüüÀûÀ¸·Î ¼±¾ðºÎ¸¦ »ý·«Çϴ°ÍÀÌ °¡´ÉÇÕ´Ï´Ù. ÀÌ·¯ÇÑ °æ¿ì Å°ÆÄÀÏÀº ù¹ø° Å°¿öµå ¶óÀÎÀ¸·Î °ð¹Ù·Î ½ÃÀÛÇÕ´Ï´Ù. Áï:
january, 1, 31, 31 february, 2, 28, 29 march, 3, 31, 31 april, 4, 30, 30 ...
µÎ¹ø° Å°ÆÄÀÏ Æ÷¸Ë ¼½¼ÇÀº Å°¿öµåµéÀÇ ¶óÀεé°ú Á¦°øµÉ¼öµµ ÀÖ´Â ÀÓÀÇÀÇ °ü·ÃµÈ ¼Ó¼ºµéÀ» Æ÷ÇÔÇÏ°í ÀÖ½À´Ï´Ù. ù¹ø° Ä÷³¿¡¼ `#'À¸·Î ½ÃÀ۵Ǵ ¶óÀÎÀº ÁÖ¼®À¸·Î ¿©°ÜÁý´Ï´Ù. `#'´ÙÀ½¿¡ µÚµû¸£´Â ¸ðµç °ÍµéÀº ±×°ÍºÎÅÍ ´ÙÀ½ÀÇ »õ·Î¿î ÇàÀ» Æ÷ÇÔÇÏ¿© ¹«½ÃµË´Ï´Ù.
ÁÖ¼®¹®ÀÌ ¾Æ´Ñ ¶óÀÎÀÇ Ã¹¹ø° Çʵå´Â Ç×»ó Å° ±× ÀÚ½ÅÀÔ´Ï´Ù. ±×°ÍÀº °£´ÜÇÑ ¸íĪÀ¸·Î ÁÖ¾îÁ®¾ß Çϴµ¥, Áï ÀοëºÎÈ£·Î µÑ·¯½×À̰ųª ù¹ø° Ä÷³¿¡ ¹ÝÇÏ¿© left-justified flushµÇ´Â °ÍÀÌ ¾ø¾î¾ß ÇÕ´Ï´Ù. ÀÌ ¹®¸Æ¿¡¼, "Çʵå"´Â ó¹ø° ºóÄ, ¶Ç´Â Äĸ¶, ȤÀº »õ·Î¿î¶óÀαîÁö È®ÀåµÇÁö¸¸ ±×°ÍµéÀ» Æ÷ÇÔÇÏÁö´Â ¾Ê´Â°ÍÀ¸·Î ¿©°ÜÁý´Ï´Ù. ¿©±â¿¡ C ¿¹¾à¾îÀÇ ºÎºÐ ¸®½ºÆ®·ÎºÎÅÍ ¹ßÃéµÈ °£´ÜÇÑ ¿¹°¡ ÀÖ½À´Ï´Ù.
# À̰͵éÀº C ¿¹¾à¾îÀÔ´Ï´Ù. ANSI C ¿¹¾à¾îÀÇ ¿ÏÀüÇÑ ¸®½ºÆ®µéÀ» À§ÇØ
# c.gperf
ÆÄÀÏÀ» º¸½Ê½Ã¿À.
unsigned
sizeof
switch
signed
if
default
for
while
return
µ¡ºÙ¿©Áø ÇʵåµéÀº ¼±ÅÃÀûÀ¸·Î ¼±µµ Å°¿öµå¸¦ µû¶ó°¥¼öµµ ÀÖ½À´Ï´Ù. ÇʵåµéÀº
Äĸ¶·Î ±¸º°µÇ¾îÁ®¾ß Çϸç, ¶óÀÎÀÇ ³¡¿¡¼ ³¡³»¾ß ÇÕ´Ï´Ù. ÀÌ·¯ÇÑ ÇʵåµéÀÌ ÀǹÌÇÏ´Â °ÍÀº ÀüÀûÀ¸·Î ´ç½Å¿¡°Ô ´Þ·Á ÀÖ½À´Ï´Ù;±×°ÍµéÀº ¼±¾ðºÎ¿¡¼ ´ç½Å¿¡ ÀÇÇØ Á¦°øµÇ´Â »ç¿ëÀÚÁ¤ÀǵÈ
¿É¼ÇÀÎ ¼¼¹ø° ¼½¼ÇÀº ¶ÇÇÑ
¸î°³ÀÇ C Äڵ带 »ý¼ºÇÏ´Â ¹æ¹ýÀ» Á¶ÀýÇÏ´Â ¿É¼ÇµéÀÌ Ç¥ÁØ Ãâ·Â¿¡ ³ªÅ¸³ª ÀÖ½À´Ï´Ù. µÎ°³ÀÇ C ÇÔ¼ö°¡ »ý¼ºµË´Ï´Ù.
´ç½ÅÀÌ Ä¿¸Çµå ¶óÀÎ ¿É¼ÇÀ» ÀÌ¿ëÇÏ¿©
µðÆúÆ®·Î, »ý¼ºµÈ
µÎ°³ÀÇ ¿É¼Ç `-g'(´ç½ÅÀÌ GNU C¿Í ±×°ÍÀÇ
¸¸¾à `-t'¿Í `-s'¿É¼ÇÀÌ »ý·«µÈ´Ù¸é, µðÆúÆ® ¾×¼ÇÀº Å°¸¦ Æ÷ÇÔÇÏ´Â
´ÙÀ½Àº
´õ ¼Ó¼ÓµéÀÌ µé¾î³»´Â Á¢±ÙÀ» °¡Áö°í ÇöÀçÀÇ ¿Ïº® Çؽà ÇÔ¼ö ¾Ë°í¸®ÁòÀ» ±³Ã¼ÇÏ´Â "ºñ±³Àû"½¬¿î ¹æ¹ýÀÌ ÀÖ¾î¾ß ÇÕ´Ï´Ù;¿Ïº® Çؽà ÇÔ¼ö ¸ðµâÀº ´Ù¸¥ ÇÁ·Î±×·¥ ¸ðµâ
¿¡ ´ëÇØ º»ÁúÀûÀ¸·Î µ¶¸³ÀûÀÔ´Ï´Ù. Ãß°¡ÀûÀÎ °¡Ä¡ÀÖ´Â Çâ»óÀÌ Æ÷ÇԵǾî ÀÖ½À´Ï´Ù:
[1] Chang, C.C.: A Scheme for Constructing Ordered Minimal Perfect
Hashing Functions Information Sciences 39(1986), 187-195.
[2] Cichelli, Richard J. Author's Response to "On Cichelli's Minimal Perfect Hash
Functions Method" Communications of the ACM, 23, 12(December 1980), 729.
[3] Cichelli, Richard J. Minimal Perfect Hash Functions Made Simple
Communications of the ACM, 23, 1(January 1980), 17-19.
[4] Cook, C. R. and Oldehoeft, R.R. A Letter Oriented Minimal
Perfect Hashing Function SIGPLAN Notices, 17, 9(September 1982), 18-27.
[5] Cormack, G. V. and Horspool, R. N. S. and Kaiserwerth, M.
Practical Perfect Hashing Computer Journal, 28, 1(January 1985), 54-58.
[6] Jaeschke, G. Reciprocal Hashing: A Method for Generating Minimal
Perfect Hashing Functions Communications of the ACM, 24, 12(December
1981), 829-833.
[7] Jaeschke, G. and Osterburg, G. On Cichelli's Minimal Perfect
Hash Functions Method Communications of the ACM, 23, 12(December 1980),
728-729.
[8] Sager, Thomas J. A Polynomial Time Generator for Minimal Perfect
Hash Functions Communications of the ACM, 28, 5(December 1985), 523-532
[9] Schmidt, Douglas C. GPERF: A Perfect Hash Function Generator
Second USENIX C++ Conference Proceedings, April 1990.
[10] Sebesta, R.W. and Taylor, M.A. Minimal Perfect Hash Functions
for Reserved Word Lists SIGPLAN Notices, 20, 12(September 1985), 47-53.
[11] Sprugnoli, R. Perfect Hashing Functions: A Single Probe
Retrieving Method for Static Sets Communications of the ACM, 20
11(November 1977), 841-850.
[12] Stallman, Richard M. Using and Porting GNU CC Free Software Foundation,
1988.
[13] Stroustrup, Bjarne The C++ Programming Language. Addison-Wesley, 1986.
[14] Tiemann, Michael D. User's Guide to GNU C++ Free Software
Foundation, 1989.
This document was generated on 25 June 2001 using
texi2html 1.56k.
flex
³ª bison
¿Í´Â ´Þ¸® ù¹ø° %%
Ç¥½Ã´Â ¸¸¾à ¼±¾ðºÎ°¡ ºñ¾îÀÖ´Ù¸é »ý·«µÉ¼öµµ ÀÖ´Ù´Â °ÍÀ» ÁÖÀÇÇϽʽÿÀ.
½ºÆ®·°Æ®
ÀÇ ¿ä¼ÒµéÀ» ÃʱâÈȴµ¥ »ç¿ëµË´Ï´Ù. ¸¸¾à `-t'¿É¼ÇÀÌ È°¼ºÈµÇÁö ¾Ê´Â´Ù¸é ÀÌ·¯ÇÑ ÇʵåµéÀº ´Ü¼øÈ÷ ¹«½ÃµË´Ï´Ù. ¸¶Áö¸· °ÍÀ» Á¦¿ÜÇÑ ¸ðµç ¾ÕÀÇ ¿¹Á¦µéÀº Å°¿öµå ¼Ó¼ºµéÀ» Æ÷ÇÔÇÕ´Ï´Ù.
Æ÷ÇԵǾî ÀÖ´Â Ãß°¡ÀûÀÎ CÇÔ¼öµé
flex
¿Í bison
¾È¿¡¼ ¹ß°ßµÇ¾îÁö´Â Çù¾à°ú ¸Å¿ì ¹ÐÁ¢ÇÏ°Ô ´ëÀÀÇÏ°í ÀÖ½À´Ï´Ù.
ÀÌ ¼½¼Ç¾ÈÀÇ ¸ðµç ÅؽºÆ®´Â ¸¶Áö¸· %%
¿¡¼ ½ÃÀÛÇÏ¿© ÀÔ·Â ÆÄÀÏÀÇ ³¡±îÁö È®ÀåµÇ¾îÁö´Âµ¥,»ý¼ºµÇ¾îÁö´Â Ãâ·Â ÆÄÀϾȿ¡
¸» ±×´ë·Î Æ÷ÇԵǾî ÀÖ½À´Ï´Ù. ´ç¿¬È÷, ÀÌ ¼½¼Ç¾È¿¡ ´ã°ÜÁ® ÀÖ´Â Äڵ尡 Á¤´çÇÑ C¶ó´Â °ÍÀ» È®½ÅÇÏ´Â °ÍÀº ´ç½ÅÀÇ Ã¥ÀÓÀÔ´Ï´Ù.
gperf
¸¦ ÀÌ¿ëÇÏ¿© »ý¼ºµÇ´Â C ÄÚµåÀÇ Ãâ·Â Æ÷¸Ëin_word_set
¸¦ À§ÇÑ À̸§À» ¼öÁ¤ÇÑ´Ù ÇÏ´õ¶óµµ ±×°ÍµéÀº
hash
¿Í in_word_set
¶ó ºÒ¸³´Ï´Ù. µÎ°³ÀÇ ÇÔ¼öµå´Â µÎ°³ÀÇ ¾Æ±Ô¸ÕÆ®¸¦ ¿ä±¸Çϴµ¥, ½ºÆ®¸µÀÎ
char *
str¿Í ±æÀÌ(length) ÆĶó¹ÌÅÍÀÎ int
lenÀÔ´Ï´Ù. ±×°ÍµéÀÇ
µðÆúÆ® ÇÔ¼ö ÇÁ·ÎÅäŸÀÔÀº ´ÙÀ½°ú °°½À´Ï´Ù:
static int hash (char *str, int len);
int in_word_set (char *str, int len);
hash
ÇÔ¼ö´Â lenÀ» ¼ö°³ÀÇ »ç¿ëÀÚÁ¤ÀÇµÈ Áö¿ªÀû ½ºÅÂƽ ¾î·¹À̾ȿ¡ ÀúÀåµÈ
Á¶ÇÕµÈ(associated) °ª Å×À̺í¾ÈÀ¸·Î À妽ºµÈ str Å° Æ÷Áö¼Ç¿¡ ´õÇÔÀ¸·Î½á »ý¼ºµÈ Á¤¼ö°ªÀ» µ¹·ÁÁÝ´Ï´Ù.
Á¶ÇÕµÈ °ª Å×À̺íÀº ³»ºÎÀûÀ¸·Î gperf
¿¡ ÀÇÇؼ Çü¼ºµÇ¾îÁö¸ç ÀÌÈÄ hash_tableÀ̶ó ºÒ¸®´Â
½ºÅÂƽ Áö¿ª C ¾î·¹À̷μ Ãâ·ÂµË´Ï´Ù; ±× ÀÇ¹Ì¿Í Æ¯¼ºÀº ¾Æ·¡ºÎºÐ¿¡ ¹¦»çµÇ¾î ÀÖ½À´Ï´Ù.
GNU gperf
ÀÇ ±¸Çö »ó¼¼µµ ¼½¼ÇÀ» º¸½Ê½Ã¿À. °ü·ÃµÈ Å° À§Ä¡µéÀº gperf
°¡
½ÇÇàµÉ¶§ `-k' ¿É¼Ç¿¡ ÀÇÇÏ¿© °áÁ¤µÇ´Âµ¥, ¾Æ·¡ÂÊÀÇ ¿É¼Çµé¼½¼Ç¿¡ ÀÚ¼¼È÷ ³ª¿Í ÀÖ½À´Ï´Ù.
gperf
À¯Æ¿¸®Æ¼¿¡ ´ëÇÑ ¿É¼Çµé ¼½¼ÇÀ» º¸½Ê½Ã¿À.
ÀζóÀÎ
ÇÇÃÄ(feature)¸¦ °¡Áö°í ÄÄÆÄÀÏÇÑ´Ù°í °¡Á¤ÇÕ´Ï´Ù.)°ú `-a'
(¾È½Ã C ½ºÅ¸ÀÏ ÇÔ¼ö ÇÁ·ÎÅäŸÀÔÀ» °¡Á¤ÇÕ´Ï´Ù.) Àº »ý¼ºµÈ hash
·çƾ°ú in_word_set
·çƾ ¸ðµÎÀÇ ³»¿ëÀ» ¹Ù²ß´Ï´Ù.
±×·¯³ª , ÇÔ¼ö in_word_set
´Â ´ç½ÃÀÇ ¿É¼Ç ¼¼Æÿ¡ ´äÇÏ¿© ´õ È®ÀåÀûÀ¸·Î ¼öÁ¤ÀÌ µÉ ¼ö ÀÖ½À´Ï´Ù. in_word_set
±¸Á¶¿¡
¿µÇâÀ» ÁÖ´Â ¿É¼ÇÀº ´ÙÀ½°ú °°½À´Ï´Ù:
±¸Á¶(struct)
¸¦ »ç¿ëÇÕ´Ï´Ù.
½ºÀ§Ä¡(switch)
¼¼ú¹®À» »ý¼ºÇÕ´Ï´Ù.
ÀÌ Á¢±Ù¹ýÀÇ Á¤È®ÇÑ ½Ã°£°ú °ø°£ ÀúÀå(space savings)Àº ´ç½ÅÀÇ C ÄÄÆÄÀÏ·¯ÀÇ ÃÖÀûȵµ¿¡ µû¶ó º¯ÈÇÏÁö¸¸, ÀÌ ¹æ¹ýÀº ÀÚÁÖ ´õ ÀÛ°í ´õ ºü¸¥ ÄÚµå·Î
±ÍÂøµË´Ï´Ù.
char *
¸¦ »ý¼ºÇÒÅÙµ¥, ÀÌ Å°´Â
¾î·¹À̸¦ ºÎ¿¬ÇÏ´Â µ¥¿¡ »ç¿ëµÇ´Â ¿©ºÐÀÇ ³Î(null) ½ºÆ®¸µÀ» µ¿¹ÝÇÕ´Ï´Ù. ´Ù¾çÇÑ ÀԷ°ú Ãâ·Â ¿É¼ÇÀ¸·Î ½ÇÇèÇÏ°í, °á°ú·Î ³ª¿À´Â C Äڵ带 ŸÀ̹ÖÇÔ¿¡
ÀÇÇÏ¿©, ´ç½ÅÀº ¼·Î ´Ù¸¥ Å°¿öµå ¼¼Æ® Ư¼ºµé¿¡ ´ëÇØ °¡Àå ÁÁÀº ¿É¼ÇÀÇ ¼±ÅÃÀ» °áÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.
gperf
À¯Æ¿¸®Æ¼¿¡ ´ëÇÑ ¿É¼Çµé gperf
¿¡ ´ëÇØ ¸¹Àº ¿É¼ÇµéÀÌ ÀÖ½À´Ï´Ù. ±×°ÍµéÀº ÇÁ·Î±×·¥ÀÌ ½ÇÁ¦ÀûÀÎ ¾îÇø®ÄÉÀ̼ǵ鿡 »ç¿ëµÇ±â ÆíÇØÁöµµ·Ï ¸¸µå´Âµ¥
µ¡ºÙ¿©Áý´Ï´Ù.
"¿Â¶óÀÎ" µµ¿ò¸»ÀÌ `-h' ¿É¼ÇÀ» ÅëÇÏ¿© Àб⠰¡´ÉÇÕ´Ï´Ù. ¿©±â¿¡ ¿ÏÀüÇÑ ¿É¼Ç ¸®½ºÆ®°¡ ÀÖ½À´Ï´Ù.
ÀÔ·Â ÆÄÀÏÀÇ Çؼ®¿¡ ¿µÇâÀ» ¹ÌÄ¡´Â ¿É¼Çµé
struct
ŸÀÔÀÇ ¼±¾ðÀ» Æ÷ÇÔÇϵµ·Ï ÇÏ°Ô ÇÕ´Ï´Ù. ¿¬¼ÓÀûÀÎ %%½Ö ÀÌÀüÀÇ ¾î¶°ÇÑ ÅؽºÅäµµ ŸÀÔ ¼±¾ðÀÇ ºÎºÐÀ¸·Î ¿©°ÜÁý´Ï´Ù.
Å° ¿öµå¿Í ºÎ°¡ÀûÀÎ ÇʵåµéÀÌ ÀÌ°Í, Áï ¶óÀδç ÇʵåÀÇ ÇÑ ±×·ìÀ» µû¸¦ ¼ö ÀÖ½À´Ï´Ù. »ý¼º(Generating) ¿ÏÀü Çؽà Å×À̺í°ú Ada, C, G++, ÆĽºÄ®(Pascal), ±×¸®°í
Modula 2 ¿Í 3ÀÇ ¿¹¾à¾îµéÀ» À§ÇÑ ÇÔ¼öµéÀ» À§ÇÑ ¿¹½ÃÀÇ ÁýÇÕÀÌ ÀÌ ¸±¸®½º¿Í ÇÔ²² ¹èÆ÷µË´Ï´Ù.
Ãâ·Â Äڵ带 À§ÇÑ ¾ð¾î¸¦ »ó¼úÇÏ´Â ¿É¼Çµé
gperf
¿¡°Ô ¿É¼ÇÀÇ ¾Æ±Ô¸ÕÆ®¿¡ ÀÇÇØ ÁöÁ¤µÇ´Â ¾ð¾î³»ÀÇ Äڵ带 »ý¼ºÇ϶ó°í Áö½ÃÇÕ´Ï´Ù. Ãë±ÞµÇ´Â ¾ð¾î´Â ´ÙÀ½°ú °°½À´Ï´Ù:
µðÆúÆ®´Â CÀÔ´Ï´Ù.
#define const
°¡ ´ç½Å¿¡°Ô Á¦°øµË´Ï´Ù.
gperf
ÀÇ ¿¹Àü ¹öÀüµé°úÀÇ È£È¯¼º¶§¹®¿¡ Á¦°øµË´Ï´Ù. Ưº°È÷ ÇÏ´Â ÀÏÀº ¾ø½À´Ï´Ù.
gperf
ÀÇ ¿¹Àü ¹öÀüµé°úÀÇ È£È¯¼º¶§¹®¿¡ Á¦°øµË´Ï´Ù. Ưº°È÷ ÇÏ´Â ÀÏÀº ¾ø½À´Ï´Ù.
Ãâ·Â Äڵ峻ÀÇ ÆÄÀÎ Æ©´× µðÅ×ÀÏ(fine tuning Details)À» À§ÇÑ ¿É¼Ç
struct
¾È¿¡¼ ¿©ÀüÈ÷ ù¹ø° Çʵå·Î¼ ³ªÅ¸³ª¾ß ÇÔ¿¡µµ ºÒ±¸ÇÏ°í ÄÄÆ÷³ÍÆ®¸¦ À§ÇÑ ½Äº°ÀÚÀÇ ÀÓÀÇÀÇ ¼±ÅÃÀ» °¡´ÉÇÏ°Ô ÇÕ´Ï´Ù.
Perfect_Hash
ÀÔ´Ï´Ù.
isalnum
¿Í isgraph
´Â ¹®ÀÚ¿ÀÌ ÀÌ ¹üÀ§¾È¿¡ À§Ä¡ÇÑ´Ù°í º¸ÀåÇÏÁö ¸øÇÕ´Ï´Ù. ¿ÀÁ÷ `c &
#62; = 'A' && c <= 'Z''¿Í °°Àº ¸íÈ®ÇÑ Å×½ºÆ®¸¸ÀÌ ÀÌ°ÍÀ» º¸ÀåÇÕ´Ï´Ù.) ÀÌ°ÍÀº gperf
ÀÇ ÀÌÀü ¹öÀüµé¾È¿¡¼ µðÆúÆ®ÀÔ´Ï´Ù;
Áö±ÝÀº µðÆúÆ®´Â 8-bit ¹®ÀÚµéÀ̶ó°í °¡Á¤µÇ¾îÁý´Ï´Ù.
strncmp
ÇÔ¼ö¸¦ »ç¿ëÇÏ´Â C Äڵ带 »ý¼ºÇÕ´Ï´Ù. ÀÌ µðÆúÆ® ¾×¼ÇÀº strcpm
¸¦ »ç¿ëÇϱâ·Î µÇ¾î ÀÖ½À´Ï´Ù.
<jjc@ai.mit.edu>
¿¡°Ô °¨»ç¸¦ Ç¥ÇÕ´Ï´Ù.
<string.h>
, À» Æ÷ÇÔÇÕ´Ï´Ù. µðÆúÆ®·Î, ÀÌ°ÍÀº µÇ¾îÁ® ÀÖÁö ¾Ê½À´Ï´Ù; »ç¿ëÀÚ´Â ¹Ýµå½Ã
ÀÌ Çì´õ ÆÄÀÏ·Î ÄÚµåÀÇ ÄÄÆÄÀÏÀ» Çã¶ôÇϵµ·Ï Æ÷ÇÔ½ÃÄÑ¾ß ÇÕ´Ï´Ù.
switch
½ºÅ×ÀÌÆ®¸ÕÆ® ½ºÅ°¸¶¸¦ »ç¿ëÇÏ°Ô ÇÕ´Ï´Ù. ÀÌ°ÍÀº ¾î¶² Å°ÆÄÀϵéÀ» À§ÇÑ ½Ã°£°ú °ø°£ÀÇ ¿ä±¸¸¦
µ¿½Ã¿¡ ÁÙ¿©ÁÖ°Ô²û ÇÕ´Ï´Ù.ÀÌ ¿É¼Ç¿¡ ´ëÇÑ ¾Æ±Ô¸ÕÆ®´Â ¾ó¸¶³ª ¸¹Àº switch
½ºÅ×ÀÌÆ®¸ÕÆ®°¡ »ý¼ºµÉÁö¸¦ °áÁ¤ÇÕ´Ï´Ù. 1ÀÇ °ªÀº ¸ðµç ¿¤·¹¸àÆ®¸¦ Æ÷ÇÔ
ÇÏ´Â 1 switch
¸¦ »ý¼ºÇϸç, 2ÀÇ °ªÀº °¢°¢ÀÇ switch
¾ÈÀÇ 1/2 ¿¤·¹¸àÆ®¸¦ °¡Áö°í 2 Å×À̺íÀ» »ý¼ºÇÕ´Ï´Ù. ÀÌ°ÍÀº ¸¹Àº C ÄÄÆÄÀÏ·¯
µéÀÌ Ä¿´Ù¶õ switch
½ºÅ×ÀÌÆ®¸ÕÆ®¿¡ ´ëÇؼ ¿Ã¹Ù¸£°Ô Äڵ带 »ý¼ºÇÏÁö ¸øÇϱ⠶§¹®¿¡ À¯¿ëÇÕ´Ï´Ù. ÀÌ ¿É¼ÇÀº Keith BosticÀÇ ¿À¸®Áö³Î C ÇÁ·Î±×·¥¿¡ ÀÇÇØ
ºÎºÐÀûÀ¸·Î ä¿ëµÇ¾ú½À´Ï´Ù.
gperf
ÀÇ ÀÌÀü ¸±¸®½º¿ÍÀÇ È£È¯¼ºÀ» Áö¿øÇÕ´Ï´Ù. ±×¿Ü¿£ ¾Æ¹« ±â´ÉÀÌ ¾ø½À´Ï´Ù.
gperf
¿¡ äÅÃµÈ ¾Ë°í¸®ÁòÀ» ¹Ù²Ù±â À§ÇÑ ¿É¼Çµé
strcmp
¿¡ ÀÇÇÏ¿© °áÄÚ ºñ±³µÇÁö ¾Ê±â ¶§¹®ÀÔ´Ï´Ù. ±×·¯³ª, `-l'»ç¿ëÀº ¸¸¾à ·è¾÷ Å×ÀÌºí ¹üÀ§°¡ Ŭ °æ¿ì( ½ºÀ§Ä¡ ¿É¼Ç
`-S'ÀÌ »ç¿ëµÇ¾îÀÖÁö ¾ÊÀ½À» ÀǹÌÇÕ´Ï´Ù.) »ý¼ºµÈ C ÄÚµåÀÇ Å©±â¸¦ »ó´çÈ÷ Áõ°¡½Ãų¼ö ÀÖ½À´Ï´Ù. ¿Ö³ÄÇÏ¸é ±æÀÌ Å×À̺íÀÌ ·è¾÷ Å×ÀÌºí³»¿¡¼ÀÇ ¿£Æ®¸®µé
¸¸ÅÀÇ ¸¹Àº ¿¤·¹¸àÆ®¸¦ Æ÷ÇÔÇϱ⠶§¹®ÀÔ´Ï´Ù.
¿É¼Ç `-D'´Â ƯÁ¤ÇÑ Å©°Å³ª ȤÀº ¸¹ÀÌ Áߺ¹µÈ Å°¿öµå ÁýÇÕµé, Áï ¾î¼Àºí·¯ ¸í·É ¿ÀÇÇÄÚµå(opcodes)°°Àº °Íµé¿¡ ¸ÅÀ¯ À¯¿ëÇÕ´Ï´Ù. ÀÌ ¿É¼ÇÀÇ »ç¿ëÀº
º¸Åë »ý¼ºµÈ Çؽà ÇÔ¼ö°¡ ´õ ÀÌ»ó ¿Ïº®ÇÏÁö ¾Ê´Ù´Â °ÍÀ» ÀǹÌÇÕ´Ï´Ù. ¹Ý¸é¿¡, ÀÌ ¿É¼ÇÀº gperf
´Â ¿ªÇàÇÏÁö ¾Ê±â¶§¹®¿¡ °¢ ´Ü¾î(word)¿¡ ´ëÇÑ °íÀ¯ÇÑ ¸ÅÇÎÀÇ ¹ß°ß¾øÀÌ ¸ðµç ´ç½ÅÀÇ ÀÔ·Â Å°¿öµåµéÀ» ó¸®ÇÏ´Â °ÍÀÌ °¡´ÉÇÕ´Ï´Ù.
±×·¯³ª, ÀÚÁÖ ¸Å¿ì ÀûÀº °¹¼ö¸¸ÀÇÀÇ Áߺ¹ÀÌ ¹ß»ýÇϸç, Å°µéÀÇ ´ëºÎºÐÀº ¿©ÀüÈ÷ Å×ÀÌºí³»·ÎÀÇ ÇÑ°³ÀÇ Å½»öÀÚ¸¦ ¿ä±¸ÇÕ´Ï´Ù.
gperf
´Â ¸ðµç ÀÌ·¯ÇÑ Å°µéÀ» µî°¡ÀÇ Å¬·¡½º·Î¼
´Ù·ç¸ç Áߺ¹µÈ Å°µé¿¡ ´ëÇÑ º¹¼öÀÇ ºñ±³¸¦ °¡Áö´Â ¿Ïº® Çؽà ÇÔ¼ö¸¦ »ý¼ºÇÕ´Ï´Ù. »ý¼ºµÈ C Äڵ带 ¼öÁ¤ÇÔÀ¸·Î½á Å°¿öµåµéÀ» ¿ÏÀüÇÏ°Ô ¸íÈ®ÇÏ°Ô ÇÏ´Â °ÍÀº ´ç½Å¿¡°Ô
´Þ·Á ÀÖ½À´Ï´Ù. ±×·¯³ª, gperf
´Â Ãâ·ÂÀ» Á¶Á÷ÈÇÔÀ¸·Î½á ´ç½ÅÀ» µµ¿ï °ÍÀÔ´Ï´Ù.
gperf
°¡ ´Ù¸¥ ¹æ¹ýÀ¸·Î´Â ´Ù·ê ¼ö ¾ø¾ú´ø Å°¿öµå ÁýÇÕ¿¡ ÀÛµ¿
Çϵµ·Ï Çã¿ëÇØ ÁÝ´Ï´Ù.
gperf
ÀÇ ¼öÇà½Ã°£À» ÁÙ¿©ÁÝ´Ï´Ù. ¹Ýº¹·®(iteration amount)Àº
Ãæµ¹À» ÇØ°áÇÒ¶§ ¹Ýº¹µÇ´Â Ƚ¼ö¸¦ ³ªÅ¸³À´Ï´Ù. `0'Àº Å°¿öµåµéÀÇ °¹¼ö¿¡ ÀÇÇÑ ¹Ýº¹À» ÀǹÌÇÕ´Ï´Ù. ÀÌ ¿É¼ÇÀº Ä¿´Ù¶õ Å°¿öµå ÁýÇÕ°ú
¿É¼Ç `-D' ±×¸®°í/ȤÀº `-S'°¡ °ü·ÃµÇ¾î »ç¿ëµÇ¾îÁú¶§ ¸Å¿ì À¯¿ëÇÕ´Ï´Ù.
gpref
´Â ¹«ÀÛÀ§ÀÇ Å©±â¸¦ °¡Áö°í Á¡ÇÁÇÕ´Ï´Ù.
gperf
ÀÇ ½ÇÇà ½Ã°£À» Áõ°¡
½Ãų¼ö ÀÖ½À´Ï´Ù.¿Ö³ÄÇϸé Ãæµ¹ÀÌ ´õ »¡¸® ½ÃÀÛÇÏ¿© Å°¿öµå ó¸®ÀÇ ³²Àº ºÎºÐµ¿¾È °è¼ÓµÉ °ÍÀ̱⠶§¹®ÀÔ´Ï´Ù. ´õ ÀÚ¼¼ÇÑ »çÇ×Àº 1980³â 1¿ù Communication of the
ACMÀÇ CichelliÀÇ ³í¹®À» º¸½Ê½Ã¿À.
gperf
°¡ ƯÁ¤ Å°¿öµå¿¡¼ °ï¶õÇÔÀÌ ÀÖ´Ù¸é `-r'ȤÀº `-D'¸¦ ÀÌ¿ëÇÏ¿© ½ÃµµÇغ¸½Ê½Ã¿À.
gperf
ÀÇ ¼öÇà½Ã°£Àº ´Ã¾î³ª°Ô µÇ´Âµ¥, ¿Ö³ÄÇÏ¸é ±×°ÍÀÌ °ªµéÀÇ ¸Å¿ì Ä¿´Ù¶õ ¹üÀ§³»¿¡¼ °Ë»öÇØ¾ß Çϱ⠶§¹®ÀÔ´Ï´Ù. ±×·¯³ª ÀûÀýÇÑ
`-f' ¿É¼ÇÀÇ »ç¿ëÀÌ ÀÌ·¯ÇÑ ºÎÇϸ¦ ´õ´Âµ¥ µµ¿òÀÌ µË´Ï´Ù.
Á¤º¸¸¦ Á¦°øÇÏ´Â Ãâ·Â
gperf
°¡ ¼öÇàµÉ¶§ "Ç¥ÁØ ¿À·ù"¿¡ ´ëÇÑ ÀåȲÇÑ(verbose) Áø´ÜÀ» »ý»êÇÕ´Ï´Ù. ±×°ÍÀº
ÇÁ·Î±×·¥ÀÇ À¯Áö¿Í ¿É¼ÇÀÇ ÁÖ¾îÁø ÁýÇÕÀÌ ½ÇÁö·Î ¼Ö·ç¼ÇÀ» ã¾Æ³»´Â°ÍÀ» »¡¸®ÇÏ°Ô ÇÏ´ÂÁöÀÇ ¿©ºÎ¸¦ °áÁ¤Çϴµ¥¿¡ À¯¿ëÇÕ´Ï´Ù. ´Ù¼öÀÇ
À¯¿ëÇÑ Á¤º¸´Â `-d'¿É¼ÇÀÌ »ç¿ëµÉ½Ã ÇÁ·Î±×·¥ÀÇ ³¡ºÎºÐ¿¡ ´ýÇÁµË´Ï´Ù.
gperf
ÀÇ ¾Ë·ÁÁø ¹®Á¦Á¡°ú ÇÑ°èµégperf
ÇöÀç ¸±¸®½ºÀÇ ¸î°¡Áö Áh°èµéÀÔ´Ï´Ù:
gperf
À¯Æ¿¸®Æ¼´Â À۰ųª Áß°£Á¤µµÀÇ Å©±â µ¥ÀÌŸ ÁýÇÕ(¾à 1000°³ÀÇ Å°¿öµåµé)µé¿¡ ´ëÇØ ºü¸£°Ô ½ÇÇàÇÏ°í ÀÛµ¿Çϵµ·Ï ÃÖÀûȵǾú½À´Ï´Ù.
±×°ÍÀº ÄÄÆÄÀÏ·¯ Å°¿öµå ÁýÇյ鿡 ´ëÇØ ¿Ïº® Çؽà ÇÔ¼ö¸¦ À¯Áöº¸¼öÇϴµ¥¿¡ ¸Å¿ì À¯¿ëÇÕ´Ï´Ù. ÃÖ±ÙÀÇ ¸î°¡ÁöÀÇ °ÈÁ¡µéÀº gperf
°¡
´õ Å« Å°¿öµå ÁýÇÕ(15,000°³ÀÇ Å°¿öµå¸¦ ³Ñ´Â)¿¡ ´ëÇؼ È¿°úÀûÀ¸·Î ÀÛµ¿ÇÏ´Â °ÍÀ» °¡´ÉÇÏ°Ô Çß½À´Ï´Ù. Ä¿´Ù¶õ Å°¿öµåÁýÇÕÀ» ó¸®ÇÒ¶§¿¡´Â 8 ¸Þ°¡°¡
³Ñ´Â ·¥À» °¡Áö´Â °ÍÀÌ ¸Å¿ì µµ¿òÀÌ µË´Ï´Ù.
±×·¯³ª, gperf
´Â ¿ªÇàÇÏÁö ¾Ê±â ¶§¹®¿¡ ÀÛµ¿½Ã¸¶´Ù ¼Ö·ç¼ÇÀÌ ¾ò¾îÁø´Ù´Â º¸ÀåÀÌ ¾ø½À´Ï´Ù. ¹Ý¸é¿¡, ¿É¼Ç ÆĶó¹ÌÅ͸¦ º¯°æÇÔÀ¸·Î½á
¼Ö·ç¼ÇÀ» ¾ò¾î³»´Â °ÍÀÌ ÀϹÝÀûÀ¸·Î ½±½À´Ï´Ù. ƯÈ÷, `-r'¿É¼ÇÀ» ½ÃµµÇغ¸°í, ¶ÇÇÑ `-S'¿Í `-j' ¿É¼ÇÀÇ
µðÆúÆ® ¾Æ±Ô¸ÕÆ®¸¦ ¹Ù²ãº¸´Â °ÍÀ» ½ÃµµÇϽʽÿÀ. ¼Ö·ç¼ÇÀ» º¸ÀåÇϱâ À§ÇØ, `-D'¿Í `-S' ¿É¼ÇÀ»
»ç¿ëÇϽʽÿÀ. ÃÖÁ¾ÀûÀÎ °á°ú°¡ ´õ ÀÌ»ó ¿Ïº®ÇÑ Çؽà ÇÔ¼ö°¡ µÇÁö ¸øÇÒ°Í °°Áö¸¸ ¸»ÀÔ´Ï´Ù!¸¶Áö¸·À¸·Î, ¸¸¾à ´ç½ÅÀÌ gperf
·Î
ÇÏ¿©±Ý ºü¸£°Ô ¿Ïº® Çؽà ÇÔ¼ö¸¦ »ý¼ºÇϱ⸦ ¿øÇÑ´Ù¸é, ÃÖ¼ÒÇÑÀ¸·Î ¸¸µé±â À§ÇÑ °Á¶¸¦ ´úÇÑ »óÅ¿¡¼ `-f' ¿É¼ÇÀ» »ç¿ëÇϽʽÿÀ.
¿©ÀüÈ÷ ³²¾Æ ÀÖ´Â ÇØ¾ß ÇÒ °Íµé
switch
¿É¼ÇÀÇ »ç¿ëÀº ¾à°£ ´õ ±ä ·è¾÷ÀÇ ´ñ°¡·Î µ¥ÀÌŸ
Å©±â¸¦ ÃÖ¼ÒÈ ÇÒ¼ö Àֱ⠶§¹®ÀÔ´Ï´Ù.(gccÄÄÆÄÀÏ·¯´Â ÀϹÝÀûÀ¸·Î switch
¹®À» À§ÇÑ ÁÁÀº Äڵ带 ¸¸µé¾î³»¸ç,
´õ º¹ÀâÇÑ ½ºÅ°¸¶ÀÇ Çʿ伺À» ÁÙ¿©Áشٴ °ÍÀ» ±â¾ïÇϽʽÿÀ.)
GNU
gperf
ÀÇ ±¸Çö ¼¼ºÎgperf
±¸Çö¿¡ »ç¿ëµÇ¾îÁö´Â µ¥ÀÌÅÍ ±¸Á¶¿Í ¾Ë°í¸®ÁòÀÇ °íÂ÷¿øÀÇ ¼³¸íÀ» ÇÏ´Â º¸°í¼°¡ °ð ³ª¿Ã °ÍÀÔ´Ï´Ù.
ÀÌ º¸°í¼´Â À¯Áöº¸¼ö¿Í °È °üÁ¡À¸·ÎºÎÅͻӸ¸ ¾Æ´Ï¶ó ´Ù¼öÀÇ ´õ Çü¸íÇÏ°í À¯¿ëÇÑ ÇÁ·Î±×·¡¹Ö ±â¹ý, Áï `¹Ýº¹ ¼ö' ºÒ¸®¾Ó ¾î·¹ÀÌ,
´õºí ÇؽÌ, ÆÄÀϷκÎÅÍÀÇ ¸¶À½´ë·ÎÀÇ ±ä ÀÔ·ÂÀ» Àд "¾ÈÀü"ÇÏ°í È¿°úÀûÀÎ ¹æ¹ý, ±×¸®°í ¸®½ºÆ®¾È¿¡¼ ÃÖ¼Ò ÃÖ´ë ¿ø¼Ò¸¦
µ¿½Ã¿¡ °áÁ¤Çϱâ À§ÇÑ ÃÖÀûÇÏµÈ ¾Ë°í¸®ÁòÀ» º¸¿©Áֱ⠶§¹®¿¡¶óµµ À¯¿ëÇÕ´Ï´Ù.
Âü°í¹®Çå