[9fans] scopes in kencc - Plan9

This is a discussion on [9fans] scopes in kencc - Plan9 ; I'm tracing through how the symbol table in kencc is maintained, and I'm not finding the part where scopes are maintained. E.g., when the compiler sees the declaration of *t in typdef int t; t foo; struct bar { int ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [9fans] scopes in kencc

  1. [9fans] scopes in kencc

    I'm tracing through how the symbol table in kencc is maintained, and
    I'm not finding the part where scopes are maintained.

    E.g., when the compiler sees the declaration of *t in

    typdef int t;
    t foo;

    struct bar
    {
    int *t;
    };

    where is it determined that LNAME is returned when *t is scanned
    rather than LTYPE (the way it is returned in the declaration of foo)?

    --Joel

  2. Re: [9fans] scopes in kencc

    > where is it determined that LNAME is returned when *t is scanned
    > rather than LTYPE (the way it is returned in the declaration of foo)?


    grep shows that /sys/src/cmd/cc/lex.c is relevant,
    since it contains

    s = lookup();
    if(s->macro) {
    ...
    }
    yylval.sym = s;
    if(s->class == CTYPEDEF || s->class == CTYPESTR)
    return LTYPE;
    return s->lexical;

    for the relevant bit of lexing. you could trace back and
    see how s->class gets set.

    russ


+ Reply to Thread