If anyone can help, I am writing a recursive decent parser for a particular grammar in JAVA. I have already written much of it, i am just lost on one thing: When the grammar has a non terminal that then points to one of three non-terminal characters (In BNF roughly... S::= a<A> | a<B> | a<C>). The parser takes in tokens from a lexical analyzer, and basically just validates the input and builds a parse tree. How do you handle such a case recusively?

My only thought is to make an abstract class with methods common to all non-terminals, and then extend that in three sub-classes, which are chosen once it gets to the next token. For some reason I keep thinking there should be a batter way. Any clues? Sorry if I am not so clear on this . . .been bashing my brain on this for days.