Initial check in lib
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// ================================================================================================
|
||||
// BlockContext stores the information needed when creating an alternative (list of elements).
|
||||
// Entering a subrule requires that we save this state as each block of alternatives requires
|
||||
// state such as "tail of current alternative."
|
||||
// ================================================================================================
|
||||
unit dpglib.BlockContext;
|
||||
|
||||
interface
|
||||
uses
|
||||
dpglib.types;
|
||||
|
||||
type
|
||||
TBlockContext = class(TObject)
|
||||
private
|
||||
fAltNum : integer;
|
||||
fBlock : IAlternativeBlock;
|
||||
fBlockEnd : IBlockEndElem;
|
||||
|
||||
public
|
||||
procedure AddAlternativeElem( pElem: IAlternativeElem); virtual;
|
||||
|
||||
function CurrentAlt : IAlternative;
|
||||
function CurrentElem : IAlternativeElem;
|
||||
|
||||
public
|
||||
property AltNum : integer read fAltNum write fAltNum;
|
||||
property Block : IAlternativeBlock read fBlock write fBlock;
|
||||
property BlockEnd : IBlockEndElem read fBlockEnd write fBlockEnd;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
// CurrentAlt
|
||||
// ----------------------------------------------------------------------------
|
||||
function TBlockContext.CurrentAlt: IAlternative;
|
||||
begin
|
||||
fBlock.Alternatives.Items[fAltNum].QueryInterface( IAlternative, result);
|
||||
end;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// CurrentElem
|
||||
// ----------------------------------------------------------------------------
|
||||
function TBlockContext.CurrentElem: IAlternativeElem;
|
||||
begin
|
||||
result := CurrentAlt.Tail;
|
||||
end;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AddAlternativeElem
|
||||
// ----------------------------------------------------------------------------
|
||||
procedure TBlockContext.AddAlternativeElem(pElem: IAlternativeElem);
|
||||
begin
|
||||
CurrentAlt.AddElem( pElem);
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user