def expand(item, firsts): next_symbol = item.NextSymbol if next_symbol is None or not next_symbol.IsNonTerminal: return [] lookaheads = ContainerSet() for preview in item.Preview(): lookaheads.hard_update(compute_local_first(firsts, preview)) assert not lookaheads.contains_epsilon return [Item(prod, 0, lookaheads) for prod in next_symbol.productions]
def Expand(item, firsts): next_symbol = item.NextSymbol if next_symbol is None or not next_symbol.IsNonTerminal: return [] lookaheads = ContainerSet() # (Compute lookahead for child items) for preview in item.Preview(): lookaheads.hard_update( UtilsParsers.ComputeLocalFirst(firsts, preview)) assert not lookaheads.contains_epsilon # (Build and return child items) return [Item(prod, 0, lookaheads) for prod in next_symbol.productions]
def expand(item, firsts): next_symbol = item.NextSymbol if next_symbol is None or not next_symbol.IsNonTerminal: return [] lookaheads = ContainerSet() # Your code here!!! (Compute lookahead for child items) for preview in item.Preview(): lookaheads.hard_update(compute_local_first(firsts, preview)) assert not lookaheads.contains_epsilon # Your code here!!! (Build and return child items) items = [] for production in next_symbol.productions: items.append(Item(production, 0, lookaheads)) return items