• R/O
  • HTTP
  • SSH
  • HTTPS

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コンパイラ


File Info

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 記述。

Content


#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;
}