Does Rational Rose analyzer deals with typedef ?

Does Rational Rose analyzer deals with typedef ?

Post by o » Fri, 29 Jun 2001 22:54:31

I am trying to analyze some code I wrote.
an error appear in the line: typedef std::map<class,class> ...
I need to know if the rational analyzer can deal with typedef ?

1. When is a typedef name not a typedef name?

I'm working on a utility that includes a C parser, and I've hit a snag with
overloading of typedef names.  The problem is that typedef names and
struct/union members are in different namespaces, so that the following code
is legal:

typedef int foo;

struct bar
   foo foo;

    struct bar blah;
    foo bletch; = 1;

    /* ... */

It turns out that the  "foo foo;" declaration is only legal inside a
struct or union -- if one were to try to declare a variable named foo
within the scope of the typedef, a syntax error would result.

I've been working with a yacc grammar for C that is almost identical to
the one in uunet:net.sources/ansi.c.grammar.Z -- there are no explicit
allowances in that grammar for allowing typedef names in the rules for
struct_declarator_list or primary_expression.  

I've looked at the GCC parser, which uses a somewhat different grammar,
but the trick seems to be to find the right way to provide feedback to the
lexical analyzer, so that it will return an IDENTIFIER token for "foo"
used as a struct/union member, and a TYPE_NAME token the rest of the

I don't really understand what GCC is doing -- its lexical analyzer
seems to be doing some kind of lookup of the last declaration of an
identifier before deciding whether to return an IDENTIFIER or a TYPE_NAME.

Rewriting the grammar seems hopeless -- every variation I've come up
with resulted in reduce/reduce conflicts.

Has anyone modified ansi.c.grammar (or the lexical analyzer that comes
with it) to address this problem?   Believe it or not, I've actually
found code that relies on overloading of identifiers and typedef names,
and I'd *really* like to be able to run it through my parser!


-- Jim Lewis
   U.C. Berkeley
   Center for EUV Astrophysics

{ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.

2. Margins in Netscape

3. Rational Rose RealTime

4. Artificial Intelligence

5. Autopmated Testing From Rational Rose

6. x-symbol 4.4.2-beta and \package[latin1]{inputenc}

7. Automated Testing from Rational Rose

8. SMS and SP5

9. Rational Rose and SAS 8.2 Class model

10. Mastering UML with Rational Rose

11. Actor class dependency removal in ObjecTime (Rational Rose RT)

12. Rational Rose model of Visibroker C++ classes

13. CORBA tool -> Rational Rose