コンパイラ
Rev. | d85114e8e96ca773d54f7651aab9a16005944069 |
---|---|
Tamanho | 705 bytes |
Hora | 2011-06-13 00:09:32 |
Autor | berupon |
Mensagem de Log | ISO/IEC 9899:TC3 Annex A Language syntax summary に基づいた Lexer 記述。
|
#include <stdio.h>
#include "lexer.h"
int main(int argc, char* argv[])
{
char* pBuf = "int main(int argc, char* argv[]){ return 0; }";
using namespace Lexer;
yyin = pBuf;
int t;
do {
t = yylex();
switch (t) {
case Token_Error:
puts("Error");
break;
case Token_WhiteSpace:
puts("WhiteSpace");
break;
default:
switch (t & 0xffffff00) {
case Token_Keyword:
puts("Keyword");
break;
case Token_Identifier:
puts("Identifier");
break;
case Token_Constant:
puts("Constant");
break;
case Token_Punctuator:
puts("Punctuator");
break;
}
}
printf("%d\n", t);
}while (t);
return 0;
}