On Tue, 2006-03-07 at 12:12 +0100, Nicolas Cannasse wrote:
> LL(1) parser don't need "generators"
> since you can directly express your grammar in terms of patterns.
> For exemple if you have a BNF :
> parent := '(' expr ')'
> you can encode it this way :
>
> function parent(s) {
> match s {
> | [< ParentOpen; e = expr s; ParentClose >] -> ....
> }
> }
Not clear how that works! For LL(1) this requires the
head token of the stream pattern to be unique?
I'm curious because Felix has a user defined grammar
system using an standard Recursive Descent implementation.
This is LL(inf). The problem is "Syntax Error". Its the
only possible diagnostic you can get.
LL(1) doesn't have that problem because it is deterministic ..
but it definitely DOES require a generator .. unless you're
willing to manually left factor your grammar.
Felix can't require left factoring, because grammar extensions
come from separate places and just have to be 'added'.
So either I use a generator to left factor, or I'm stuck
without any possibility of sensible diagnostics.
Well .. I am think of a heuristic which checks if there
is more than one alternative .. if not we can advance the
backtracking cut point, and get closer to the real error.
--
John Skaller <skaller at users dot sourceforge dot net>
Async PL, Realtime software consultants
Checkout Felix: http://felix.sourceforge.net
--
Neko : One VM to run them all
(http://nekovm.org)