Script Refactoring
This commit is contained in:
@@ -233,7 +233,6 @@ type
|
|||||||
// Helpers
|
// Helpers
|
||||||
function ParseTupleBody(StopToken: TTokenKind): TArray<IAstNode>;
|
function ParseTupleBody(StopToken: TTokenKind): TArray<IAstNode>;
|
||||||
function ExtractIdentifiers(const Node: IAstNode; const Context: string): TArray<IIdentifierNode>;
|
function ExtractIdentifiers(const Node: IAstNode; const Context: string): TArray<IIdentifierNode>;
|
||||||
procedure InitSpecialForms;
|
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(const ASource: string);
|
constructor Create(const ASource: string);
|
||||||
@@ -498,19 +497,6 @@ constructor TParser.Create(const ASource: string);
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FLexer := TLexer.Create(ASource);
|
FLexer := TLexer.Create(ASource);
|
||||||
InitSpecialForms;
|
|
||||||
NextToken;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TParser.Destroy;
|
|
||||||
begin
|
|
||||||
FSpecialForms.Free;
|
|
||||||
FLexer.Free;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TParser.InitSpecialForms;
|
|
||||||
begin
|
|
||||||
FSpecialForms := TDictionary<string, TSpecialFormParser>.Create(TStringComparer.Ordinal);
|
FSpecialForms := TDictionary<string, TSpecialFormParser>.Create(TStringComparer.Ordinal);
|
||||||
FSpecialForms.Add('if', ParseIf);
|
FSpecialForms.Add('if', ParseIf);
|
||||||
FSpecialForms.Add('?', ParseCond);
|
FSpecialForms.Add('?', ParseCond);
|
||||||
@@ -526,6 +512,14 @@ begin
|
|||||||
FSpecialForms.Add('add-item', ParseAddItem);
|
FSpecialForms.Add('add-item', ParseAddItem);
|
||||||
FSpecialForms.Add('count', ParseCount);
|
FSpecialForms.Add('count', ParseCount);
|
||||||
FSpecialForms.Add('get', ParseGet);
|
FSpecialForms.Add('get', ParseGet);
|
||||||
|
NextToken;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TParser.Destroy;
|
||||||
|
begin
|
||||||
|
FSpecialForms.Free;
|
||||||
|
FLexer.Free;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TParser.Error(const Msg: string);
|
procedure TParser.Error(const Msg: string);
|
||||||
|
|||||||
Reference in New Issue
Block a user