/***************************************************************************
*
* Lex로 구현한 Java 어휘 분석기
*
* 컴파일 방법 :
* 1) LINUX
* flex scanner.l
* gcc lex.yy.c -lfl -oscanner
*
* 2) UNIX
* lex scanner.l
* cc lex.yy.c -ll -oscanner
*
* 실행 방법 :
* ./scanner < source.java (입력 파일은 `<` 입력리다이렉션으로)
* cat tokenlist.txt (결과 파일)
*
***************************************************************************/
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define MAX_ID_LENGTH 255 // Max Length of Identifier
#define NUM_KEYWORD 47 // Number of keywords
enum tsymbol {
teof, tident, tint, tfloat, tdouble, tchar, tstring,
tslparen, tsrparen, tmlparen, tmrparen, tblparen, tbrparen, tsemicolon, tcomma, tdot, tplus, tminus, ttimes, tdiv, tmod, tassign, tpass, tmass, ttass, tdass, tmodass, tinc,
tdec, tOR, tAND, tNOT, tques, tcolon, tequal, tnequal, tless, tgreat, tlesse, tgreate, tand, tor, txor, tls, trs, tunsignedrs,tnot, tlsass, trsass, tunsignedrsass, tandass, torass, txorass,
// keyword
abstractsym, booleansym, breaksym, bytesym, casesym, catchsym, charsym, classsym, constsym, continuesym, defaultsym, dosym,
doublesym, elsesym, extendssym, finalsym, finallysym, floatsym, forsym, gotosym, ifsym, implementssym, importsym, instanceofsym,
intsym, interfacesym, longsym, nativesym, newsym, packagesym, privatesym, protectedsym, publicsym, returnsym, shortsym, staticsym,
supersym, switchsym, synchronizedsym, thissym, throwsym, throwssym, transientsym, trysym, voidsym, volatilesym, whilesym
};