139 lines
5.5 KiB
ObjectPascal
139 lines
5.5 KiB
ObjectPascal
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.
|