Token Enumeration in Java
I'm writing a lexer using jflex for a made up programming language. It requires an enumeration java class w开发者_如何学运维hich holds a bunch of tokens for the made up language. Things like STRING_TKN, ON_TKN, GOTO_TKN, COMMAND_TKN, etc. I haven't used java in a while so I forget how to set these up.
Thanks
Java as an enum
type.
http://download.oracle.com/javase/tutorial/java/javaOO/enum.html
An example:
public enum Colors{
RED,BLUE,GREEN;
}
精彩评论