File Content: LALR States

Structure

cgt-lalr-states.gif (2172 bytes)

Each record describing a state in the LALR State Table is preceded by a byte field containing the value 76 - the ASCII code for "L". The file will contain one of these records for each state in the table. The Table Count record, which precedes any LALR records, will contain the total number of states.

A LALR State contains a series of actions that are performed based on the next token. The record mostly consists of a series of fields (in groups of 4) which describe each of these actions.

Initial Fields

Item Type Description
Index Integer This parameter holds the index of the state in the LALR State Table.
(Reserved) Empty This field is reserved for future use.
Action 0...n Described below.

Action 0...n

Value Type Description
Symbol Index Integer This field contains the index in the Symbol Table.
Action Integer This field contains a value that represents the action that LALR parsing engine is to take based on the symbol. These values are enumerated below.
Target Integer Depending on the value of the Action field, the target will hold different types of information.
(Reserved) Empty This field is reserved for future use.

'Action' Constants

Value Name Description
1 ActionShift This action indicates the symbol is to be shifted. The Target field will contain the index of the state in the LALR State table that the parsing engine will advance to.
2 ActionReduce This action denotes that the parser can reduce a rule. The Target field will contain the index of the rule in the Rule Table.
3 ActionGoto This action is used when a rule is reduced and the parser jumps to the state that represents the shifted nonterminal. The Target field will contain the index of the state in the LALR State table that the parsing engine will jump to after a reduction if completed.
4 ActionAccept When the parser encounters the Accept action for a given symbol, the source text is accepted as correct and complete. In this case, the Target field is not needed and should be ignored.