158 lines
6.4 KiB
ObjectPascal
158 lines
6.4 KiB
ObjectPascal
unit dpglib.AlternativeElem;
|
|
|
|
interface
|
|
uses
|
|
dpgrtl.types,
|
|
dpglib.types,
|
|
dpglib.GrammarElem;
|
|
|
|
type
|
|
TAlternativeElem = class( TGrammarElem, IAlternativeElem, IGrammarElem)
|
|
protected
|
|
fNext : IAlternativeElem;
|
|
fEnclosingRule : AnsiString;
|
|
fAutoGenType : integer;
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction/destruction
|
|
// ----------------------------------------------------------------------
|
|
public
|
|
constructor Create( Grammar : IGrammar); overload;
|
|
constructor Create( Grammar : IGrammar;
|
|
Start : IToken); overload;
|
|
constructor Create( Grammar : IGrammar;
|
|
Start : IToken;
|
|
AutoGenType : integer); overload;
|
|
|
|
destructor Destroy; override;
|
|
|
|
// ----------------------------------------------------------------------
|
|
// IAlternativeElem
|
|
// ----------------------------------------------------------------------
|
|
protected
|
|
function GetAutoGenType : integer;
|
|
function GetNext : IAlternativeElem;
|
|
function GetLabel : AnsiString;
|
|
function GetEnclosingRule : AnsiString;
|
|
|
|
procedure SetNext( Next : IAlternativeElem);
|
|
procedure SetLabel( Lbl : AnsiString);
|
|
procedure SetEnclosingRule( Rule : AnsiString);
|
|
end;
|
|
|
|
implementation
|
|
|
|
// @@@: Construction/destruction ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
//
|
|
// Construction/destruction
|
|
//
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ================================================================================================
|
|
// Constructor
|
|
// ================================================================================================
|
|
constructor TAlternativeElem.Create( Grammar: IGrammar);
|
|
begin
|
|
inherited Create( Grammar);
|
|
fAutoGenType := AUTOGEN_NONE;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Constructor
|
|
// ================================================================================================
|
|
constructor TAlternativeElem.Create( Grammar : IGrammar;
|
|
Start : IToken);
|
|
begin
|
|
inherited Create( Grammar, Start);
|
|
fAutoGenType := AUTOGEN_NONE;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Constructor
|
|
// ================================================================================================
|
|
constructor TAlternativeElem.Create( Grammar : IGrammar;
|
|
Start : IToken;
|
|
AutoGenType: integer);
|
|
begin
|
|
inherited Create( Grammar, Start);
|
|
fAutoGenType := AutoGenType;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Destructor
|
|
// ================================================================================================
|
|
destructor TAlternativeElem.Destroy;
|
|
begin
|
|
fNext := nil;
|
|
inherited;
|
|
end;
|
|
|
|
// @@@: IAlternativeElem implementation +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
//
|
|
// IAlternativeElem implementation
|
|
//
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// ================================================================================================
|
|
// Get AutoGenType
|
|
// ================================================================================================
|
|
function TAlternativeElem.GetAutoGenType: integer;
|
|
begin
|
|
result := fAutoGenType;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Get EnclosingRule
|
|
// ================================================================================================
|
|
function TAlternativeElem.GetEnclosingRule: AnsiString;
|
|
begin
|
|
result := fEnclosingRule;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Get Label
|
|
// ================================================================================================
|
|
function TAlternativeElem.GetLabel: AnsiString;
|
|
begin
|
|
result := '';
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Get Next
|
|
// ================================================================================================
|
|
function TAlternativeElem.GetNext: IAlternativeElem;
|
|
begin
|
|
result := fNext;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Set EnclosingRule
|
|
// ================================================================================================
|
|
procedure TAlternativeElem.SetEnclosingRule(Rule: AnsiString);
|
|
begin
|
|
fEnclosingRule := Rule;
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Set Label
|
|
// ================================================================================================
|
|
procedure TAlternativeElem.SetLabel(Lbl: AnsiString);
|
|
begin
|
|
end;
|
|
|
|
// ================================================================================================
|
|
// Set Next
|
|
// ================================================================================================
|
|
procedure TAlternativeElem.SetNext(Next: IAlternativeElem);
|
|
begin
|
|
fNext := Next;
|
|
end;
|
|
|
|
end.
|