Initial check in lib

This commit is contained in:
2026-01-03 18:33:48 +01:00
parent b20cd8e688
commit 5666f85e99
89 changed files with 36370 additions and 1 deletions
+57
View File
@@ -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.