Hi Søren,

The section on backtracking parsers in Ter's "Language Implementation
Patterns" book really helped me to understand this issue better:
http://www.pragprog.com/titles/tpdsl/language-implementation-patterns

Stealing a relevant example from the book involving C++ function
definitions and declarations...

void bar() {...} // a function definition
void bar();     // a function declaration (forward declaration)

"Because C++ function headers can be arbitrarily long, the
distinguishing token does not appear at a fixed lookahead position
from the left side of the statement. Consequently, Pattern 4, LL(k)
Recursive-Descent Parser, on page 59 is too weak to distinguish
function definitions from declarations using a natural grammar."

So, in this example you can't refactor the grammar to LL(k) but you
can have a simple, readable grammar for this part of the language if
you work with a back-tracking parser.

Hope this helps.

Michael

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to