[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A lot of prduction classes
Hi Mattias,
Sorry for the delay, I was under a ton of things to do. See below.
"Mattias Grönlund" wrote:
> Thanks for the quick answer, but I?m not sure if I explained my question
> clear enough.
> ...
Your're right! I didn't understand clearly your initial question; maybe
I read it too quickly...
> ...
> But, the duplication that I was referring was the duplication of
> Axxx-classes for an alternative. Lets take an example to illustrate this:
>
> goal = {a} a;
> a = import identifier semicolon;
My question is this:
why don't you rewrite this grammar as:
goal = {a} import identifier semicolon;
> And when we add a secondary alternative to goal:
> goal = {a} a |
> {b} b;
> a = import identifier semicolon;
> b = import identifier dot star semicolon;
and, of course:
goal = {a} import identifier semicolon |
{b} import identifier dot star semicolon;
> What I think is that it should be enough if the first grammar created one
> Axxx class:
> AA :: PGoal
>
> And that the extended grammar should add one extra class:
> AB :: PGoal
Having AA extend PGoal would be counter-intuitive (for novice users, at
least). Specially that you can get a similar AST if you write your
grammar as shown above.
Maybe there's a reason why you need a separate rule for "a"?
Etienne
--
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc. e-mail: egagnon@j-meg.com
Author of SableCC: http://www.sablecc.org/
and SableVM: http://www.sablevm.org/