1

I'm building up a Symbol Table for a compiler of a subset of C++.

My question here is how to deal with the scope in objects. I mean, in a normal language such as Pascal we should create a Symbol Table for every scope. But with C++ should I consider another approche for the case of methods and attrubtes of an object?

Regards.

FranTastic
  • 61
  • 6

1 Answers1

0

I'd say an object has a symbol table for every scope for its methods and attributes, plus another table for friend class and methods.

It's just an idea.

Joel
  • 3,427
  • 5
  • 38
  • 60
  • It could work. But, what about the persistency of the tables? Are it the same as with the others? – FranTastic May 11 '11 at 09:10
  • Yes, a friend declaration is definitive, just like a method/attribute scope definition. There are no way to change these informations once they are set. And they can be set only once, according to C++ syntax. – Joel May 11 '11 at 09:13
  • I'm sorry for asking this 10 years later, but is it possible to have a class diagram that shows how the object symbol table differs from normal scoped symbol tables ? =o – Lorenzo Apr 14 '21 at 12:33