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