kernel/src/main/java/org/kframework/parser/inner/kernel/EarleyParser.java
/**
     * Adds an {@link EarleyState} to the set.
     *
     * @param state The state to be added.
     * @param data The {@link ParserMetadata} about the current sentence being parsed.
     */
Adds an  EarleyState to the set.
@param state The state to be added.
@param data The  ParserMetadata about the current sentence being parsed.
Adds an EarleyState to the set . @param state The state to be added . @param data The ParserMetadata about the current sentence being parsed .
public void add(EarleyState state, ParserMetadata data) {
      EarleyState prevState = membership.get(state.start).get(state);
      if (prevState != null) { 
        unionParseTree(prevState, state);
        if (state.item == state.prod.items.size()) {
          Set<Term> parses = completedParses(state.prod.sort, state.start);
          wrapState(parses, state.parseTree(), state.prod, state.start, index, data);
        }
        return;
      }
      states.add(state);
      membership.get(state.start).put(state, state);
      if (state.item != state.prod.items.size() && state.prod.items.get(state.item).isNonTerminal()) {
        EarleyNonTerminal nt = (EarleyNonTerminal)state.prod.items.get(state.item);
        completor.get(nt.sort).add(state);
      } else if (state.item == state.prod.items.size()) {
        Set<Term> parses = completedParses(state.prod.sort, state.start);
        wrapState(parses, state.parseTree(), state.prod, state.start, index, data);
      }
    }
public void add ( EarleyState state , ParserMetadata data ) { EarleyState prevState = membership . get ( state . start ) . get ( state ) ; if ( prevState != null ) { unionParseTree ( prevState , state ) ; if ( state . item == state . prod . items . size ( ) ) { Set < Term > parses = completedParses ( state . prod . sort , state . start ) ; wrapState ( parses , state . parseTree ( ) , state . prod , state . start , index , data ) ; } return ; } states . add ( state ) ; membership . get ( state . start ) . put ( state , state ) ; if ( state . item != state . prod . items . size ( ) && state . prod . items . get ( state . item ) . isNonTerminal ( ) ) { EarleyNonTerminal nt = ( EarleyNonTerminal ) state . prod . items . get ( state . item ) ; completor . get ( nt . sort ) . add ( state ) ; } else if ( state . item == state . prod . items . size ( ) ) { Set < Term > parses = completedParses ( state . prod . sort , state . start ) ; wrapState ( parses , state . parseTree ( ) , state . prod , state . start , index , data ) ; } }
Adds an {@link EarleyState} to the set.
Adds an { @link EarleyState } to the set .
// if the state already exists in the set // merge previous and current state's parse tree. // if the state is complete, add the proper derivations to the CompleteParseTreeNode // add state to set // compute metadata about new state // if the state is complete, add the proper derivations to the CompleteParseTreeNode