[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: name conflicts



Hi Navin,

I will try to restate your problem.

I am seeking everyone's feedback on a possible solution.

PROBLEM

The problem is not restricted to productions with single alternatives.
Here's the general Problem:

b_c = {a} ... | ...;
c = {a_b} ... | ...;

generates the 2 following alternative classes:
AABC and AABC

POSSIBLE SOLUTION

To resolve this problem, we need to add an explicit separator between the
name of the alternative and the name of the production as in:
AA_BC and AAB_C

If we do this, we could as well change the order of names so that:

statement = {if} ... | {for} ...;

gives:
Statement_If_Alt, Statement_For_alt, Statement_Prod

ADVANTAGES

-Directory listings ("ls" on UNIX, "dir" on DOS, ...)  put all related
classes together:-))))
-Your problem is solved

DRAWBACKS

- Not Backward compatible...
- Class name are longer
- "_" is not nice in a class name (aesthetics)

ADDITIONAL PROBLEM TO THINK ABOUT

There is an additional problem that I would like to address, which is
automatic naming of alternatives. If I was to implement an automatic naming
scheme for alternatives, what should it be?

By experience (SableCC 1.0), using numbers is not good. It results in
confusing alternative names. (e.g. ASatement5, ASatement6 do not help in
knowing which one is the FOR or the IF statement.)

I am thinking of something like taking the first distinctive element of an
alternative, and if this is not enough, then use numbers.
For example:

  prod = a b c | a b d | b d c | b d;

would be identical to:

  prod = {a} a b c | {b} a b d | {d} b d c | {b2} b d;
OR
  prod = {a} a b c | {b1} a b d | {d} b d c | {b2} b d;

CALL FOR SUGGESTIONS

I am open to suggestions. What should I implement?

Etienne

-----Original Message-----
From: Navindra Umanee <navindra@cs.mcgill.ca>
To: sablecc-list@sable.mcgill.ca <sablecc-list@sable.mcgill.ca>
Date: Tuesday, May 26, 1998 8:49 PM
Subject: name conflicts


>Montreal Tue May 26 20:20:27 1998
>
>statement =
>  {if_then}                      /* Node is called AIfThenStatement */
>    if_then_statement |
>
>  {while}                        /* Node is called AWhileStatement */
>    while_statement;
>
>if_then_statement =              /* Node is called AIfThenStatement */
>  blah;
>
>while_statement =               /* Node is called AWhileStatement */
>  bleh;
>
>Wouldn't it be nice if SableCC didn't generate such conflicts?  Maybe
>it would be nice if productions with single alternatives had a
>different prefix as opposed to productions with multiple alternatives
>(right now the prefix is A in both cases).
>
>Navin