Initial check in lib
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
unit dpglib.NMBlock;
|
||||
|
||||
interface
|
||||
uses
|
||||
dpgrtl.types,
|
||||
dpglib.types,
|
||||
dpglib.BlockWithImpliedExitPath;
|
||||
|
||||
type
|
||||
// =========================================================================
|
||||
// Class TOneOrMoreBlock declaration
|
||||
// =========================================================================
|
||||
TNMBlock = class( TBlockWithImpliedExitPath,
|
||||
INMBlock,
|
||||
IBlockWithImpliedExitPath,
|
||||
IAlternativeBlock,
|
||||
IAlternativeElem,
|
||||
IGrammarElem)
|
||||
|
||||
protected
|
||||
fM : integer;
|
||||
fN : integer;
|
||||
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
|
||||
protected
|
||||
function GetLow : integer;
|
||||
function GetHigh : integer;
|
||||
|
||||
procedure SetLow( Value: integer);
|
||||
procedure SetHigh(Value: integer);
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// IGrammarElem overrides
|
||||
// ---------------------------------------------------------------
|
||||
public
|
||||
procedure Generate;
|
||||
function Look( pK: integer): ILookahead;
|
||||
function AsString : AnsiString;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
// @@@: Construction/destruction ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
// Construction/destruction
|
||||
//
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// AftgerConstruction
|
||||
// ================================================================================================
|
||||
procedure TNMBlock.AfterConstruction;
|
||||
begin
|
||||
fN := 0;
|
||||
fM := MaxInt;
|
||||
end;
|
||||
|
||||
// @@@: dgpGrammarElem overrides ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
// dgpGrammarElem overrides
|
||||
//
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// Generate
|
||||
// ================================================================================================
|
||||
procedure TNMBlock.Generate;
|
||||
begin
|
||||
|
||||
fGrammar.Generator.Gen( self);
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// Look
|
||||
// ================================================================================================
|
||||
function TNMBlock.Look(pK: integer): ILookahead;
|
||||
begin
|
||||
result := fGrammar.LLkAnalyzer.Look( pK, self);
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// ToString
|
||||
// ================================================================================================
|
||||
function TNMBlock.AsString: AnsiString;
|
||||
begin
|
||||
result := inherited AsString + '@';
|
||||
end;
|
||||
|
||||
// @@@: Property handlers +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
// Property handlers
|
||||
//
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// GetLow
|
||||
// ================================================================================================
|
||||
function TNMBlock.GetLow : integer;
|
||||
begin
|
||||
result := fN;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// GetHigh
|
||||
// ================================================================================================
|
||||
function TNMBlock.GetHigh : integer;
|
||||
begin
|
||||
result := fM
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// SetLow
|
||||
// ================================================================================================
|
||||
procedure TNMBlock.SetLow( Value: integer);
|
||||
begin
|
||||
fN := Value;
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
// SetHigh
|
||||
// ================================================================================================
|
||||
procedure TNMBlock.SetHigh(Value: integer);
|
||||
begin
|
||||
fM := Value;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user