views:

198

answers:

2

I'm writing an assembler for a microprocessor I'm creating using lex/yacc.

I'd like to implement labels in my assembler code, and I thought a good way to do this would be to have a dictionary of labels in the form {name:line#}. I could then check when inserting a label, if it's already defined, its an error.

So how can I use a dictionary structure in lex/yacc?

+1  A: 

Look at the various hash table implementations to find one you like.

MarkusQ
A: 

for labels? create a structure with a file pointer,and initialise that t the position of the found label.......and when u come across the label declaration.......accesss that pointer and fill that blank with locctr.........

gymnos