Initial check in lib
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
unit dpglib.BlockWithImpliedExitPath;
|
||||
|
||||
interface
|
||||
uses
|
||||
dpgrtl.types,
|
||||
dpglib.types,
|
||||
dpglib.AlternativeBlock;
|
||||
|
||||
type
|
||||
// =========================================================================
|
||||
// Class TBlockWithImpliedExitPath declaration
|
||||
// =========================================================================
|
||||
TBlockWithImpliedExitPath = class( TAlternativeBlock,
|
||||
IBlockWithImpliedExitPath,
|
||||
IAlternativeBlock,
|
||||
IAlternativeElem,
|
||||
IGrammarElem)
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Members
|
||||
// ---------------------------------------------------------------
|
||||
protected
|
||||
fExitLookaheadDepth : integer;
|
||||
fExitCache : array of ILookahead;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor/destructor
|
||||
// ---------------------------------------------------------------
|
||||
public
|
||||
constructor Create( pGrammar: IGrammar); overload;
|
||||
constructor Create( pGrammar: IGrammar; pStart: IToken); overload;
|
||||
destructor Destroy; override;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// IBlockWithImpliedExitPath methods
|
||||
// ---------------------------------------------------------------
|
||||
protected
|
||||
function GetExitDepth: integer;
|
||||
function GetExitCache( i: integer) : ILookahead;
|
||||
|
||||
procedure SetExitDepth( pDepth: integer);
|
||||
procedure SetExitCache( i: integer; pExitCache: ILookahead);
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
// ****************************************************************************
|
||||
// Constructor/destructor
|
||||
// ****************************************************************************
|
||||
// ============================================================================
|
||||
// Constructor
|
||||
// ============================================================================
|
||||
constructor TBlockWithImpliedExitPath.Create( pGrammar : IGrammar);
|
||||
begin
|
||||
inherited Create( pGrammar);
|
||||
SetLength( fExitCache, pGrammar.MaxK + 1);
|
||||
end;
|
||||
|
||||
// ============================================================================
|
||||
// Constructor
|
||||
// ============================================================================
|
||||
constructor TBlockWithImpliedExitPath.Create( pGrammar : IGrammar;
|
||||
pStart : IToken);
|
||||
begin
|
||||
inherited Create( pGrammar, pStart);
|
||||
SetLength( fExitCache, pGrammar.MaxK + 1);
|
||||
end;
|
||||
|
||||
// ============================================================================
|
||||
// Destructor
|
||||
// ============================================================================
|
||||
destructor TBlockWithImpliedExitPath.Destroy;
|
||||
var
|
||||
i: integer;
|
||||
|
||||
begin
|
||||
for i:=Low(fExitCache) to High(fExitCache) do
|
||||
fExitCache[i] := nil;
|
||||
|
||||
fExitCache := nil;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
// ****************************************************************************
|
||||
// IBlockWithImpliedExitPath implementation
|
||||
// ****************************************************************************
|
||||
// ============================================================================
|
||||
// GetExitDepth
|
||||
// ============================================================================
|
||||
function TBlockWithImpliedExitPath.GetExitDepth: integer;
|
||||
begin
|
||||
result := fExitLookaheadDepth;
|
||||
end;
|
||||
|
||||
// ============================================================================
|
||||
// GetExitCache
|
||||
// ============================================================================
|
||||
function TBlockWithImpliedExitPath.GetExitCache( i: integer): ILookahead;
|
||||
begin
|
||||
result := fExitCache[i];
|
||||
end;
|
||||
|
||||
// ============================================================================
|
||||
// SetExitDepth
|
||||
// ============================================================================
|
||||
procedure TBlockWithImpliedExitPath.SetExitDepth(pDepth: integer);
|
||||
begin
|
||||
fExitLookaheadDepth := pDepth;
|
||||
end;
|
||||
|
||||
// ============================================================================
|
||||
// SetExitCache
|
||||
// ============================================================================
|
||||
procedure TBlockWithImpliedExitPath.SetExitCache( i : integer;
|
||||
pExitCache : ILookahead);
|
||||
begin
|
||||
fExitCache[i] := pExitCache;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user