kernel/src/main/java/org/kframework/parser/inner/kernel/EarleyParser.java
/**
   * Add a state to either S or Q depending on whether the next production item to parse is a terminal or a
   * non-terminal. May be added to neither if the next state expects a terminal not found next in the input.
   *
   * @param S The {@link EarleySet EarleySets} for completion and prediction.
   * @param Q The {@link EarleySet} for scanning
   * @param state The state that is being processed.
   * @param nextState The state that is being added to either S or Q.
   * @param k the current end-index being parsed.
   * @param data The {@link ParserMetadata} about the sentence being parsed.
   */
Add a state to either S or Q depending on whether the next production item to parse is a terminal or a
non-terminal. May be added to neither if the next state expects a terminal not found next in the input.

@param S The  EarleySet EarleySets for completion and prediction.
@param Q The  EarleySet for scanning
@param state The state that is being processed.
@param nextState The state that is being added to either S or Q.
@param k the current end-index being parsed.
@param data The  ParserMetadata about the sentence being parsed.
Add a state to either S or Q depending on whether the next production item to parse is a terminal or a non - terminal . May be added to neither if the next state expects a terminal not found next in the input . @param S The EarleySet EarleySets for completion and prediction . @param Q The EarleySet for scanning @param state The state that is being processed . @param nextState The state that is being added to either S or Q . @param k the current end - index being parsed . @param data The ParserMetadata about the sentence being parsed .
private void addStateToSet(List<EarleySet> S, EarleySet Q, EarleyState state, EarleyState nextState, int k, ParserMetadata data) {
    if (state.item+1 != state.prod.items.size() && !state.prod.items.get(state.item+1).isNonTerminal()) {
      EarleyTerminal t = (EarleyTerminal) state.prod.items.get(state.item+1);
      if (t.kind == data.words[k].kind) {
        Q.add(nextState, data);
      }
    } else {
      S.get(k).add(nextState, data);
    }
  }
private void addStateToSet ( List < EarleySet > S , EarleySet Q , EarleyState state , EarleyState nextState , int k , ParserMetadata data ) { if ( state . item + 1 != state . prod . items . size ( ) && ! state . prod . items . get ( state . item + 1 ) . isNonTerminal ( ) ) { EarleyTerminal t = ( EarleyTerminal ) state . prod . items . get ( state . item + 1 ) ; if ( t . kind == data . words [ k ] . kind ) { Q . add ( nextState , data ) ; } } else { S . get ( k ) . add ( nextState , data ) ; } }
Add a state to either S or Q depending on whether the next production item to parse is a terminal or a
 non-terminal.
Add a state to either S or Q depending on whether the next production item to parse is a terminal or a non - terminal .
// if the next item in the state is a terminal, scan it and possibly add it to Q' // state is either now complete or at a non-terminal, therefore add it to S[k+1]