On Tue, Apr 01, 2008 at 03:29:49PM +0200, Sebastián PEÑA SALDARRIAGA wrote:
> Fredrik Skeel Lokke a écrit :
> >
> >
> >I am getting the following error when trying to generate a parser:
[snip]
> >Verifying identifiers.
> >
> >java.lang.RuntimeException: [0,0] Redefinition of AFormalParameterList.
[snip]
> I think you have a production like
>
> formal_parameter_list = blablala | blablabla2;
>
> You need to specify a name for each option :
> formal_parameter_list = {firstblabla}blablala | {secondblabla}blablabla2;
>
> So that different classes for the same production are generated :
> AFormalParameterListFirstBlabla and AFormalParameterListSecondBlabla
>
> Hope this helps,
It would be nice if SableCC 4 could generate suitable names for cases
that use a CST->AST transformation. I find my self writing things like
the following quite often...
mul_exp {-> exp }
= { a } [exp]:add_exp {-> exp.exp }
| { b } [lhs]:mul_exp [op]:mul_op [rhs]:add_exp
{-> New exp.binary(lhs.exp, op.op, rhs.exp }
;
mul_op {-> op }
= { a } asterix {-> New op.mul(asterix) }
| { b } slash {-> New op.div(slash) }
| { c } percent {-> New op.mod(percent) }
;
add_exp {-> exp }
= { a } [exp]:etc_exp {-> exp.exp }
| { b } [lhs]:add_exp [op]:add_op [rhs]:add_exp
{-> New exp.binary(lhs.exp, op.op, rhs.exp }
;
add_op {-> op }
= { a } plus {-> New op.add(plus) }
| { b } minus {-> New op.sub(minus) }
;
etc_exp {-> exp } ....
None of those names really have a purpose, except to avoid the kind of
error message that Frederik suffered. Semicolons are used in other
generated names, and I'm pretty sure that a straightforward scheme
could be worked out, such as "production$a", "production$b", etc. If
you run out of single letters, then "production$aa", "production$ab",
etc. If CST->AST transformations are not being used the usual naming
rules would still have to apply.
BTW, I know this isn't the usual way that SableCC grammars are laid
out, but I find that lining things up vertically makes the whole thing
easier to follow. I'm sure other people have their own personal styles.
--
Jon Shapcott <[EMAIL PROTECTED]>
"This is the Space Age, and we are Here To Go" - William S. Burroughs
_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion