When a function call returns the activation stack will be popped and the values of the registers restored. During the first phase the interpreter will read the input file and create a list of the instructions found. During the second phase the interpreter will iterate through the list and execute each instruction. Parsing During the first phase of execution the interpreter will read the source file and parse the TVI program. The interpreter should only attempt to execute valid TVI source code and should print an appropriate error message if there is a syntax error in the file.
Most programming languages require a variable to be declared before it can be used.
However, the TVI programmer is allowed to use a variable before it has been declared, causing a slight problem for the parser. When parsing an instruction the parser needs to substitue variable names with its addresses, however if the variable's declaration hasn't been encountered yet the variable won't have an address assigned. The same is also true for procedures and labels. A procedure may be called before it has been defined, and a goto can jump to a statement later in the file. During the pre-processing pass the parser simply looks for variable declarations, procedure definitions, and labelled statements.