I have the following grammar:
IdentifierName ::
IdentifierStart
IdentifierName IdentifierPart
Which using the word git
should be parsed into the following parse tree:
IdentifierName
/ \
IdentifierName IdentifierPart
/ \ |
IdentifierName IdentifierPart 't'
| |
IdentiiferStart 'i'
|
'g'
I want to write a recursive descent algorithm to do that. Now I have two options either write a recursive descent parser with backtracking or a predictive recursive descent parser. These both are not table-drive parsers. However, I've read that for the recursive descent with backtracking I need to eliminate left-recursion. The grammar in the question seems to be left recursive.
So am I right that I either need to refactor grammar or use predictive algorithm?