Let's suppose I have a code file that reads (I'll use Java-ish syntax) and it is being interpreted. Kind of like a ruby script.
class A{
int fieldName = 4;
A(){...}
void doSomething(){...}
}
A instanceOfA = new A();
A.fieldName = 7;
This is what I understand to happen when this file is interpreted.
- File is lexed and parsed
- AST or Parse tree is generated
- Parse tree is walked to generate code in the runtime to represent the class.
- Then what happens? How is the definition turned into an instance? And what kind of internal representation is require to represent the class? Does the interpreter keep the AST for the class around for re-processing each time an instance is created or is some other form created?
I've been following the patterns in Terrence Parr's Language Implementations Patterns book. I think understand how to build the symbol table and scope objects. I'm just a little fuzzy on how take a structure like a class and create an instance of it.