LEX(1)			UNIX¥³¥Þ¥ó¥É		LEX(1)

 [Ì¾Á°]
lex - »ú¶ç²òÀÏ¥×¥í¥°¥é¥àÀ¸À®

 [·Á¼°]
lex [-w] -[ tvfnm ] [ file ]...

 [µ¡Ç½ÀâÌÀ]
lex¤Ï´ÊÃ±¤Ê»ú¶ç²òÀÏ¤ò¤ª¤³¤Ê¤¦¥×¥í¥°¥é¥à¤òÀ¸À®¤·¤Þ¤¹¡£ÆþÎÏ¥Õ¥¡¥¤¥ë¤Ë¤Ï¡¢¸¡º÷¤Î°Ù¤ÎÀµµ¬É½¸½¤È¡¢¸«¤Ä¤±¤¿ºÝ¤Ë¼Â¹Ô¤µ¤ì¤ëC¸À¸ì¤Ç½ñ¤«¤ì¤¿¡¢¥¢¥¯¥·¥ç¥ó¤¬´Þ¤Þ¤ì¤Þ¤¹¡£

À¸À®¤µ¤ì¤¿C¥×¥í¥°¥é¥à'lex.yy.c'¤Ï¼¡¤Î¤è¤¦¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤Þ¤¹¡£	
	 	cc -bsd lex.yy.c -L/usr/lib -lnjeJ -llnJ (-w¥ª¥×¥·¥ç¥ó»ØÄê»þ)		cc  lex.yy.c -ll (-w¥ª¥×¥·¥ç¥óÌ¤»ØÄê»þ)

¥×¥í¥°¥é¥à¼Â¹Ô»þ¡¢ÆþÎÏ¥Ç¡¼¥¿¤¬»ØÄê¤·¤¿Àµµ¬É½¸½¤È°ìÃ×¤·¤¿¤È¤­¡¢C¤Çµ­½Ò¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤¬¼Â¹Ô¤µ¤ì¡¢°ìÃ×¤·¤Ê¤¤¤È¤­¤Ï¤½¤Î¤Þ¤Þ½ÐÎÏ¤µ¤ì¤Þ¤¹¡£
¥ª¥×¥·¥ç¥ó¤Ï°Ê²¼¤Ë¼¨¤¹¤È¤¦¤ê¤Ç¤¹¡£	     -w
-w¤ò»ØÄê¤¹¤ë¤È¡¢ÆüËÜ¸ìÂÐ±þlex(/usr/nje/bin/lex)¤¬µ¯Æ°¤µ¤ì¤Þ¤¹¡£
Ì¤»ØÄê¤Î¾ì¹ç¤ÏÄÌ¾ï¤Îlex(/usr/bin/lex)¤¬µ¯Æ°¤µ¤ì¤Þ¤¹¡£

-t 
lex.yy.c¤Ë½ÐÎÏ¤µ¤ì¤ëÆâÍÆ¤¬¡¢¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯É¸½à½ÐÎÏ¤Ë½ÐÎÏ¤µ¤ì¤ë¡£

-v 
Åý·×¾ðÊó¤ÎÍ×Ìó¤ò½ÐÎÏ¤¹¤ë¡£

-n 
-v¤òÍÞ»ß¤·¤Þ¤¹¡£¡¨¥Ç¥Õ¥©¥ë¥È¤Ç»ØÄê¤µ¤ì¤Þ¤¹¡£

-m
	   yytext¤òchar·¿¤Ç½ÐÎÏ¤·¤Þ¤¹¡£
	   
 [ÆüËÜ¸ìµ¡Ç½]
1 ¥¹¥¯¥ê¥×¥È
  a) ÄêµÁÉô
	ÆüËÜ¸ìÆþÎÏ¤¬¤Ç¤­¤Þ¤¹¡£
	  ex: Ê¿²¾Ì¾	[¤¢-¤ó]
 
  b) ¥ë¡¼¥ëÉô
	ÆüËÜ¸ìÆþÎÏ¤¬¤Ç¤­¤Þ¤¹¡£Ã¢¤·¥¢¥¯¥·¥ç¥ó¤Ë´Ø¤·¤Æ¤Ï¡¢C¥³¥ó¥Ñ¥¤¥é¤Î»ÅÍÍÆâ¤Ç²ÄÇ½¤Ç¤¹¡£
	  ex: [¤«-¤³]	printf("¤«¹Ô\n");
	      .[eEqQ½ª]	{printf(" ½èÍý½ªÎ»\n");return(0);}

  c) ¥µ¥Ö¥ë¡¼¥Á¥óÉô
	C¥³¥ó¥Ñ¥¤¥é¤Î»ÅÍÍÈÏ°ÏÆâ¤Ç¡¢ÆüËÜ¸ìÆþÎÏ¤¬¤Ç¤­¤Þ¤¹¡£

