Results 1 to 3 of 3
- 10-16-2011, 08:52 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 46
- Rep Power
- 0
Is my recursive decent parse correct?
I am trying to get a better grasp of recursive decent parsing and wanted to make sure this would be correct.
<repeat_statement> -> REPEAT<statement>UNTIL<expression>;
Java Code:boolean parseRepeatStatement(){ if(token == REPEAT){ token = getNextToken(); if(parseStatement()){ if(token == UNTIL){ token = getNextToken(); if(parseExpression()){ if(token == ';') return true; } } } } return false; }
- 10-16-2011, 09:05 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
Re: Is my recursive decent parse correct?
It looks almost fine to me: if the getNextToken() method removes the current token from the input stream. why don't you call that method after it has seen that semi colon and just before your code returns true? Otherwise you have to explain what your code does exactly ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-17-2011, 12:20 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 46
- Rep Power
- 0
Similar Threads
-
These components should at least TRY to look decent
By blackbird in forum AWT / SwingReplies: 12Last Post: 07-29-2011, 07:00 PM -
Please help - can't seem to correct this...
By jmjbreezin in forum New To JavaReplies: 7Last Post: 05-09-2011, 01:39 PM -
Recursive and Non-Recursive powersets?
By csisdifficult in forum New To JavaReplies: 5Last Post: 04-20-2011, 02:45 AM -
Are my comments correct?
By twiggy62 in forum New To JavaReplies: 2Last Post: 02-08-2010, 05:34 AM -
Decent Book For JBuilder 2006
By MayheM in forum New To JavaReplies: 2Last Post: 08-12-2008, 01:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks