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
|
||||
@ -200,7 +200,7 @@ begin
|
||||
Classification[126] := transitionClassOther; (* } *)
|
||||
Classification[127] := transitionClassSingle; (* ~ *)
|
||||
Classification[128] := transitionClassInvalid (* DEL *)
|
||||
END InitializeClassification;
|
||||
end;
|
||||
|
||||
proc CompareKeyword(Keyword: ARRAY OF CHAR; TokenStart: PLexerBuffer; TokenEnd: PLexerBuffer): BOOLEAN;
|
||||
var
|
||||
@ -217,19 +217,19 @@ begin
|
||||
end;
|
||||
Result := (Index = Length(Keyword)) AND (TokenStart = TokenEnd) AND Result;
|
||||
return Result
|
||||
END CompareKeyword;
|
||||
end;
|
||||
|
||||
(* Reached the end of file. *)
|
||||
proc TransitionActionEof(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
AToken^.Kind := lexerKindEof
|
||||
END TransitionActionEof;
|
||||
end;
|
||||
|
||||
(* Add the character to the token currently read and advance to the next character. *)
|
||||
proc TransitionActionAccumulate(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionAccumulate;
|
||||
end;
|
||||
|
||||
(* The current character is not a part of the token. Finish the token already
|
||||
* read. Don't advance to the next character. *)
|
||||
@ -253,7 +253,7 @@ begin
|
||||
if ALexer^.Start^ = '.' then
|
||||
AToken^.Kind := lexerKindDot
|
||||
end
|
||||
END TransitionActionFinalize;
|
||||
end;
|
||||
|
||||
(* An action for tokens containing multiple characters. *)
|
||||
proc TransitionActionComposite(ALexer: PLexer; AToken: PLexerToken);
|
||||
@ -276,14 +276,14 @@ begin
|
||||
AToken^.Kind := lexerKindAssignment
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionComposite;
|
||||
end;
|
||||
|
||||
(* Skip a space. *)
|
||||
proc TransitionActionSkip(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
INC(ALexer^.Current);
|
||||
INC(ALexer^.Start)
|
||||
END TransitionActionSkip;
|
||||
end;
|
||||
|
||||
(* Delimited string action. *)
|
||||
proc TransitionActionDelimited(ALexer: PLexer; AToken: PLexerToken);
|
||||
@ -298,13 +298,16 @@ begin
|
||||
AToken^.Kind := lexerKindString
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionDelimited;
|
||||
end;
|
||||
|
||||
(* Finalize keyword or identifier. *)
|
||||
proc 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;
|
||||
@ -400,7 +403,7 @@ begin
|
||||
AToken^.Kind := lexerKindBoolean;
|
||||
AToken^.booleanKind := FALSE
|
||||
end
|
||||
END TransitionActionKeyId;
|
||||
end;
|
||||
|
||||
(* Action for tokens containing only one character. The character cannot be
|
||||
* followed by other characters forming a composite token. *)
|
||||
@ -449,13 +452,13 @@ begin
|
||||
AToken^.Kind := lexerKindPipe
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionSingle;
|
||||
end;
|
||||
|
||||
(* Handle an integer literal. *)
|
||||
proc TransitionActionInteger(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
AToken^.Kind := lexerKindInteger
|
||||
END TransitionActionInteger;
|
||||
end;
|
||||
|
||||
proc SetDefaultTransition(CurrentState: TransitionState; DefaultAction: TransitionAction; NextState: TransitionState);
|
||||
var
|
||||
@ -486,7 +489,7 @@ begin
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassGreater)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassLess)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassOther)] := DefaultTransition
|
||||
END SetDefaultTransition;
|
||||
end;
|
||||
|
||||
(*
|
||||
* The transition table describes transitions from one state to another, given
|
||||
@ -740,7 +743,7 @@ begin
|
||||
|
||||
Transitions[ORD(transitionStateDecimalSuffix)][ORD(transitionClassX)].Action := NIL;
|
||||
Transitions[ORD(transitionStateDecimalSuffix)][ORD(transitionClassX)].NextState := transitionStateEnd
|
||||
END InitializeTransitions;
|
||||
end;
|
||||
|
||||
proc LexerInitialize(ALexer: PLexer; Input: File);
|
||||
begin
|
||||
@ -750,7 +753,7 @@ begin
|
||||
ALLOCATE(ALexer^.Buffer, ChunkSize);
|
||||
MemZero(ALexer^.Buffer, ChunkSize);
|
||||
ALexer^.Size := ChunkSize
|
||||
END LexerInitialize;
|
||||
end;
|
||||
|
||||
proc LexerCurrent(ALexer: PLexer): LexerToken;
|
||||
var
|
||||
@ -772,7 +775,7 @@ begin
|
||||
CurrentState := CurrentTransition.NextState
|
||||
end;
|
||||
return Result
|
||||
END LexerCurrent;
|
||||
end;
|
||||
|
||||
proc LexerLex(ALexer: PLexer): LexerToken;
|
||||
var
|
||||
@ -786,14 +789,14 @@ begin
|
||||
|
||||
Result := LexerCurrent(ALexer);
|
||||
return Result
|
||||
END LexerLex;
|
||||
end;
|
||||
|
||||
proc LexerDestroy(ALexer: PLexer);
|
||||
begin
|
||||
DEALLOCATE(ALexer^.Buffer, ALexer^.Size)
|
||||
END LexerDestroy;
|
||||
end;
|
||||
|
||||
BEGIN
|
||||
begin
|
||||
InitializeClassification();
|
||||
InitializeTransitions()
|
||||
END Lexer.
|
||||
end Lexer.
|
||||
|
Reference in New Issue
Block a user