2 »ÅÍÍÊÑ¹¹ÅÀ
  	ÆüËÜ¸ì²½¤ËÈ¼¤¤¡¢°Ê²¼¤ÎÅÀ¤Ç»ÅÍÍÊÑ¹¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
 		a) -m¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢yytext¤òchar·¿¤È¤·¤ÆÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
 
  b) ½èÍý¤Ï¥Ð¥¤¥ÈÃ±°Ì¤Ç¤Ê¤¯¡¢Ê¸»úÃ±°Ì¤È¤·¤¿¡£½¾¤Ã¤ÆÊ¸»ú¤Ïwchar_t·¿¤Ç½èÍý¤µ¤ì¤Þ¤¹¡£

  c) ¼¡¤Î´Ø¿ô¤òÄÉ²Ã¤·¤Þ¤·¤¿¡£
	EUCCNV -- EUCÊ¸»ú¤òÆâÉô¥³¡¼¥É¤ËÊÑ´¹¤¹¤ë¡£
	RETBACK - yytext¤ÎÆâÍÆ¤òÉ¬Í×¤Ë±þ¤¸Éü¸µ¤¹¤ë¡£
	RSTEUC -- ÆâÉô¥³¡¼¥É¤òEUCÊ¸»ú¤ËÉü¸µ¤¹¤ë¡£

 3 Ãí°Õ»ö¹à
  a) ÂÐ¾Ý¥³¡¼¥É·Ï¤Ï¡¢ASCII¡¢EUC¡¢È¾³Ñ¥«¥Ê¤Ç¤¹¡£(³°»ú¤Ï¥µ¥Ý¡¼¥È¤·¤Þ¤»¤ó)

  b) EUC¥³¡¼¥É¤Ïyylex()Æâ¤Ç¤Ï¡¢Á´¤ÆÆâÉô¥³¡¼¥É¤ËÊÑ´¹¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢yylex()¤ò½¤Àµ¤¹¤ëºÝ¤Ë¤ÏÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ÆÃ¤ËÆâÉô¥³¡¼¥É¤Ø¤ÎÊÑ´¹¡¢EUC¤Ø¤ÎÉü¸µ¤Ï¤½¤ì¤¾¤ìEUCCNV¡¢RSTEUC¤òÍÑ¤¤¤Æ¤¯¤À¤µ¤¤¡£

  c) input¥Þ¥¯¥í¤òÊÑ¹¹¤¹¤ëºÝ¤Ï¡¢Ê¸»úÃ±°Ì¤ÎÆþÎÏ¤È¤·¡¢ÆþÎÏ¸å¤ÏÉ¬¤ºEUCCNV¤ò¥³¡¼¥ë¤·¤Æ¤¯¤À¤µ¤¤¡£

  d) ¥½¡¼¥¹¥¹¥¯¥ê¥×¥È¤ÇEUC¥³¡¼¥É¤¬ÆþÎÏ¤µ¤ì¤ë¤È¡¢lex.yy.cÆâ¤ËÆþÎÏ¤µ¤ì¤¿EUC¥³¡¼¥É¤Î°ìÍ÷É½¤¬Å¸³«¤µ¤ì¤Þ¤¹¡£½¾¤Ã¤ÆÂ¿¤¯¤ÎÊ¸»ú¼ï¤ò°·¤¦¥¹¥¯¥ê¥×¥È¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ëºÝ¤Ë¤Ï¡¢lex.yy.c¤Î¥×¥í¥°¥é¥à¥µ¥¤¥º¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£

  e) lex.yy.c ¥ê¥ó¥¯»þ¤ÏÉ¬¤º¡¢ÀìÍÑ¥é¥¤¥Ö¥é¥ê/usr/lib/liblnJ.a¤ÈÆüËÜ¸ì½èÍý¥é¥¤¥Ö¥é¥ê/usr/lib/libnjeJ.a ¤ò»ØÄê¤·¤Æ¤¯¤À¤µ¤¤¡£

 [»ÈÍÑÎã]
lex -w lexcommand

¤³¤Î¥³¥Þ¥ó¥ÉÆþÎÏ¤Ë¤è¤ê¡¢lexcommandÆâ¤ÎÌ¿Îá¤òlex.yy.c¤Ë½ÐÎÏ¤·¤Þ¤¹¡£

Ê¿²¾Ì¾	[¤¢-¤ó]
%%
{Ê¿²¾Ì¾}	{putwchar(yytext[0]+0xa5a1-0xa4a1);}
[ ]+	{putchar(' ');}
"Ê¸½ñ½ªÎ»"	return(0);

¤³¤ÎÎã¤Ï¡¢Ê¿²¾Ì¾¤ò¥«¥¿¥«¥Ê¤ËÊÑ´¹¤·¡¢Æó¤Ä°Ê¾å¤Î¥¹¥Ú¡¼¥¹¤ò°ì¤Ä¤Î¥¹¥Ú¡¼¥¹¤ËÊÑ´¹¤·¡¢"Ê¸½ñ½ªÎ»"¤òÆÉ¤ß¹þ¤ó¤À¤é½èÍý¤ò½ªÎ»¤·¤Þ¤¹¡£

 [´ØÏ¢»ö¹à]
yacc(1), sed(1)