kldp에서 lex에 관해서 보다가 의문점이 있어 글올립니다.
예제를 보면
%{
/* need this for the call to atof() below */
#include
%}
DIGIT [0-9] /* 매크로를 정의한다 */
ID [a-z][a-z0-9]*
%%
{DIGIT}+ { printf( "An integer %s (%d)\n", yytext, atoi( yytext ) ); }
{DIGIT}+"."{DIGIT}* { printf( "A float %s (%g)\n", yytext, atof(
yytext ) );
}
if|then|begin|end|procedure|function { printf( "A keyword %s\n",
yytext ); }
{ID} { printf( "An identifier %s\n", yytext ); }
"+"|"-"|"*"|"/" { printf( "An operator %s\n", yytext ); }
"{"[^}\n]*"}" ; /* { } 안의 내용은 주석으로 무시한다. */