I have been racking my brain over this for a while and I can't figure it out.
I have some kind of code like this in my c-like language:
struct PersonInfo {
int numFriends;
int favColour;
}
struct Person {
PersonInfo info;
string firstName;
string lastName;
};
Person john;
john.info.numFriends; // <- specifically this part here!
How can I check that the path expression 'john.info.numFriends' is correct, i.e. all of the symbols exist. john exists, john is an instance of the structure Person, and we are accessing a field 'info' which exists, and also contains the field 'numFriends'.
What is a common algorithm/approach that is used to do this type of error check in compilers?