Hi there,
I indeed asked in another topic something about Syntax Analysis (parsing). But I believe that this needs a separate topic, just to make things more organized.
I have a few questions regarding compiler construction, and specifically Syntax Directed Translation. I'm really struggling to understand this part.
Question 1:
From my understanding, Syntax Directed Translation is semantic analysis. It adds rules and actions, but does not perform these actions.
The rules/actions are rather checked during type checking, but then my real question: isn't type checking part of the ''semantic analysis''? (which is again from my understanding, semantic analysis?)
In what order are these things happening now?
Lexical Analysis -> Syntax Analysis -> Semantic Analysis (=Syntax Directed Translation?) -> Intermediate Code Generation -> etc.
Is this the correct order? Where is type checking then performed? Because the dragonbook explains type checking during the intermediate code generation phase.
So is type checking during the intermediate code generation or semantic analysis?
Question 2:
I understand that you can combine phases of the compiler. If you combine the parts of Syntax Analysis and Semantic Analysis. Would you first create an AST and then traverse a second time to apply semantic checks? And by checks I mean: does it just apply rules but check them in a later phase (intermediate code generation; type checking?)
Thank you!