views:

239

answers:

1

When I run make on the following Makefile, when is the symbol table built, if it even is?

LEX = flex
YACC = yacc
CC = gcc

calcu: y.tab.o lex.yy.o
    $(CC) -o calcu y.tab.o lex.yy.o -ly -lfl

y.tab.c y.tab.h: parser.y
    $(YACC) -d parser.y

y.tab.o: y.tab.c parser.h
    $(CC) -c y.tab.c

lex.yy.o: y.tab.h lex.yy.c 
    $(CC) -c lex.yy.c

lex.yy.c: calclexer.l parser.h
    $(LEX) calclexer.l

clean:
    rm *.o
    rm *.c
    rm calcu
+2  A: 

make doesn't build symbol tables (obviously the compilers and linkers it invokes will have to do that!). I'll assume you're referring to whatever the resulting calcu binary does wrt its input, instead.

If any such thing as a "symbol table" is ever built by calcu, it will be by code you inserted into parser.y that gets moved over into yacc.tab.c; as to when, it will be during the course of a calcu run over whatever its input is -- incrementally, as each syntax production including "symbol-table building code" matches.

Alex Martelli
I think the symbol table is completely built before the program is even run.
Phenom