|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
module;
|
|
|
|
|
|
|
|
|
|
from FIO import ReadNBytes, StdErr;
|
|
|
|
|
from FIO import ReadNBytes;
|
|
|
|
|
from SYSTEM import ADR, TSIZE;
|
|
|
|
|
|
|
|
|
|
from DynamicStrings import String, InitStringCharStar, KillString;
|
|
|
|
@ -64,8 +64,8 @@ type
|
|
|
|
|
);
|
|
|
|
|
TransitionAction = proc(PLexer, PLexerToken);
|
|
|
|
|
Transition = record
|
|
|
|
|
Action: TransitionAction;
|
|
|
|
|
NextState: TransitionState
|
|
|
|
|
action: TransitionAction;
|
|
|
|
|
next_state: TransitionState
|
|
|
|
|
end;
|
|
|
|
|
TransitionClasses = [22]Transition;
|
|
|
|
|
|
|
|
|
@ -209,25 +209,31 @@ begin
|
|
|
|
|
i := 129;
|
|
|
|
|
while i <= 256 do
|
|
|
|
|
classification[i] := transitionClassOther;
|
|
|
|
|
i := i + 1
|
|
|
|
|
INC(i)
|
|
|
|
|
end
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
proc compare_keyword(Keyword: ARRAY OF CHAR, TokenStart: PLexerBuffer, TokenEnd: PLexerBuffer) -> BOOLEAN;
|
|
|
|
|
proc compare_keyword(keyword: ARRAY OF CHAR, token_start: PLexerBuffer, token_end: PLexerBuffer) -> BOOLEAN;
|
|
|
|
|
var
|
|
|
|
|
result: BOOLEAN;
|
|
|
|
|
index: CARDINAL;
|
|
|
|
|
keyword_length: CARDINAL;
|
|
|
|
|
continue: BOOLEAN;
|
|
|
|
|
begin
|
|
|
|
|
index := 0;
|
|
|
|
|
result := true;
|
|
|
|
|
keyword_length := Length(keyword);
|
|
|
|
|
continue := (index < keyword_length) & (token_start <> token_end);
|
|
|
|
|
|
|
|
|
|
while (index < Length(Keyword)) & (TokenStart <> TokenEnd) & result DO
|
|
|
|
|
result := (Keyword[index] = TokenStart^) or (Lower(Keyword[index]) = TokenStart^);
|
|
|
|
|
INC(TokenStart);
|
|
|
|
|
INC(index)
|
|
|
|
|
while continue & result do
|
|
|
|
|
result := (keyword[index] = token_start^) or (Lower(keyword[index]) = token_start^);
|
|
|
|
|
INC(token_start);
|
|
|
|
|
INC(index);
|
|
|
|
|
continue := (index < keyword_length) & (token_start <> token_end)
|
|
|
|
|
end;
|
|
|
|
|
result := (index = Length(Keyword)) & (TokenStart = TokenEnd) & result;
|
|
|
|
|
return result
|
|
|
|
|
result := result & (index = Length(keyword));
|
|
|
|
|
|
|
|
|
|
return result & (token_start = token_end)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* Reached the end of file. *)
|
|
|
|
@ -239,29 +245,29 @@ end;
|
|
|
|
|
(* Add the character to the token currently read and advance to the next character. *)
|
|
|
|
|
proc transition_action_accumulate(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
INC(lexer^.Current)
|
|
|
|
|
INC(lexer^.current)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* The current character is not a part of the token. Finish the token already
|
|
|
|
|
* read. Don't advance to the next character. *)
|
|
|
|
|
proc transition_action_finalize(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
if lexer^.Start^ = ':' then
|
|
|
|
|
if lexer^.start^ = ':' then
|
|
|
|
|
token^.kind := lexerKindColon
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '>' then
|
|
|
|
|
if lexer^.start^ = '>' then
|
|
|
|
|
token^.kind := lexerKindGreaterThan
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '<' then
|
|
|
|
|
if lexer^.start^ = '<' then
|
|
|
|
|
token^.kind := lexerKindLessThan
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '(' then
|
|
|
|
|
if lexer^.start^ = '(' then
|
|
|
|
|
token^.kind := lexerKindLeftParen
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '-' then
|
|
|
|
|
token^.kind := lexerKindLeftParen
|
|
|
|
|
if lexer^.start^ = '-' then
|
|
|
|
|
token^.kind := lexerKindMinus
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '.' then
|
|
|
|
|
if lexer^.start^ = '.' then
|
|
|
|
|
token^.kind := lexerKindDot
|
|
|
|
|
end
|
|
|
|
|
end;
|
|
|
|
@ -269,34 +275,34 @@ end;
|
|
|
|
|
(* An action for tokens containing multiple characters. *)
|
|
|
|
|
proc transition_action_composite(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
if lexer^.Start^ = '<' then
|
|
|
|
|
if lexer^.Current^ = '>' then
|
|
|
|
|
if lexer^.start^ = '<' then
|
|
|
|
|
if lexer^.current^ = '>' then
|
|
|
|
|
token^.kind := lexerKindNotEqual
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '=' then
|
|
|
|
|
if lexer^.current^ = '=' then
|
|
|
|
|
token^.kind := lexerKindLessEqual
|
|
|
|
|
end
|
|
|
|
|
end;
|
|
|
|
|
if (lexer^.Start^ = '>') & (lexer^.Current^ = '=') then
|
|
|
|
|
if (lexer^.start^ = '>') & (lexer^.current^ = '=') then
|
|
|
|
|
token^.kind := lexerKindGreaterEqual
|
|
|
|
|
end;
|
|
|
|
|
if (lexer^.Start^ = '.') & (lexer^.Current^ = '.') then
|
|
|
|
|
if (lexer^.start^ = '.') & (lexer^.current^ = '.') then
|
|
|
|
|
token^.kind := lexerKindRange
|
|
|
|
|
end;
|
|
|
|
|
if (lexer^.Start^ = ':') & (lexer^.Current^ = '=') then
|
|
|
|
|
if (lexer^.start^ = ':') & (lexer^.current^ = '=') then
|
|
|
|
|
token^.kind := lexerKindAssignment
|
|
|
|
|
end;
|
|
|
|
|
if (lexer^.Start^ = '-') & (lexer^.Current^ = '>') then
|
|
|
|
|
if (lexer^.start^ = '-') & (lexer^.current^ = '>') then
|
|
|
|
|
token^.kind := lexerKindArrow
|
|
|
|
|
end;
|
|
|
|
|
INC(lexer^.Current)
|
|
|
|
|
INC(lexer^.current)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* Skip a space. *)
|
|
|
|
|
proc transition_action_skip(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
INC(lexer^.Current);
|
|
|
|
|
INC(lexer^.Start)
|
|
|
|
|
INC(lexer^.current);
|
|
|
|
|
INC(lexer^.start)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* Delimited string action. *)
|
|
|
|
@ -304,20 +310,30 @@ proc transition_action_delimited(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
var
|
|
|
|
|
text_length: CARDINAL;
|
|
|
|
|
begin
|
|
|
|
|
if lexer^.Start^ = '(' then
|
|
|
|
|
if lexer^.start^ = '(' then
|
|
|
|
|
token^.kind := lexerKindComment
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = '"' then
|
|
|
|
|
if lexer^.start^ = '"' then
|
|
|
|
|
text_length := lexer^.current;
|
|
|
|
|
DEC(text_length, lexer^.start);
|
|
|
|
|
INC(text_length);
|
|
|
|
|
|
|
|
|
|
MemZero(ADR(token^.stringKind), TSIZE(ShortString));
|
|
|
|
|
MemCopy(lexer^.start, text_length, ADR(token^.stringKind));
|
|
|
|
|
|
|
|
|
|
token^.kind := lexerKindCharacter
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Start^ = "'" then
|
|
|
|
|
text_length := lexer^.Current - lexer^.Start;
|
|
|
|
|
if lexer^.start^ = "'" then
|
|
|
|
|
text_length := lexer^.current;
|
|
|
|
|
DEC(text_length, lexer^.start);
|
|
|
|
|
INC(text_length);
|
|
|
|
|
|
|
|
|
|
MemZero(ADR(token^.stringKind), TSIZE(ShortString));
|
|
|
|
|
MemCopy(lexer^.Start, text_length, ADR(token^.stringKind));
|
|
|
|
|
MemCopy(lexer^.start, text_length, ADR(token^.stringKind));
|
|
|
|
|
|
|
|
|
|
token^.kind := lexerKindString
|
|
|
|
|
end;
|
|
|
|
|
INC(lexer^.Current)
|
|
|
|
|
INC(lexer^.current)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* Finalize keyword or identifier. *)
|
|
|
|
@ -325,101 +341,102 @@ proc transition_action_key_id(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
token^.kind := lexerKindIdentifier;
|
|
|
|
|
|
|
|
|
|
token^.identifierKind[1] := lexer^.Current - lexer^.Start;
|
|
|
|
|
MemCopy(lexer^.Start, ORD(token^.identifierKind[1]), ADR(token^.identifierKind[2]));
|
|
|
|
|
token^.identifierKind[1] := lexer^.current;
|
|
|
|
|
DEC(token^.identifierKind[1], lexer^.start);
|
|
|
|
|
MemCopy(lexer^.start, ORD(token^.identifierKind[1]), ADR(token^.identifierKind[2]));
|
|
|
|
|
|
|
|
|
|
if compare_keyword('PROGRAM', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('PROGRAM', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindProgram
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('IMPORT', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('IMPORT', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindImport
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('CONST', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('CONST', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindConst
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('VAR', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('VAR', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindVar
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('IF', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('IF', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindIf
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('THEN', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('THEN', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindThen
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('ELSIF', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('ELSIF', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindElsif
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('ELSE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('ELSE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindElse
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('WHILE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('WHILE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindWhile
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('DO', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('DO', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindDo
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('proc', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('proc', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindProc
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('BEGIN', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('BEGIN', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindBegin
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('END', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('END', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindEnd
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('TYPE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('TYPE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindType
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('RECORD', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('RECORD', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindRecord
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('UNION', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('UNION', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindUnion
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('NIL', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('NIL', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindNull
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('AND', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('AND', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindAnd
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('OR', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('OR', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindOr
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('RETURN', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('RETURN', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindReturn
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('DEFINITION', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('DEFINITION', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindDefinition
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('TO', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('TO', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindTo
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('CASE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('CASE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindCase
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('OF', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('OF', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindOf
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('FROM', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('FROM', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindFrom
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('MODULE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('MODULE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindModule
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('IMPLEMENTATION', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('IMPLEMENTATION', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindImplementation
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('POINTER', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('POINTER', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindPointer
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('ARRAY', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('ARRAY', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindArray
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('TRUE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('TRUE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindBoolean;
|
|
|
|
|
token^.booleanKind := true
|
|
|
|
|
end;
|
|
|
|
|
if compare_keyword('FALSE', lexer^.Start, lexer^.Current) then
|
|
|
|
|
if compare_keyword('FALSE', lexer^.start, lexer^.current) then
|
|
|
|
|
token^.kind := lexerKindBoolean;
|
|
|
|
|
token^.booleanKind := false
|
|
|
|
|
end
|
|
|
|
@ -429,49 +446,52 @@ end;
|
|
|
|
|
* followed by other characters forming a composite token. *)
|
|
|
|
|
proc transition_action_single(lexer: PLexer, token: PLexerToken);
|
|
|
|
|
begin
|
|
|
|
|
if lexer^.Current^ = '&' then
|
|
|
|
|
if lexer^.current^ = '&' then
|
|
|
|
|
token^.kind := lexerKindAnd
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = ';' then
|
|
|
|
|
if lexer^.current^ = ';' then
|
|
|
|
|
token^.kind := lexerKindSemicolon
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = ',' then
|
|
|
|
|
if lexer^.current^ = ',' then
|
|
|
|
|
token^.kind := lexerKindComma
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '~' then
|
|
|
|
|
if lexer^.current^ = '~' then
|
|
|
|
|
token^.kind := lexerKindTilde
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = ')' then
|
|
|
|
|
if lexer^.current^ = ')' then
|
|
|
|
|
token^.kind := lexerKindRightParen
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '[' then
|
|
|
|
|
if lexer^.current^ = '[' then
|
|
|
|
|
token^.kind := lexerKindLeftSquare
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = ']' then
|
|
|
|
|
if lexer^.current^ = ']' then
|
|
|
|
|
token^.kind := lexerKindRightSquare
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '^' then
|
|
|
|
|
if lexer^.current^ = '^' then
|
|
|
|
|
token^.kind := lexerKindHat
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '=' then
|
|
|
|
|
if lexer^.current^ = '=' then
|
|
|
|
|
token^.kind := lexerKindEqual
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '+' then
|
|
|
|
|
if lexer^.current^ = '+' then
|
|
|
|
|
token^.kind := lexerKindPlus
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '/' then
|
|
|
|
|
if lexer^.current^ = '*' then
|
|
|
|
|
token^.kind := lexerKindAsterisk
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.current^ = '/' then
|
|
|
|
|
token^.kind := lexerKindDivision
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '%' then
|
|
|
|
|
if lexer^.current^ = '%' then
|
|
|
|
|
token^.kind := lexerKindRemainder
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '@' then
|
|
|
|
|
if lexer^.current^ = '@' then
|
|
|
|
|
token^.kind := lexerKindAt
|
|
|
|
|
end;
|
|
|
|
|
if lexer^.Current^ = '|' then
|
|
|
|
|
if lexer^.current^ = '|' then
|
|
|
|
|
token^.kind := lexerKindPipe
|
|
|
|
|
end;
|
|
|
|
|
INC(lexer^.Current)
|
|
|
|
|
INC(lexer^.current)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(* Handle an integer literal. *)
|
|
|
|
@ -483,44 +503,45 @@ var
|
|
|
|
|
begin
|
|
|
|
|
token^.kind := lexerKindInteger;
|
|
|
|
|
|
|
|
|
|
integer_length := lexer^.Current - lexer^.Start;
|
|
|
|
|
integer_length := lexer^.current;
|
|
|
|
|
DEC(integer_length, lexer^.start);
|
|
|
|
|
MemZero(ADR(token^.identifierKind), TSIZE(Identifier));
|
|
|
|
|
MemCopy(lexer^.Start, integer_length, ADR(token^.identifierKind[1]));
|
|
|
|
|
MemCopy(lexer^.start, integer_length, ADR(token^.identifierKind[1]));
|
|
|
|
|
|
|
|
|
|
buffer := InitStringCharStar(ADR(token^.identifierKind[1]));
|
|
|
|
|
token^.integerKind := StringToInteger(buffer, 10, found);
|
|
|
|
|
buffer := KillString(buffer)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
proc set_default_transition(CurrentState: TransitionState, DefaultAction: TransitionAction, NextState: TransitionState);
|
|
|
|
|
proc set_default_transition(current_state: TransitionState, DefaultAction: TransitionAction, next_state: TransitionState);
|
|
|
|
|
var
|
|
|
|
|
DefaultTransition: Transition;
|
|
|
|
|
default_transition: Transition;
|
|
|
|
|
begin
|
|
|
|
|
DefaultTransition.Action := DefaultAction;
|
|
|
|
|
DefaultTransition.NextState := NextState;
|
|
|
|
|
default_transition.action := DefaultAction;
|
|
|
|
|
default_transition.next_state := next_state;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassInvalid) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassDigit) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassAlpha) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassSpace) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassColon) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassEquals) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassLeftParen) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassRightParen) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassAsterisk) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassUnderscore) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassSingle) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassHex) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassZero) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassX) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassEof) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassDot) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassMinus) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassSingleQuote) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassDoubleQuote) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassGreater) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassLess) + 1] := DefaultTransition;
|
|
|
|
|
transitions[ORD(CurrentState) + 1][ORD(transitionClassOther) + 1] := DefaultTransition
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassInvalid) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassDigit) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassAlpha) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassSpace) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassColon) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassEquals) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassLeftParen) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassRightParen) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassAsterisk) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassUnderscore) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassSingle) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassHex) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassZero) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassX) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassEof) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassDot) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassMinus) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassSingleQuote) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassDoubleQuote) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassGreater) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassLess) + 1] := default_transition;
|
|
|
|
|
transitions[ORD(current_state) + 1][ORD(transitionClassOther) + 1] := default_transition
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
(*
|
|
|
|
@ -542,269 +563,278 @@ end;
|
|
|
|
|
proc initialize_transitions();
|
|
|
|
|
begin
|
|
|
|
|
(* Start state. *)
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassInvalid) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassInvalid) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassInvalid) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassInvalid) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDigit) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDigit) + 1].NextState := transitionStateDecimal;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDigit) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDigit) + 1].next_state := transitionStateDecimal;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAlpha) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAlpha) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAlpha) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAlpha) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSpace) + 1].Action := transition_action_skip;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSpace) + 1].NextState := transitionStateStart;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSpace) + 1].action := transition_action_skip;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSpace) + 1].next_state := transitionStateStart;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassColon) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassColon) + 1].NextState := transitionStateColon;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassColon) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassColon) + 1].next_state := transitionStateColon;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEquals) + 1].Action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEquals) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEquals) + 1].action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEquals) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLeftParen) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLeftParen) + 1].NextState := transitionStateLeftParen;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLeftParen) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLeftParen) + 1].next_state := transitionStateLeftParen;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassRightParen) + 1].Action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassRightParen) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassRightParen) + 1].action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassRightParen) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAsterisk) + 1].Action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAsterisk) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAsterisk) + 1].action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassAsterisk) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassUnderscore) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassUnderscore) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassUnderscore) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassUnderscore) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingle) + 1].Action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingle) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingle) + 1].action := transition_action_single;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingle) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassHex) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassHex) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassHex) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassHex) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassZero) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassZero) + 1].NextState := transitionStateLeadingZero;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassZero) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassZero) + 1].next_state := transitionStateLeadingZero;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassX) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassX) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassX) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassX) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEof) + 1].Action := transition_action_eof;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEof) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEof) + 1].action := transition_action_eof;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassEof) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDot) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDot) + 1].NextState := transitionStateDot;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDot) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDot) + 1].next_state := transitionStateDot;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassMinus) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassMinus) + 1].NextState := transitionStateMinus;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassMinus) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassMinus) + 1].next_state := transitionStateMinus;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingleQuote) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingleQuote) + 1].NextState := transitionStateCharacter;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingleQuote) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassSingleQuote) + 1].next_state := transitionStateCharacter;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDoubleQuote) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDoubleQuote) + 1].NextState := transitionStateString;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDoubleQuote) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassDoubleQuote) + 1].next_state := transitionStateString;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassGreater) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassGreater) + 1].NextState := transitionStateGreater;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassGreater) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassGreater) + 1].next_state := transitionStateGreater;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLess) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLess) + 1].NextState := transitionStateLess;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLess) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassLess) + 1].next_state := transitionStateLess;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassOther) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassOther) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassOther) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateStart) + 1][ORD(transitionClassOther) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Colon state. *)
|
|
|
|
|
set_default_transition(transitionStateColon, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateColon) + 1][ORD(transitionClassEquals) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateColon) + 1][ORD(transitionClassEquals) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateColon) + 1][ORD(transitionClassEquals) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateColon) + 1][ORD(transitionClassEquals) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Identifier state. *)
|
|
|
|
|
set_default_transition(transitionStateIdentifier, transition_action_key_id, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassDigit) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassDigit) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassDigit) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassDigit) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassAlpha) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassAlpha) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassAlpha) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassAlpha) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassUnderscore) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassUnderscore) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassUnderscore) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassUnderscore) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassHex) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassHex) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassHex) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassHex) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassZero) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassZero) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassZero) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassZero) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassX) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassX) + 1].NextState := transitionStateIdentifier;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassX) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateIdentifier) + 1][ORD(transitionClassX) + 1].next_state := transitionStateIdentifier;
|
|
|
|
|
|
|
|
|
|
(* Decimal state. *)
|
|
|
|
|
set_default_transition(transitionStateDecimal, transition_action_integer, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassDigit) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassDigit) + 1].NextState := transitionStateDecimal;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassDigit) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassDigit) + 1].next_state := transitionStateDecimal;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassAlpha) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassAlpha) + 1].NextState := transitionStateDecimalSuffix;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassAlpha) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassAlpha) + 1].next_state := transitionStateDecimalSuffix;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassUnderscore) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassUnderscore) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassUnderscore) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassUnderscore) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassHex) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassHex) + 1].NextState := transitionStateDecimalSuffix;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassHex) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassHex) + 1].next_state := transitionStateDecimalSuffix;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassZero) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassZero) + 1].NextState := transitionStateDecimal;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassZero) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassZero) + 1].next_state := transitionStateDecimal;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassX) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassX) + 1].NextState := transitionStateDecimalSuffix;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassX) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateDecimal) + 1][ORD(transitionClassX) + 1].next_state := transitionStateDecimalSuffix;
|
|
|
|
|
|
|
|
|
|
(* Greater state. *)
|
|
|
|
|
set_default_transition(transitionStateGreater, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateGreater) + 1][ORD(transitionClassEquals) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateGreater) + 1][ORD(transitionClassEquals) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateGreater) + 1][ORD(transitionClassEquals) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateGreater) + 1][ORD(transitionClassEquals) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Minus state. *)
|
|
|
|
|
set_default_transition(transitionStateMinus, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateMinus) + 1][ORD(transitionClassGreater) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateMinus) + 1][ORD(transitionClassGreater) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateMinus) + 1][ORD(transitionClassGreater) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateMinus) + 1][ORD(transitionClassGreater) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Left paren state. *)
|
|
|
|
|
set_default_transition(transitionStateLeftParen, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeftParen) + 1][ORD(transitionClassAsterisk) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateLeftParen) + 1][ORD(transitionClassAsterisk) + 1].NextState := transitionStateComment;
|
|
|
|
|
transitions[ORD(transitionStateLeftParen) + 1][ORD(transitionClassAsterisk) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateLeftParen) + 1][ORD(transitionClassAsterisk) + 1].next_state := transitionStateComment;
|
|
|
|
|
|
|
|
|
|
(* Less state. *)
|
|
|
|
|
set_default_transition(transitionStateLess, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassEquals) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassEquals) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassEquals) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassEquals) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassGreater) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassGreater) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassGreater) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateLess) + 1][ORD(transitionClassGreater) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Hexadecimal after 0x. *)
|
|
|
|
|
set_default_transition(transitionStateDot, transition_action_finalize, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDot) + 1][ORD(transitionClassDot) + 1].Action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateDot) + 1][ORD(transitionClassDot) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDot) + 1][ORD(transitionClassDot) + 1].action := transition_action_composite;
|
|
|
|
|
transitions[ORD(transitionStateDot) + 1][ORD(transitionClassDot) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Comment. *)
|
|
|
|
|
set_default_transition(transitionStateComment, transition_action_accumulate, transitionStateComment);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassAsterisk) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassAsterisk) + 1].NextState := transitionStateClosingComment;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassAsterisk) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassAsterisk) + 1].next_state := transitionStateClosingComment;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassEof) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassEof) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassEof) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateComment) + 1][ORD(transitionClassEof) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Closing comment. *)
|
|
|
|
|
set_default_transition(transitionStateClosingComment, transition_action_accumulate, transitionStateComment);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassInvalid) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassInvalid) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassInvalid) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassInvalid) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassRightParen) + 1].Action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassRightParen) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassRightParen) + 1].action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassRightParen) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassAsterisk) + 1].Action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassAsterisk) + 1].NextState := transitionStateClosingComment;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassAsterisk) + 1].action := transition_action_accumulate;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassAsterisk) + 1].next_state := transitionStateClosingComment;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassEof) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassEof) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassEof) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateClosingComment) + 1][ORD(transitionClassEof) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Character. *)
|
|
|
|
|
set_default_transition(transitionStateCharacter, transition_action_accumulate, transitionStateCharacter);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassInvalid) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassInvalid) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassInvalid) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassInvalid) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassEof) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassEof) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassEof) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassEof) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassSingleQuote) + 1].Action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassSingleQuote) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassSingleQuote) + 1].action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateCharacter) + 1][ORD(transitionClassSingleQuote) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* String. *)
|
|
|
|
|
set_default_transition(transitionStateString, transition_action_accumulate, transitionStateString);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassInvalid) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassInvalid) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassInvalid) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassInvalid) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassEof) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassEof) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassEof) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassEof) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassDoubleQuote) + 1].Action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassDoubleQuote) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassDoubleQuote) + 1].action := transition_action_delimited;
|
|
|
|
|
transitions[ORD(transitionStateString) + 1][ORD(transitionClassDoubleQuote) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Leading zero. *)
|
|
|
|
|
set_default_transition(transitionStateLeadingZero, transition_action_integer, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassDigit) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassDigit) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassDigit) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassDigit) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassAlpha) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassAlpha) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassAlpha) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassAlpha) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassUnderscore) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassUnderscore) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassUnderscore) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassUnderscore) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassHex) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassHex) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassHex) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassHex) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassZero) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassZero) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassZero) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassZero) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassX) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassX) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassX) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateLeadingZero) + 1][ORD(transitionClassX) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
(* Digit with a character suffix. *)
|
|
|
|
|
set_default_transition(transitionStateDecimalSuffix, transition_action_integer, transitionStateEnd);
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassAlpha) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassAlpha) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassAlpha) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassAlpha) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassDigit) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassDigit) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassDigit) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassDigit) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassHex) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassHex) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassHex) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassHex) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassZero) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassZero) + 1].NextState := transitionStateEnd;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassZero) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassZero) + 1].next_state := transitionStateEnd;
|
|
|
|
|
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassX) + 1].Action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassX) + 1].NextState := transitionStateEnd
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassX) + 1].action := nil;
|
|
|
|
|
transitions[ORD(transitionStateDecimalSuffix) + 1][ORD(transitionClassX) + 1].next_state := transitionStateEnd
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
proc lexer_initialize(lexer: PLexer, Input: File);
|
|
|
|
|
proc lexer_initialize(lexer: PLexer, input: File);
|
|
|
|
|
begin
|
|
|
|
|
lexer^.Input := Input;
|
|
|
|
|
lexer^.Length := 0;
|
|
|
|
|
lexer^.input := input;
|
|
|
|
|
lexer^.length := 0;
|
|
|
|
|
|
|
|
|
|
ALLOCATE(lexer^.Buffer, CHUNK_SIZE);
|
|
|
|
|
MemZero(lexer^.Buffer, CHUNK_SIZE);
|
|
|
|
|
lexer^.Size := CHUNK_SIZE
|
|
|
|
|
ALLOCATE(lexer^.buffer, CHUNK_SIZE);
|
|
|
|
|
MemZero(lexer^.buffer, CHUNK_SIZE);
|
|
|
|
|
lexer^.size := CHUNK_SIZE
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
proc lexer_current(lexer: PLexer) -> LexerToken;
|
|
|
|
|
var
|
|
|
|
|
CurrentClass: TransitionClass;
|
|
|
|
|
CurrentState: TransitionState;
|
|
|
|
|
CurrentTransition: Transition;
|
|
|
|
|
current_class: TransitionClass;
|
|
|
|
|
current_state: TransitionState;
|
|
|
|
|
current_transition: Transition;
|
|
|
|
|
result: LexerToken;
|
|
|
|
|
index1: CARDINAL;
|
|
|
|
|
index2: CARDINAL;
|
|
|
|
|
begin
|
|
|
|
|
lexer^.Current := lexer^.Start;
|
|
|
|
|
CurrentState := transitionStateStart;
|
|
|
|
|
lexer^.current := lexer^.start;
|
|
|
|
|
current_state := transitionStateStart;
|
|
|
|
|
|
|
|
|
|
while CurrentState <> transitionStateEnd DO
|
|
|
|
|
CurrentClass := classification[ORD(lexer^.Current^) + 1];
|
|
|
|
|
while current_state <> transitionStateEnd DO
|
|
|
|
|
index1 := ORD(lexer^.current^);
|
|
|
|
|
INC(index1);
|
|
|
|
|
current_class := classification[index1];
|
|
|
|
|
|
|
|
|
|
CurrentTransition := transitions[ORD(CurrentState) + 1][ORD(CurrentClass) + 1];
|
|
|
|
|
if CurrentTransition.Action <> nil then
|
|
|
|
|
CurrentTransition.Action(lexer, ADR(result))
|
|
|
|
|
index1 := ORD(current_state);
|
|
|
|
|
INC(index1);
|
|
|
|
|
index2 := ORD(current_class);
|
|
|
|
|
INC(index2);
|
|
|
|
|
|
|
|
|
|
current_transition := transitions[index1][index2];
|
|
|
|
|
if current_transition.action <> nil then
|
|
|
|
|
current_transition.action(lexer, ADR(result))
|
|
|
|
|
end;
|
|
|
|
|
CurrentState := CurrentTransition.NextState
|
|
|
|
|
current_state := current_transition.next_state
|
|
|
|
|
end;
|
|
|
|
|
return result
|
|
|
|
|
end;
|
|
|
|
@ -813,11 +843,11 @@ proc lexer_lex(lexer: PLexer) -> LexerToken;
|
|
|
|
|
var
|
|
|
|
|
result: LexerToken;
|
|
|
|
|
begin
|
|
|
|
|
if lexer^.Length = 0 then
|
|
|
|
|
lexer^.Length := ReadNBytes(lexer^.Input, CHUNK_SIZE, lexer^.Buffer);
|
|
|
|
|
lexer^.Current := lexer^.Buffer
|
|
|
|
|
if lexer^.length = 0 then
|
|
|
|
|
lexer^.length := ReadNBytes(lexer^.input, CHUNK_SIZE, lexer^.buffer);
|
|
|
|
|
lexer^.current := lexer^.buffer
|
|
|
|
|
end;
|
|
|
|
|
lexer^.Start := lexer^.Current;
|
|
|
|
|
lexer^.start := lexer^.current;
|
|
|
|
|
|
|
|
|
|
result := lexer_current(lexer);
|
|
|
|
|
return result
|
|
|
|
@ -825,7 +855,7 @@ end;
|
|
|
|
|
|
|
|
|
|
proc lexer_destroy(lexer: PLexer);
|
|
|
|
|
begin
|
|
|
|
|
DEALLOCATE(lexer^.Buffer, lexer^.Size)
|
|
|
|
|
DEALLOCATE(lexer^.buffer, lexer^.size)
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|