Initial check in lib
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
unit dpglib.RuleSymbol;
|
||||
|
||||
interface
|
||||
uses
|
||||
System.Classes,
|
||||
dpgrtl.types,
|
||||
dpglib.types,
|
||||
dpglib.GrammarSymbol;
|
||||
|
||||
type
|
||||
TRuleSymbol = class( TGrammarSymbol, IRuleSymbol, IGrammarSymbol)
|
||||
protected
|
||||
fBlock : IRuleBlock;
|
||||
fDefined : boolean;
|
||||
fReferences : TInterfaceList;
|
||||
|
||||
fAccess : AnsiString;
|
||||
fComment : AnsiString;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// IRuleSymbol
|
||||
// ----------------------------------------------------------------------
|
||||
protected
|
||||
function GetBlock : IRuleBlock;
|
||||
function GetDefined : boolean;
|
||||
function GetReferences : TInterfaceList;
|
||||
function GetAccess : AnsiString;
|
||||
function GetComment : AnsiString;
|
||||
function GetReference(i: integer): IRuleRefElem;
|
||||
|
||||
procedure SetBlock( pBlock : IRuleBlock);
|
||||
procedure SetDefined( pDefined : boolean);
|
||||
procedure SetAccess( pAccess : AnsiString);
|
||||
procedure SetComment( pComment : AnsiString);
|
||||
|
||||
procedure AddReference( pRef: IRuleRefElem);
|
||||
function ReferenceCount: integer;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Construction/destruction
|
||||
// ----------------------------------------------------------------------
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
procedure BeforeDestruction; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses
|
||||
System.SysUtils;
|
||||
|
||||
// @@@: Construction/destruction ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
// Construction/destruction
|
||||
//
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// After Construction
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.AfterConstruction;
|
||||
begin
|
||||
inherited;
|
||||
fReferences := TInterfaceList.Create;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Before Destruction
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.BeforeDestruction;
|
||||
begin
|
||||
FreeAndNil( fReferences);
|
||||
inherited
|
||||
end;
|
||||
|
||||
// @@@: IGrammarSymbol implementation +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
// IGrammarSymbol implementation
|
||||
//
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// Get Block
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetBlock: IRuleBlock;
|
||||
begin
|
||||
result := fBlock;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Get Defined
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetDefined: boolean;
|
||||
begin
|
||||
result := fDefined;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Get References
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetReferences: TInterfaceList;
|
||||
begin
|
||||
result := fReferences;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Get Reference
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetReference(i: integer): IRuleRefElem;
|
||||
begin
|
||||
if (i>=0) and (i<fReferences.Count) then
|
||||
fReferences.Items[i].QueryInterface( IRuleRefElem, result);
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Get Access
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetAccess: AnsiString;
|
||||
begin
|
||||
result := fAccess;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Get Comment
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.GetComment: AnsiString;
|
||||
begin
|
||||
result := fComment;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Set Block
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.SetBlock(pBlock: IRuleBlock);
|
||||
begin
|
||||
fBlock := pBlock;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Set Defined
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.SetDefined(pDefined: boolean);
|
||||
begin
|
||||
fDefined := pDefined;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Set Access
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.SetAccess(pAccess: AnsiString);
|
||||
begin
|
||||
fAccess := pAccess;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Set Comment
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.SetComment(pComment: AnsiString);
|
||||
begin
|
||||
fComment := pComment;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Add Reference
|
||||
// ================================================================================================
|
||||
procedure TRuleSymbol.AddReference(pRef: IRuleRefElem);
|
||||
begin
|
||||
fReferences.Add( pRef);
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Reference Count
|
||||
// ================================================================================================
|
||||
function TRuleSymbol.ReferenceCount: integer;
|
||||
begin
|
||||
result := fReferences.Count;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user