On Sat, 2007-03-24 at 22:19 -0700, Erick Tryzelaar wrote:
> Every time I run my parser, it always has at least one unreachable 
> nonterminal. Looking at the grammar that felix generates, it's easy to 
> see the problem:
> 
> nonterm(_poly_3928t_6311*) elk_1 {
>   -> t:TOK_TEXT
>     {
>        _poly_3928t_6311 *_x = new 
> _poly_3928t_6311(_nt_1007_1009(FLX_FPAR_PASS ptrcompile)
>       .apply(*t));
>        return _x;
>     }
> }
> nonterm(_poly_3928t_6311*) _nt_1007 {
>   fun dup(x) { return new _poly_3928t_6311(*x); }
>   fun del(x) { delete x; }
>   -> t:TOK_TEXT
>     {
>        _poly_3928t_6311 *_x = new 
> _poly_3928t_6311(_nt_1007_1009(FLX_FPAR_PASS ptrcompile)
>       .apply(*t));
>        return _x;
>     }
> }
> 
> If I read elkhound correctly, felix is generating the same nonterminal 
> twice. The only difference are the two extra functions. Is this a bug?

>From memory, this problem occurs because 

        parse .. with ...

is an expression which itself can contain grammar productions,
quite distinct from

        nonterm ...

which is a *declared* parser function. The apparent duplication
of productions is simply because they ARE duplicated in most
cases: once in the 'parse .. with' expression and once in the
'nonterm' definition.

So the difference is evident:

nonterm(_poly_3928t_6311*) elk_1 <<<<--- anonymous nonterminal
nonterm(_poly_3928t_6311*) _nt_1007 <<<<<--- declare nonterminal

This is poor design by me, but fixing it would require some
rewriting and rethinking: the parse/with expression is basically
an anonymous, top level only, grammar which can, if it likes,
call on the library of nonterminals previously defined.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to