Initialize

 

function Initialize()

This procedure initializes the system and readies if for parsing. Normally, this procedure is called when a stream is opened.

Part 1: Prepare the Token Stack to parse.
Basically, a "Start" token is created and pushed onto the Token Stack which is used by the LALR Algorithm. The Initial LALR State and the Start Symbol are specified in the Compiled Grammar Table file.

Create a new token Start

Set the State property of Start to the Initial-LALR-State.
Set the Parent-Symbol property of Start to the Start-Symbol.

Push Start onto the LALR-Token-Stack.

Part 2: Set initial values.
Other code related to setting line counters, etc... can also be added to this procedure.

Set the Comment-Level to 0.
Clear the Input-Stack.

end function