Keywords
This commit is contained in:
+15
-13
@@ -58,7 +58,7 @@ type
|
||||
class function Assign(const AIdentifier: IIdentifierNode; const AValue: IAstNode): IAssignmentNode; static;
|
||||
class function AssignResult(const AValue: IAstNode): IAssignmentNode; static; deprecated;
|
||||
class function Indexer(const ABase: IAstNode; const AIndex: IAstNode): IIndexerNode; static;
|
||||
class function MemberAccess(const ABase: IAstNode; const AMember: IIdentifierNode): IMemberAccessNode; static;
|
||||
class function MemberAccess(const ABase: IAstNode; const AMember: IKeywordNode): IMemberAccessNode; static;
|
||||
class function RecordLiteral(const AFields: TArray<TRecordFieldLiteral>): IRecordLiteralNode; static;
|
||||
class function CreateSeries(const ADefinition: String): ICreateSeriesNode; static;
|
||||
class function AddSeriesItem(
|
||||
@@ -104,7 +104,7 @@ type
|
||||
FValue: IKeyword;
|
||||
function GetValue: IKeyword;
|
||||
public
|
||||
constructor Create(const AName: string);
|
||||
constructor Create(const AValue: IKeyword);
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
property Value: IKeyword read FValue;
|
||||
end;
|
||||
@@ -292,11 +292,11 @@ type
|
||||
TMemberAccessNode = class(TAstNode, IMemberAccessNode)
|
||||
private
|
||||
FBase: IAstNode;
|
||||
FMember: IIdentifierNode;
|
||||
FMember: IKeywordNode;
|
||||
function GetBase: IAstNode;
|
||||
function GetMember: IIdentifierNode;
|
||||
function GetMember: IKeywordNode;
|
||||
public
|
||||
constructor Create(const ABase: IAstNode; const AMember: IIdentifierNode);
|
||||
constructor Create(const ABase: IAstNode; const AMember: IKeywordNode);
|
||||
function Accept(const Visitor: IAstVisitor): TDataValue; override;
|
||||
end;
|
||||
|
||||
@@ -349,14 +349,15 @@ constructor TConstantNode.Create(const AValue: TDataValue);
|
||||
begin
|
||||
inherited Create;
|
||||
// Validate that only allowed constant kinds are used.
|
||||
if not (AValue.Kind in [vkScalar, vkText, vkVoid]) then
|
||||
raise EArgumentException.Create('IConstantNode only supports Scalar, Text, and Void values.');
|
||||
if not (AValue.Kind in [vkScalar, vkText, vkVoid, vkKeyword]) then
|
||||
raise EArgumentException.Create('IConstantNode only supports Scalar, Text, Void and Keyword values.');
|
||||
FValue := AValue;
|
||||
|
||||
case AValue.Kind of
|
||||
vkScalar: StaticType := TTypes.FromScalarKind(AValue.AsScalar.Kind);
|
||||
vkText: StaticType := TTypes.Text;
|
||||
vkVoid: StaticType := TTypes.Void;
|
||||
vkKeyword: StaticType := TTypes.Keyword;
|
||||
else
|
||||
StaticType := TTypes.Unknown; // Should not happen due to validation above
|
||||
end;
|
||||
@@ -392,11 +393,12 @@ end;
|
||||
|
||||
{ TKeywordNode }
|
||||
|
||||
constructor TKeywordNode.Create(const AName: string);
|
||||
constructor TKeywordNode.Create(const AValue: IKeyword);
|
||||
begin
|
||||
inherited Create;
|
||||
FValue := TKeywordRegistry.Intern(AName);
|
||||
FValue := AValue;
|
||||
StaticType := TTypes.Keyword;
|
||||
FValue := AValue;
|
||||
end;
|
||||
|
||||
function TKeywordNode.Accept(const Visitor: IAstVisitor): TDataValue;
|
||||
@@ -788,7 +790,7 @@ end;
|
||||
|
||||
{ TMemberAccessNode }
|
||||
|
||||
constructor TMemberAccessNode.Create(const ABase: IAstNode; const AMember: IIdentifierNode);
|
||||
constructor TMemberAccessNode.Create(const ABase: IAstNode; const AMember: IKeywordNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FBase := ABase;
|
||||
@@ -805,7 +807,7 @@ begin
|
||||
Result := FBase;
|
||||
end;
|
||||
|
||||
function TMemberAccessNode.GetMember: IIdentifierNode;
|
||||
function TMemberAccessNode.GetMember: IKeywordNode;
|
||||
begin
|
||||
Result := FMember;
|
||||
end;
|
||||
@@ -992,7 +994,7 @@ end;
|
||||
|
||||
class function TAst.Keyword(const AName: string): IKeywordNode;
|
||||
begin
|
||||
Result := TKeywordNode.Create(AName);
|
||||
Result := TKeywordNode.Create(TKeywordRegistry.Intern(AName));
|
||||
end;
|
||||
|
||||
class function TAst.LambdaExpr(const AParameters: TArray<IIdentifierNode>; const ABody: IAstNode): ILambdaExpressionNode;
|
||||
@@ -1009,7 +1011,7 @@ begin
|
||||
Result := TMacroDefinitionNode.Create(AName, AParameters, ABody);
|
||||
end;
|
||||
|
||||
class function TAst.MemberAccess(const ABase: IAstNode; const AMember: IIdentifierNode): IMemberAccessNode;
|
||||
class function TAst.MemberAccess(const ABase: IAstNode; const AMember: IKeywordNode): IMemberAccessNode;
|
||||
begin
|
||||
Result := TMemberAccessNode.Create(ABase, AMember);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user