Processing Label Declarations
Processing Label declarations is trivial. They are simply stored into symbol table as identifiers.
Procedure ProcessLabelDeclarations;
Var Id: PIdentifier;
AddData: Pointer;
begin
GetNextToken;
Repeat
CheckForNumericLabel;
Id := ExpectAndStoreIdentifier (2, AddData);
Id^.Token := Token_LabelIdentifier;
until not CheckAndGetNextToken (Token_Comma);
ExpectTokenAndGetNext (TOKEN_Semicolon);
end;
This procedure reads numeric label, checks limits and converts it to string identifier with hash value.
Procedure CheckForNumericLabel;
Var N: Byte;
begin
If Token <> Token_Constant then Exit;
If ConstantTypeDefRec.Ofs <> LongInt_TypeOffset then Exit;
If NumericConstant.LongRec.WordH <> 0 then Exit;
If NumericConstant.LongRec.WordL > 9999 then Exit;
Str (NumericConstant.LongRec.WordL: 4, CurrentIdentifier);
ShortInt (CurrentIdentifierHash) := - 4;
For N := 1 to 4 do
begin
If CurrentIdentifier [N] = ' ' then CurrentIdentifier [N] := '0';
Inc (CurrentIdentifierHash, Byte (CurrentIdentifier [N]) and $DF);
end;
CurrentIdentifierHash := CurrentIdentifierHash shl 1;
Token := Token_Identifier;
end;