Name: Anonymous 2009-05-13 5:26
Sup expert programmers. My task is to write a .lex file for jflex in order to generate a lexical scanner. I have everything ready, except for the declarations of IDENT and NUMBER:
As you can see, I don't know how I should assign a value to ident and number. The task is: Ident should have its name as a String as the value and Number should have its own int value as a value. How would I go about doing this?
ALPHA=[A-Za-z]
DIGIT=[0-9]
({ALPHA}({DIGIT}|{ALPHA})*) { value = /* ? */ return TokenType.IDENT; }
({DIGIT}+) { value = /* ? */ return TokenType.NUMBER; }As you can see, I don't know how I should assign a value to ident and number. The task is: Ident should have its name as a String as the value and Number should have its own int value as a value. How would I go about doing this?