Transpile procedures and statements
This commit is contained in:
@ -70,8 +70,8 @@ var
|
||||
Classification: ARRAY[1..128] OF TransitionClass;
|
||||
Transitions: ARRAY[0..15] OF ARRAY[0..21] OF Transition;
|
||||
|
||||
PROCEDURE InitializeClassification();
|
||||
BEGIN
|
||||
proc InitializeClassification();
|
||||
begin
|
||||
Classification[1] := transitionClassEof; (* NUL *)
|
||||
Classification[2] := transitionClassInvalid; (* SOH *)
|
||||
Classification[3] := transitionClassInvalid; (* STX *)
|
||||
@ -202,195 +202,265 @@ BEGIN
|
||||
Classification[128] := transitionClassInvalid (* DEL *)
|
||||
END InitializeClassification;
|
||||
|
||||
PROCEDURE CompareKeyword(Keyword: ARRAY OF CHAR; TokenStart: PLexerBuffer; TokenEnd: PLexerBuffer): BOOLEAN;
|
||||
VAR
|
||||
proc CompareKeyword(Keyword: ARRAY OF CHAR; TokenStart: PLexerBuffer; TokenEnd: PLexerBuffer): BOOLEAN;
|
||||
var
|
||||
Result: BOOLEAN;
|
||||
Index: CARDINAL;
|
||||
BEGIN
|
||||
begin
|
||||
Index := 0;
|
||||
Result := TRUE;
|
||||
|
||||
WHILE (Index < Length(Keyword)) AND (TokenStart <> TokenEnd) AND Result DO
|
||||
while (Index < Length(Keyword)) AND (TokenStart <> TokenEnd) AND Result DO
|
||||
Result := (Keyword[Index] = TokenStart^) OR (Lower(Keyword[Index]) = TokenStart^);
|
||||
INC(TokenStart);
|
||||
INC(Index)
|
||||
END;
|
||||
RETURN (Index = Length(Keyword)) AND (TokenStart = TokenEnd) AND Result
|
||||
end;
|
||||
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
|
||||
proc 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
|
||||
proc 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);
|
||||
BEGIN
|
||||
IF ALexer^.Start^ = ':' THEN
|
||||
proc TransitionActionFinalize(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
if ALexer^.Start^ = ':' then
|
||||
AToken^.Kind := lexerKindColon
|
||||
ELSIF ALexer^.Start^ = '>' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '>' then
|
||||
AToken^.Kind := lexerKindGreaterThan
|
||||
ELSIF ALexer^.Start^ = '<' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '<' then
|
||||
AToken^.Kind := lexerKindLessThan
|
||||
ELSIF ALexer^.Start^ = '(' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '(' then
|
||||
AToken^.Kind := lexerKindLeftParen
|
||||
ELSIF ALexer^.Start^ = '-' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '-' then
|
||||
AToken^.Kind := lexerKindLeftParen
|
||||
ELSIF ALexer^.Start^ = '.' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '.' then
|
||||
AToken^.Kind := lexerKindDot
|
||||
END
|
||||
end
|
||||
END TransitionActionFinalize;
|
||||
|
||||
(* An action for tokens containing multiple characters. *)
|
||||
PROCEDURE TransitionActionComposite(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
IF ALexer^.Start^ = '<' THEN
|
||||
IF ALexer^.Current^ = '>' THEN
|
||||
proc TransitionActionComposite(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
if ALexer^.Start^ = '<' then
|
||||
if ALexer^.Current^ = '>' then
|
||||
AToken^.Kind := lexerKindNotEqual
|
||||
ELSIF ALexer^.Current^ = '=' THEN
|
||||
end;
|
||||
if ALexer^.Current^ = '=' then
|
||||
AToken^.Kind := lexerKindLessEqual
|
||||
END
|
||||
ELSIF (ALexer^.Start^ = '>') AND (ALexer^.Current^ = '=') THEN
|
||||
end
|
||||
end;
|
||||
if (ALexer^.Start^ = '>') AND (ALexer^.Current^ = '=') then
|
||||
AToken^.Kind := lexerKindGreaterEqual
|
||||
ELSIF (ALexer^.Start^ = '.') AND (ALexer^.Current^ = '.') THEN
|
||||
end;
|
||||
if (ALexer^.Start^ = '.') AND (ALexer^.Current^ = '.') then
|
||||
AToken^.Kind := lexerKindRange
|
||||
ELSIF (ALexer^.Start^ = ':') AND (ALexer^.Current^ = '=') THEN
|
||||
end;
|
||||
if (ALexer^.Start^ = ':') AND (ALexer^.Current^ = '=') then
|
||||
AToken^.Kind := lexerKindAssignment
|
||||
END;
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionComposite;
|
||||
|
||||
(* Skip a space. *)
|
||||
PROCEDURE TransitionActionSkip(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
proc TransitionActionSkip(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
INC(ALexer^.Current);
|
||||
INC(ALexer^.Start)
|
||||
END TransitionActionSkip;
|
||||
|
||||
(* 0x04. Delimited string action. *)
|
||||
PROCEDURE TransitionActionDelimited(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
IF ALexer^.Start^ = '(' THEN
|
||||
(* Delimited string action. *)
|
||||
proc TransitionActionDelimited(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
if ALexer^.Start^ = '(' then
|
||||
AToken^.Kind := lexerKindComment
|
||||
ELSIF ALexer^.Start^ = '"' THEN
|
||||
end;
|
||||
if ALexer^.Start^ = '"' then
|
||||
AToken^.Kind := lexerKindCharacter
|
||||
ELSIF ALexer^.Start^ = "'" THEN
|
||||
end;
|
||||
if ALexer^.Start^ = "'" then
|
||||
AToken^.Kind := lexerKindString
|
||||
END;
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionDelimited;
|
||||
|
||||
(* Finalize keyword or identifier. *)
|
||||
PROCEDURE TransitionActionKeyId(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
IF CompareKeyword('PROGRAM', ALexer^.Start, ALexer^.Current) THEN
|
||||
proc TransitionActionKeyId(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
AToken^.Kind := lexerKindIdentifier;
|
||||
|
||||
if CompareKeyword('PROGRAM', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindProgram
|
||||
ELSIF CompareKeyword('IMPORT', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('IMPORT', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindImport
|
||||
ELSIF CompareKeyword('CONST', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('CONST', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindConst
|
||||
ELSIF CompareKeyword('VAR', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('VAR', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindVar
|
||||
ELSIF CompareKeyword('IF', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('IF', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindIf
|
||||
ELSIF CompareKeyword('THEN', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('THEN', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindThen
|
||||
ELSIF CompareKeyword('ELSIF', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('ELSIF', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindElsif
|
||||
ELSIF CompareKeyword('ELSE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('ELSE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindElse
|
||||
ELSIF CompareKeyword('WHILE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('WHILE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindWhile
|
||||
ELSIF CompareKeyword('DO', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('DO', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindDo
|
||||
ELSIF CompareKeyword('PROCEDURE', ALexer^.Start, ALexer^.Current) OR CompareKeyword('proc', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('proc', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindProc
|
||||
ELSIF CompareKeyword('BEGIN', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('BEGIN', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindBegin
|
||||
ELSIF CompareKeyword('END', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('END', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindEnd
|
||||
ELSIF CompareKeyword('TYPE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('TYPE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindType
|
||||
ELSIF CompareKeyword('RECORD', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('RECORD', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindRecord
|
||||
ELSIF CompareKeyword('UNION', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('UNION', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindUnion
|
||||
ELSIF CompareKeyword('NIL', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('NIL', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindNull
|
||||
ELSIF CompareKeyword('AND', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('AND', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindAnd
|
||||
ELSIF CompareKeyword('OR', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('OR', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindOr
|
||||
ELSIF CompareKeyword('RETURN', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('RETURN', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindReturn
|
||||
ELSIF CompareKeyword('DEFINITION', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('DEFINITION', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindDefinition
|
||||
ELSIF CompareKeyword('TO', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('TO', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindTo
|
||||
ELSIF CompareKeyword('CASE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('CASE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindCase
|
||||
ELSIF CompareKeyword('OF', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('OF', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindOf
|
||||
ELSIF CompareKeyword('FROM', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('FROM', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindFrom
|
||||
ELSIF CompareKeyword('MODULE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('MODULE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindModule
|
||||
ELSIF CompareKeyword('IMPLEMENTATION', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('IMPLEMENTATION', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindImplementation
|
||||
ELSIF CompareKeyword('POINTER', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('POINTER', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindPointer
|
||||
ELSIF CompareKeyword('ARRAY', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('ARRAY', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindArray
|
||||
ELSIF CompareKeyword('TRUE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('TRUE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindBoolean;
|
||||
AToken^.booleanKind := TRUE
|
||||
ELSIF CompareKeyword('FALSE', ALexer^.Start, ALexer^.Current) THEN
|
||||
end;
|
||||
if CompareKeyword('FALSE', ALexer^.Start, ALexer^.Current) then
|
||||
AToken^.Kind := lexerKindBoolean;
|
||||
AToken^.booleanKind := FALSE
|
||||
ELSE
|
||||
AToken^.Kind := lexerKindIdentifier
|
||||
END;
|
||||
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);
|
||||
BEGIN
|
||||
CASE ALexer^.Current^ OF
|
||||
'&': AToken^.Kind := lexerKindAnd |
|
||||
';': AToken^.Kind := lexerKindSemicolon |
|
||||
',': AToken^.Kind := lexerKindComma |
|
||||
')': AToken^.Kind := lexerKindRightParen |
|
||||
'[': AToken^.Kind := lexerKindLeftSquare |
|
||||
']': AToken^.Kind := lexerKindRightSquare |
|
||||
'^': AToken^.Kind := lexerKindHat |
|
||||
'=': AToken^.Kind := lexerKindEqual |
|
||||
'+': AToken^.Kind := lexerKindPlus |
|
||||
'/': AToken^.Kind := lexerKindDivision |
|
||||
'%': AToken^.Kind := lexerKindRemainder |
|
||||
'@': AToken^.Kind := lexerKindAt |
|
||||
'|': AToken^.Kind := lexerKindPipe
|
||||
END;
|
||||
proc TransitionActionSingle(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
if ALexer^.Current^ = '&' then
|
||||
AToken^.Kind := lexerKindAnd
|
||||
end;
|
||||
if ALexer^.Current^ = ';' then
|
||||
AToken^.Kind := lexerKindSemicolon
|
||||
end;
|
||||
if ALexer^.Current^ = ',' then
|
||||
AToken^.Kind := lexerKindComma
|
||||
end;
|
||||
if ALexer^.Current^ = ',' then
|
||||
AToken^.Kind := lexerKindComma
|
||||
end;
|
||||
if ALexer^.Current^ = ')' then
|
||||
AToken^.Kind := lexerKindRightParen
|
||||
end;
|
||||
if ALexer^.Current^ = '[' then
|
||||
AToken^.Kind := lexerKindLeftSquare
|
||||
end;
|
||||
if ALexer^.Current^ = ']' then
|
||||
AToken^.Kind := lexerKindRightSquare
|
||||
end;
|
||||
if ALexer^.Current^ = '^' then
|
||||
AToken^.Kind := lexerKindHat
|
||||
end;
|
||||
if ALexer^.Current^ = '=' then
|
||||
AToken^.Kind := lexerKindEqual
|
||||
end;
|
||||
if ALexer^.Current^ = '+' then
|
||||
AToken^.Kind := lexerKindPlus
|
||||
end;
|
||||
if ALexer^.Current^ = '/' then
|
||||
AToken^.Kind := lexerKindDivision
|
||||
end;
|
||||
if ALexer^.Current^ = '%' then
|
||||
AToken^.Kind := lexerKindRemainder
|
||||
end;
|
||||
if ALexer^.Current^ = '@' then
|
||||
AToken^.Kind := lexerKindAt
|
||||
end;
|
||||
if ALexer^.Current^ = '|' then
|
||||
AToken^.Kind := lexerKindPipe
|
||||
end;
|
||||
INC(ALexer^.Current)
|
||||
END TransitionActionSingle;
|
||||
|
||||
(* Handle an integer literal. *)
|
||||
PROCEDURE TransitionActionInteger(ALexer: PLexer; AToken: PLexerToken);
|
||||
BEGIN
|
||||
proc TransitionActionInteger(ALexer: PLexer; AToken: PLexerToken);
|
||||
begin
|
||||
AToken^.Kind := lexerKindInteger
|
||||
END TransitionActionInteger;
|
||||
|
||||
PROCEDURE SetDefaultTransition(CurrentState: TransitionState; DefaultAction: TransitionAction; NextState: TransitionState);
|
||||
VAR DefaultTransition: Transition;
|
||||
BEGIN
|
||||
proc SetDefaultTransition(CurrentState: TransitionState; DefaultAction: TransitionAction; NextState: TransitionState);
|
||||
var
|
||||
DefaultTransition: Transition;
|
||||
begin
|
||||
DefaultTransition.Action := DefaultAction;
|
||||
DefaultTransition.NextState := NextState;
|
||||
|
||||
@ -415,7 +485,7 @@ BEGIN
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassDoubleQuote)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassGreater)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassLess)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassOther)] := DefaultTransition;
|
||||
Transitions[ORD(CurrentState)][ORD(transitionClassOther)] := DefaultTransition
|
||||
END SetDefaultTransition;
|
||||
|
||||
(*
|
||||
@ -434,8 +504,8 @@ END SetDefaultTransition;
|
||||
* For the meaning of actions see labels in the lex_next function, which
|
||||
* handles each action.
|
||||
*)
|
||||
PROCEDURE InitializeTransitions();
|
||||
BEGIN
|
||||
proc InitializeTransitions();
|
||||
begin
|
||||
(* Start state. *)
|
||||
Transitions[ORD(transitionStateStart)][ORD(transitionClassInvalid)].Action := NIL;
|
||||
Transitions[ORD(transitionStateStart)][ORD(transitionClassInvalid)].NextState := transitionStateEnd;
|
||||
@ -672,8 +742,8 @@ BEGIN
|
||||
Transitions[ORD(transitionStateDecimalSuffix)][ORD(transitionClassX)].NextState := transitionStateEnd
|
||||
END InitializeTransitions;
|
||||
|
||||
PROCEDURE LexerInitialize(ALexer: PLexer; Input: File);
|
||||
BEGIN
|
||||
proc LexerInitialize(ALexer: PLexer; Input: File);
|
||||
begin
|
||||
ALexer^.Input := Input;
|
||||
ALexer^.Length := 0;
|
||||
|
||||
@ -682,41 +752,44 @@ BEGIN
|
||||
ALexer^.Size := ChunkSize
|
||||
END LexerInitialize;
|
||||
|
||||
PROCEDURE LexerCurrent(ALexer: PLexer): LexerToken;
|
||||
VAR
|
||||
proc LexerCurrent(ALexer: PLexer): LexerToken;
|
||||
var
|
||||
CurrentClass: TransitionClass;
|
||||
CurrentState: TransitionState;
|
||||
CurrentTransition: Transition;
|
||||
Result: LexerToken;
|
||||
BEGIN
|
||||
begin
|
||||
ALexer^.Current := ALexer^.Start;
|
||||
CurrentState := transitionStateStart;
|
||||
|
||||
WHILE CurrentState <> transitionStateEnd DO
|
||||
while CurrentState <> transitionStateEnd DO
|
||||
CurrentClass := Classification[ORD(ALexer^.Current^) + 1];
|
||||
|
||||
CurrentTransition := Transitions[ORD(CurrentState)][ORD(CurrentClass)];
|
||||
IF CurrentTransition.Action <> NIL THEN
|
||||
if CurrentTransition.Action <> NIL then
|
||||
CurrentTransition.Action(ALexer, ADR(Result))
|
||||
END;
|
||||
end;
|
||||
CurrentState := CurrentTransition.NextState
|
||||
END;
|
||||
RETURN Result
|
||||
end;
|
||||
return Result
|
||||
END LexerCurrent;
|
||||
|
||||
PROCEDURE LexerLex(ALexer: PLexer): LexerToken;
|
||||
BEGIN
|
||||
IF ALexer^.Length = 0 THEN
|
||||
proc LexerLex(ALexer: PLexer): LexerToken;
|
||||
var
|
||||
Result: LexerToken;
|
||||
begin
|
||||
if ALexer^.Length = 0 then
|
||||
ALexer^.Length := ReadNBytes(ALexer^.Input, ChunkSize, ALexer^.Buffer);
|
||||
ALexer^.Current := ALexer^.Buffer
|
||||
END;
|
||||
end;
|
||||
ALexer^.Start := ALexer^.Current;
|
||||
|
||||
RETURN LexerCurrent(ALexer)
|
||||
Result := LexerCurrent(ALexer);
|
||||
return Result
|
||||
END LexerLex;
|
||||
|
||||
PROCEDURE LexerDestroy(ALexer: PLexer);
|
||||
BEGIN
|
||||
proc LexerDestroy(ALexer: PLexer);
|
||||
begin
|
||||
DEALLOCATE(ALexer^.Buffer, ALexer^.Size)
|
||||
END LexerDestroy;
|
||||
|
||||
|
Reference in New Issue
Block a user