with Generic_Set ; generic ---------------------------------------------------------------------------- -- T y p e s -- type Symbol is ( <> ) ; type Phrase is array ( Positive range <> ) of Symbol ; type To_Phrase is access Phrase ; type Phrases is array ( Positive range <> ) of To_Phrase ; type To_Phrases is access Phrases ; type Context_Free_Grammar is array ( Symbol range <> ) of To_Phrases ; ---------------------------------------------------------------------------- -- C o n s t a n t s -- Terminal_First : Symbol ; Terminal_Last : Symbol ; Productions : Context_Free_Grammar ; Start : Symbol ; Follow_Start : Symbol ; package Generic_CFG_to_NFA is ---------------------------------------------------------------------------- -- T y p e s -- subtype Terminal is Symbol range Terminal_First..Terminal_Last ; subtype Nonterminal is Symbol range Productions'Range ; type Item is record A : Nonterminal ; Dot : Positive ; Alpha : To_Phrase ; end record; type Item_Order is ( '<', '=', '>' ) ; function Compare ( Left, Right : Item ) return Item_Order ; function Equal ( Compare : Item_Order ) return Boolean ; function Less_Than ( Compare : Item_Order ) return Boolean ; package Items is new Generic_Set ( Item, Item_Order ) ; ---------------------------------------------------------------------------- -- O p e r a t i o n s -- function Start_Item return Item ; function Alphabet_Transition ( From : Items.Set ; On : Symbol ) return Items.Set ; function Epsilon_Closure ( From : Items.Set ) return Items.Set ; function Final ( From : Items.Set ) return Boolean ; function Handles ( From : Items.Set ) return Items.Set ; end Generic_CFG_to_NFA;