Description | Hierarchy | Fields | Methods | Properties |
type TProduction = class(TObject)
This is just a double-linked list of TSymbol instances. It's reference counted, so it can be used by more than one TNonTerminal.
![]() |
constructor Create; |
![]() |
destructor Destroy; override; |
![]() |
function FirstSymbol: TSymbol; |
![]() |
function LastSymbol: TSymbol; |
![]() |
function Empty: boolean; |
![]() |
procedure Collect( var FirstIndex: Cardinal; CollectValues: boolean; ProductionsList: TProductionsList; out UsedTerminals: TSetOfChars); |
![]() |
function CollectValue: string; |
![]() |
procedure DoCollectGrammarSize( var GrammarSize: Cardinal; var FirstIndexProductions: Cardinal; var UsedTerminals: TSetOfChars); |
![]() |
function GraphLabel(LongNonTerminalNames: boolean): string; |
![]() |
procedure GraphSaveToStream(Stream: TStream; LongNonTerminalNames: boolean); |
![]() |
procedure GraphSaveToFile(const FileName: string; LongNonTerminalNames: boolean); |
![]() |
procedure SaveToStream(Stream: TStream); |
![]() |
constructor CreateFromStream(Stream: TStream); |
![]() |
procedure GrammarSizes(var GrammarSize, SymbolsCount, NonTerminalsCount, TerminalsCount, BitsPerSymbol: Cardinal); |
![]() |
function Name: string; |
![]() |
procedure ReleaseSymbols; |
![]() |
procedure SimpleCalculateCollectedValue; |
![]() |
property UsedCount: Cardinal read FUsedCount; |
![]() |
property CollectedIndex: Integer read FCollectedIndex; |
![]() |
property CollectedValue: string read FCollectedValue write FCollectedValue; |
![]() |
constructor Create; |
![]() |
destructor Destroy; override; |
![]() |
function FirstSymbol: TSymbol; |
Note that these return special Guard symbol when production is empty. |
![]() |
function LastSymbol: TSymbol; |
![]() |
function Empty: boolean; |
![]() |
procedure Collect( var FirstIndex: Cardinal; CollectValues: boolean; ProductionsList: TProductionsList; out UsedTerminals: TSetOfChars); |
This is used to recursively calculate various properties of this production, and productions referenced by used non-terminals. Sets CollectedIndex of this production and then all referenced productions, recursively. Starts indexing using FirstIndex, and always after assigning some CollectedIndex increments FirstIndex, so FirstIndex should always indicate next free index. Each time when index is assigned it adds the item to ProductionsList, so ProductionsList contains all the indexed items, in the indexing order. Pass ProductionsList = nil if you don't need this. If CollectValues then also sets CollectedValue of this production and all children. CollectValues = UsedTerminals is set to all terminals used. |
![]() |
function CollectValue: string; |
This is like simpler version of Collect, when all you want is to set CollectedValue. This calculates CollectedValue of this production and all references productions, and then returns CollectedValue (that's comfortable sometimes). |
![]() |
procedure DoCollectGrammarSize( var GrammarSize: Cardinal; var FirstIndexProductions: Cardinal; var UsedTerminals: TSetOfChars); |
![]() |
function GraphLabel(LongNonTerminalNames: boolean): string; |
![]() |
procedure GraphSaveToFile(const FileName: string; LongNonTerminalNames: boolean); |
Like GraphSaveToStream but takes FileName as a parameter. |
![]() |
procedure SaveToStream(Stream: TStream); |
Saves grammar starting from this production to a binary stream, trying to use as little bits as possible. In other words: do the compression. |
![]() |
constructor CreateFromStream(Stream: TStream); |
Loads grammar from a binary stream saved by SaveToStream. In other words: do 1st part the decompression (2nd part is to actually calculate the result, this is easily done by the Collect method). |
![]() |
procedure GrammarSizes(var GrammarSize, SymbolsCount, NonTerminalsCount, TerminalsCount, BitsPerSymbol: Cardinal); |
Calculate various sizes and counts of this grammar. |
![]() |
function Name: string; |
![]() |
procedure ReleaseSymbols; |
Simply set this production to empty, forgetting about all symbols between FirstSymbol and LastSymbol. You're responsible to save somewhere FirstSymbol and/or LastSymbol references before calling this, to not leak memory. |
![]() |
procedure SimpleCalculateCollectedValue; |
Calculates CollectedValue by simply iteraring over items of this production, and assuming that all children productions already have correct CollectedValue. |
![]() |
property UsedCount: Cardinal read FUsedCount; |
![]() |
property CollectedIndex: Integer read FCollectedIndex; |