Thread: Recursive Decent Parsing
February 4th, 2009, 06:48 PM #1
Recursive Decent Parsing
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.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By ShuckyD in forum Webmastering and ProgrammingReplies: 3Last Post: April 6th, 2009, 04:23 AM
By ShuckyD in forum Webmastering and ProgrammingReplies: 6Last Post: April 18th, 2006, 09:27 PM
By FatalException in forum Webmastering and ProgrammingReplies: 13Last Post: March 8th, 2006, 01:52 PM
By YottaHertz in forum Webmastering and ProgrammingReplies: 7Last Post: February 19th, 2006, 10:22 PM
By John Prophet in forum MotherboardsReplies: 6Last Post: December 19th, 2002, 09:26 PM