anchor.diff:          // Return the closure of the item set.
           closure productions items
   
  +
  +//
  +type internal Lr0ParserState<'NonterminalId, 'Token
  +        when 'NonterminalId : comparison
  +        and 'Token : comparison> = Set<Lr0Item<'NonterminalId, 'Token>>
  +
  +/// LR(0) parser table generation state.
  +type internal Lr0TableGenState<'NonterminalId, 'Token
  +        when 'NonterminalId : comparison
  +        and 'Token : comparison> = {
  +    //
  +    Table : Map<LrParserStateId * Symbol<'NonterminalId, 'Token>, Set<LrParserTableAction>>;
  +    //
  +    ParserStates : Map<Lr0ParserState<'NonterminalId, 'Token>, LrParserStateId>;
  +    //
  +    ReductionRules : Map<'NonterminalId * Symbol<'NonterminalId, 'Token>[], LrReductionRuleId>;
  +    //
  +    ReductionRulesById : Map<LrReductionRuleId, 'NonterminalId * Symbol<'NonterminalId, 'Token>[]>;
  +}
  +
  +//
  +[<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  +module internal Lr0TableGenState =
  +    /// Returns an empty Lr0TableGenState with the given
  +    /// nonterminal and terminal types.
  +    let empty : Lr0TableGenState<'NonterminalId, 'Token> = {
  +        Table = Map.empty;
  +        ParserStates = Map.empty;
  +        ReductionRules = Map.empty;
  +        ReductionRulesById = Map.empty; }
  +
  +    /// Retrives the identifier for a given parser state (set of items).
  +    /// If the state has not been assigned an identifier, one is created
  +    /// and added to the table-generation state before returning.
  +    let stateId (parserState : Lr0ParserState<'NonterminalId, 'Token>) (tableGenState : Lr0TableGenState<'NonterminalId, 'Token>) =
  +        // Try to retrieve an existing id for this state.
  +        match Map.tryFind parserState tableGenState.ParserStates with
  +        | Some parserStateId ->
  +            parserStateId, tableGenState
  +
  +        | None ->
  +            // Create a new ID for this state.
  +            let parserStateId = LanguagePrimitives.Int32WithMeasure <| tableGenState.ParserStates.Count + 1
  +
  +            // Return the id, along with the updated table-gen state.
  +            parserStateId,
  +            { tableGenState with
  +                ParserStates = Map.add parserState parserStateId tableGenState.ParserStates; }
  +
  +    //
  +    let reductionRuleId (reductionRule : 'NonterminalId * Symbol<'NonterminalId, 'Token>[]) (tableGenState : Lr0TableGenState<'NonterminalId, 'Token>) =
  +        // Reduction rules should only be added, but for safety we'll check to
  +        // see if the rule has already been assigned an identifier.
  +        match Map.tryFind reductionRule tableGenState.ReductionRules with
  +        | Some reductionRuleId ->
  +            reductionRuleId, tableGenState
  +
  +        | None ->
  +            // Create a new ID for this reduction rule.
  +            let reductionRuleId = LanguagePrimitives.Int32WithMeasure <| tableGenState.ReductionRules.Count + 1
  +
  +            // Return the id, along with the updated table-gen state.
  +            reductionRuleId,
  +            { tableGenState with
  +                ReductionRules = Map.add reductionRule reductionRuleId tableGenState.ReductionRules;
  +                ReductionRulesById = Map.add reductionRuleId reductionRule tableGenState.ReductionRulesById; }
  +
  +    /// Add a 'shift' action to the parser table.
  +    let shift (sourceState : LrParserStateId)
  +                (transitionSymbol : 'Token)
  +                (targetState : LrParserStateId)
  +                (tableGenState : Lr0TableGenState<'NonterminalId, 'Token>) =
  +        //
  +        let tableKey = sourceState, Symbol.Terminal transitionSymbol
  +
  +        //
  +        let entry =
  +            let action = Shift targetState
  +            match Map.tryFind tableKey tableGenState.Table with
  +            | None ->
  +                Set.singleton action
  +            | Some entry ->
  +                Set.add action entry
  +
  +        // Update the table with the new entry.
  +        (),
  +        { tableGenState with
  +            Table = Map.add tableKey entry tableGenState.Table; }
  +
  +    /// Add a 'goto' action to the parser table.
  +    let goto (sourceState : LrParserStateId)
  +                (transitionSymbol : 'NonterminalId)
  +                (targetState : LrParserStateId)
  +                (tableGenState : Lr0TableGenState<'NonterminalId, 'Token>) =
  +        //
  +        let tableKey = sourceState, Symbol.Nonterminal transitionSymbol
  +
  +        //
  +        let entry =
  +            let action = Goto targetState
  +            match Map.tryFind tableKey tableGenState.Table with
  +            | None ->
  +                Set.singleton action
  +            | Some entry ->
  +                Set.add action entry
  +
  +        // Update the table with the new entry.
  +        (),
  +        { tableGenState with
  +            Table = Map.add tableKey entry tableGenState.Table; }
  +
  +    /// Add an 'accept' action to the parser table.
  +    let accept (sourceState : LrParserStateId) (tableGenState : Lr0TableGenState<'NonterminalId, AugmentedTerminal<'Token>>) =
  +        //
  +        let tableKey = sourceState, Symbol.Terminal EndOfFile
  +
  +        //
  +        let entry =
  +            match Map.tryFind tableKey tableGenState.Table with
  +            | None ->
  +                // Create a new 'accept' action for this table entry.
  +                Set.singleton Accept
  +            | Some entry ->
  +                // Create a new 'accept' action and add it to the existing table entry.
  +                Set.add Accept entry
  +
  +        // Update the table with the new entry.
  +        (),
  +        { tableGenState with
  +            Table = Map.add tableKey entry tableGenState.Table; }
  +
  +    /// Add 'reduce' actions to the parser table for each terminal (token) in the grammar.
  +    let reduce (sourceState : LrParserStateId) (reductionRuleId : LrReductionRuleId) (terminals : Set<_>) (tableGenState : Lr0TableGenState<'NonterminalId, AugmentedTerminal<'Token>>) =
  +        // Fold over the set of terminals (tokens) in the grammar.
  +        let table =
  +            (tableGenState.Table, terminals)
  +            ||> Set.fold (fun table token ->
  +                //
  +                let tableKey = sourceState, Symbol.Terminal token
  +
  +                //
  +                let entry =
  +                    let action = Reduce reductionRuleId
  +                    match Map.tryFind tableKey table with
  +                    | None ->
  +                        Set.singleton action
  +                    | Some entry ->
  +                        Set.add action entry
  +
  +                // Update the table with the entry.
  +                Map.add tableKey entry table)
  +
  +        // Return the updated table-gen state.
  +        (),
  +        { tableGenState with
  +            Table = table; }
  +
  +//
  +[<RequireQualifiedAccess>]
  +module internal Lr0 =
       //
       let rec private createTableImpl grammar (tableGenState : Lr0TableGenState<'NonterminalId, AugmentedTerminal<'Token>>) =
           // Preconditions
  
positive.code:                         | Symbol.Terminal (Terminal _ as token) as symbol ->                            
                              /// The state (set of items) transitioned into
                              /// via the edge labeled with this symbol.
                              let targetState = goto symbol stateItems grammar.Productions
  
                              /// The identifier of the target state.
                              let targetStateId, tableGenState =
  
negative.code:         // Return the closure of the item set.
          closure grammar analysis items
  
  
  //
  type internal Lr1ParserState<'NonterminalId, 'Token
          when 'NonterminalId : comparison
          and 'Token : comparison> = Set<Lr1Item<'NonterminalId, 'Token>>
  
  //
  [<RequireQualifiedAccess>]
  module Lr1 =
      //
      let createTable (grammar : Grammar<'NonterminalId, 'Token>) =
          // Augment the grammar with the start production and end-of-file token.
  