Make procedure name after the end
This commit is contained in:
@ -5,7 +5,7 @@ FROM SYSTEM IMPORT ADR;
|
||||
|
||||
FROM Storage IMPORT DEALLOCATE, ALLOCATE;
|
||||
FROM Strings IMPORT Length;
|
||||
FROM MemUtils IMPORT MemZero;
|
||||
FROM MemUtils IMPORT MemCopy, MemZero;
|
||||
FROM StrCase IMPORT Lower;
|
||||
|
||||
CONST
|
||||
@ -201,7 +201,6 @@ BEGIN
|
||||
Classification[127] := transitionClassSingle; (* ~ *)
|
||||
Classification[128] := transitionClassInvalid (* DEL *)
|
||||
END InitializeClassification;
|
||||
|
||||
PROCEDURE CompareKeyword(Keyword: ARRAY OF CHAR; TokenStart: PLexerBuffer; TokenEnd: PLexerBuffer): BOOLEAN;
|
||||
VAR
|
||||
Result: BOOLEAN;
|
||||
@ -218,19 +217,16 @@ BEGIN
|
||||
Result := (Index = Length(Keyword)) AND (TokenStart = TokenEnd) AND Result;
|
||||
RETURN Result
|
||||
END CompareKeyword;
|
||||
|
||||
(* Reached the end of file. *)
|
||||
PROCEDURE TransitionActionEof(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
AToken^.Kind := lexerKindEof
|
||||
END TransitionActionEof;
|
||||
|
||||
(* Add the character to the token currently read and advance to the next character. *)
|
||||
PROCEDURE TransitionActionAccumulate(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionAccumulate;
|
||||
|
||||
(* The current character is not a part of the token. Finish the token already
|
||||
* read. Don't advance to the next character. *)
|
||||
PROCEDURE TransitionActionFinalize(ALexer: PLexer; AToken: PLexerToken);
|
||||
@ -254,7 +250,6 @@ BEGIN
|
||||
AToken^.Kind := lexerKindDot
|
||||
END
|
||||
END TransitionActionFinalize;
|
||||
|
||||
(* An action for tokens containing multiple characters. *)
|
||||
PROCEDURE TransitionActionComposite(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
@ -277,14 +272,12 @@ BEGIN
|
||||
END;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionComposite;
|
||||
|
||||
(* Skip a space. *)
|
||||
PROCEDURE TransitionActionSkip(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
INC(ALexer^.Current);
|
||||
INC(ALexer^.Start)
|
||||
END TransitionActionSkip;
|
||||
|
||||
(* Delimited string action. *)
|
||||
PROCEDURE TransitionActionDelimited(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
@ -299,12 +292,14 @@ BEGIN
|
||||
END;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionDelimited;
|
||||
|
||||
(* Finalize keyword or identifier. *)
|
||||
PROCEDURE TransitionActionKeyId(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
AToken^.Kind := lexerKindIdentifier;
|
||||
|
||||
AToken^.identifierKind[1] := ALexer^.Current - ALexer^.Start;
|
||||
MemCopy(ALexer^.Start, ORD(AToken^.identifierKind[1]), ADR(AToken^.identifierKind[2]));
|
||||
|
||||
IF CompareKeyword('PROGRAM', ALexer^.Start, ALexer^.Current) THEN
|
||||
AToken^.Kind := lexerKindProgram
|
||||
END;
|
||||
@ -401,7 +396,6 @@ BEGIN
|
||||
AToken^.booleanKind := FALSE
|
||||
END
|
||||
END TransitionActionKeyId;
|
||||
|
||||
(* Action for tokens containing only one character. The character cannot be
|
||||
* followed by other characters forming a composite token. *)
|
||||
PROCEDURE TransitionActionSingle(ALexer: PLexer; AToken: PLexerToken);
|
||||
@ -450,13 +444,11 @@ BEGIN
|
||||
END;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionSingle;
|
||||
|
||||
(* Handle an integer literal. *)
|
||||
PROCEDURE TransitionActionInteger(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
AToken^.Kind := lexerKindInteger
|
||||
END TransitionActionInteger;
|
||||
|
||||
PROCEDURE SetDefaultTransition(CurrentState: TransitionState; DefaultAction: TransitionAction; NextState: TransitionState);
|
||||
VAR
|
||||
DefaultTransition: Transition;
|
||||
@ -487,7 +479,6 @@ BEGIN
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassLess)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassOther)] := DefaultTransition
|
||||
END SetDefaultTransition;
|
||||
|
||||
(*
|
||||
* The transition table describes transitions from one state to another, given
|
||||
* a symbol (character class).
|
||||
@ -741,7 +732,6 @@ BEGIN
|
||||
Transitions[ORD(transitionStateDecimalSuffix)][ORD(transitionClassX)].Action := NIL;
|
||||
Transitions[ORD(transitionStateDecimalSuffix)][ORD(transitionClassX)].NextState := transitionStateEnd
|
||||
END InitializeTransitions;
|
||||
|
||||
PROCEDURE LexerInitialize(ALexer: PLexer; Input: File);
|
||||
BEGIN
|
||||
ALexer^.Input := Input;
|
||||
@ -751,7 +741,6 @@ BEGIN
|
||||
MemZero(ALexer^.Buffer, ChunkSize);
|
||||
ALexer^.Size := ChunkSize
|
||||
END LexerInitialize;
|
||||
|
||||
PROCEDURE LexerCurrent(ALexer: PLexer): LexerToken;
|
||||
VAR
|
||||
CurrentClass: TransitionClass;
|
||||
@ -773,7 +762,6 @@ BEGIN
|
||||
END;
|
||||
RETURN Result
|
||||
END LexerCurrent;
|
||||
|
||||
PROCEDURE LexerLex(ALexer: PLexer): LexerToken;
|
||||
VAR
|
||||
Result: LexerToken;
|
||||
@ -787,12 +775,10 @@ BEGIN
|
||||
Result := LexerCurrent(ALexer);
|
||||
RETURN Result
|
||||
END LexerLex;
|
||||
|
||||
PROCEDURE LexerDestroy(ALexer: PLexer);
|
||||
BEGIN
|
||||
DEALLOCATE(ALexer^.Buffer, ALexer^.Size)
|
||||
END LexerDestroy;
|
||||
|
||||
BEGIN
|
||||
InitializeClassification();
|
||||
InitializeTransitions()
|
||||
|
Reference in New Issue
Block a user