Module Info.ItemSource

Explicit representation of LR(0) items. An item is a production with a dot position: A -> α . β. Items are indexed globally across all productions for efficient set operations. The dot position ranges from 0 (before all RHS symbols) to length (after all).

include INDEXED with type 'g n = 'g item
Sourcetype 'g n = 'g item
Sourceval cardinal : 'g grammar -> 'g n Fix.Indexing.cardinal
Sourceval of_int : 'g grammar -> int -> 'g n Fix.Indexing.index

make g prod pos creates an item for production prod with the dot at position pos. Raises Invalid_argument if pos is out of bounds.

last g prod creates an item with the dot at the end of production prod, i.e., the item where the production is fully recognized.

Sourceval prev : 'g grammar -> 'g n Fix.Indexing.index -> 'g n Fix.Indexing.index option

prev g item returns the previous item in the same production (dot moved one position left), or None if the dot is already at position 0.

desc g item returns the (production, position) pair for the item

Sourceval position : 'g grammar -> 'g n Fix.Indexing.index -> int

position g item returns the dot position within the item's production

production g item returns the production that this item belongs to

Sourceval is_reducible : 'g grammar -> 'g n Fix.Indexing.index -> bool

is_reducible g item returns true if the dot is at the end of the production, meaning the item is ready to be reduced.

Sourceval to_string : 'g grammar -> 'g n Fix.Indexing.index -> string

Converts an item to a human-readable string in standard notation, e.g., "A:B . c d"