Transpile type section
This commit is contained in:
@ -1,16 +1,17 @@
|
||||
IMPLEMENTATION MODULE Lexer;
|
||||
implementation module Lexer;
|
||||
|
||||
FROM FIO IMPORT ReadNBytes;
|
||||
FROM SYSTEM IMPORT ADR;
|
||||
from FIO import ReadNBytes;
|
||||
from SYSTEM import ADR;
|
||||
|
||||
FROM Storage IMPORT DEALLOCATE, ALLOCATE;
|
||||
FROM Strings IMPORT Length;
|
||||
FROM MemUtils IMPORT MemZero;
|
||||
from Storage import DEALLOCATE, ALLOCATE;
|
||||
from Strings import Length;
|
||||
from MemUtils import MemZero;
|
||||
from StrCase import Lower;
|
||||
|
||||
CONST
|
||||
const
|
||||
ChunkSize = 65536;
|
||||
|
||||
TYPE
|
||||
type
|
||||
(*
|
||||
* Classification table assigns each possible character to a group (class). All
|
||||
* characters of the same group a handled equivalently.
|
||||
@ -59,11 +60,11 @@ TYPE
|
||||
transitionStateDecimalSuffix,
|
||||
transitionStateEnd
|
||||
);
|
||||
TransitionAction = PROCEDURE(PLexer, PLexerToken);
|
||||
Transition = RECORD
|
||||
TransitionAction = procedure(PLexer, PLexerToken);
|
||||
Transition = record
|
||||
Action: TransitionAction;
|
||||
NextState: TransitionState
|
||||
END;
|
||||
end;
|
||||
|
||||
VAR
|
||||
Classification: ARRAY[1..128] OF TransitionClass;
|
||||
@ -210,7 +211,7 @@ BEGIN
|
||||
Result := TRUE;
|
||||
|
||||
WHILE (Index < Length(Keyword)) AND (TokenStart <> TokenEnd) AND Result DO
|
||||
Result := Keyword[Index] = TokenStart^;
|
||||
Result := (Keyword[Index] = TokenStart^) OR (Lower(Keyword[Index]) = TokenStart^);
|
||||
INC(TokenStart);
|
||||
INC(Index)
|
||||
END;
|
||||
@ -344,6 +345,10 @@ BEGIN
|
||||
AToken^.Kind := lexerKindModule
|
||||
ELSIF CompareKeyword('IMPLEMENTATION', ALexer^.Start, ALexer^.Current) THEN
|
||||
AToken^.Kind := lexerKindImplementation
|
||||
ELSIF CompareKeyword('POINTER', ALexer^.Start, ALexer^.Current) THEN
|
||||
AToken^.Kind := lexerKindPointer
|
||||
ELSIF CompareKeyword('ARRAY', ALexer^.Start, ALexer^.Current) THEN
|
||||
AToken^.Kind := lexerKindArray
|
||||
ELSIF CompareKeyword('TRUE', ALexer^.Start, ALexer^.Current) THEN
|
||||
AToken^.Kind := lexerKindBoolean;
|
||||
AToken^.booleanKind := TRUE
|
||||
@ -685,7 +690,6 @@ VAR
|
||||
Result: LexerToken;
|
||||
BEGIN
|
||||
ALexer^.Current := ALexer^.Start;
|
||||
Result.Kind := lexerKindTrait;
|
||||
CurrentState := transitionStateStart;
|
||||
|
||||
WHILE CurrentState <> transitionStateEnd DO
|
||||
|
Reference in New Issue
Block a user