[ java ] in KIDS 글 쓴 이(By): guest (guest) 날 짜 (Date): 1998년04월08일(수) 11시35분38초 ROK 제 목(Title): 누가 이것 좀 도와 줘요!! java로 프로그램을 짜는데 잘 않되네요!! 사실은 이것 레포트로 제출하는 것라 하긴 해야 된는데... java를 잘 하시는 분은 꼭 좀 도와 줘요.. 그럼 감사 ... 꾸벅 4 Y Develop a lexical analyzer for Simple Java Language which is descibed below. Simple Java Language only provides the following tokens: Keywords : char class double extends float for if int public private static void while Operators : + - * / . = < > <= >= == != [ ] Punctuationmark: ( ) { } ; Token Identifiers Keywords Operators Number constants String constants Punctuators Lexical analyzer Read a Simple Java program as input and divides it into a sequence of tokens. It also generates various tables (symbol table, string table, number table) whose indices are used in the token sequence. If it finds a lexical error (e.g. unknown symbol, illegal identifier, etc; but it does not detect grammatical syntax errors), it generates an appropriate error message. In the output token sequence, each token consists of a pair of values <token_type, token_value>. (see the table below) token type sample tokens descriptions ID sum, main, f, $total identifier IF if keyword WHILE while keyword REL_OP <, <=, ... relational operators ARITH_OP +, -, *, / arithmatic operators ASSIGN_OP = assignment operator MEMBER . member access operator NUMBER 3.14, 10 number constants STRING "Java Language" string constants PUNC (, ), {, }, [, ], ; punctuators Token values are defined differently for each token type. Token types Token values ID index number to symbol table entry where the id is stored keywords none REL_OP LT, LE, EQ, ... (symbolic constant) ARITH_OP PLUS, MINUS, ...(symbolic constant) ASSIGN_OP none MEMBER none NUMBER index to number table STRING index to string table PUNC OPEN_PARAN, CLOSE_PAREN, ... (symbolic constant) Example Token Sequence System.out.println("int: " + (int)fmin + ".." + (int)fmax); <ID,1> System <MMEBER, > . <ID,2> out <MEMBER, > . <ID,3> println <PUNC, OPEN_PAREN> ( <STRING, 1> "int: " <ARITH_OP, PLUS> + <PUNC, OPEN_PAREN> ( <INT, > int <PUNC, CLOSE_PAREN> ) <ID, 4> fmin .... <PUNC, SEMICOLON> ; Due date : Apr. 22 Things to be submitted: Design Output (Class Diagram with description) Source Program Sample Data and Results(token sequence, symbol table, constant tables) |