Package Coco

Examples of Coco.NodeProvider


    //instantiate the state sets
    currentStates = new HashSet<State>();   
    followerStates = new HashSet<State>();
   
    //enter the start Symbol of the language
    followerStates.add(new StartState(new NodeProvider(tab.gramSy)));
   
   
   
    //set stop position to offset -1, so that unfinished written tokens aren't mistaken for another similar token (most likely as ident)
//    stopPosition = offset-1;
View Full Code Here


   * @return the state which the next pointer of s points at.
   *        the next pointer of the parent production if the next pointer of s is null,
   *        null, if the next pointer is null and the stack is empty (the end of the grammar has been reached),
   */
  private State getNextState(State s){
    NodeProvider next = s.getNext();
    LinkedList<NodeProvider> stack = s.getStack();
   
    if(next.getNode() == null){
      if(stack.isEmpty()){
        return null;
      }
     
      else{
        NodeProvider node = stack.removeLast();       
        State parent = new State(node, stack)
       
        return getNextState(parent);
      }
    }
View Full Code Here

    HashSet<State> followers = new HashSet<State>();
    if(s==null){
     
    }
    else{
      NodeProvider node = s.getNode();
      LinkedList<NodeProvider> stack = s.getStack();
     
      int nodeType = node.getType();
      switch(nodeType){
        case NodeProvider.eps:         
          State follower2 = getNextState(s);
          followers.addAll(calculateFollowers(follower2));
          break;
     
        case NodeProvider.opt:
        case NodeProvider.iter:
         
         
          State sub = new State(node.getSub(), stack);
          State next = getNextState(s);
         
          followers.addAll(calculateFollowers(sub));
         
         
          followers.addAll(calculateFollowers(next));
          break;
        case NodeProvider.alt:
          State alt1 = new State(node.getSub(), stack);
          State alt2 = new State(node.getDown(), stack);
         
         
          followers.addAll(calculateFollowers(alt1));     
         
          if(alt2.getNode().getNode()!=null){
            followers.addAll(calculateFollowers(alt2));
          }
         

          break;
         
        case NodeProvider.nt:
         
         
          //only continue if the peek token is a terminal follower of the nt
//          BitSet terminalFollowers = node.getSymbol().getTerminalFollowers();
//          BitSet nonTerminalFollowers = node.getSymbol().getNonTerminalFollowers();
          BitSet startSymbols = node.getSymbol().getStartSymbols();
//          System.out.println(getPeekTokenKind() + " " + node.getSymbol().getName());
//          for(int i = 0; i < startSymbols.size(); i++){
//            System.out.print(i + " " +startSymbols.get(i) + " ");           
//          }
//          System.out.println();
          if(startSymbols.get(getPeekTokenKind())){
            stack.add(node);
            State first = new State(node.getSymbol().getGraph(), stack);
            followers.addAll(calculateFollowers(first));
          }
          else if(node.getSymbol().isDeletable()){
            State over = getNextState(s);
            followers.addAll(calculateFollowers(over));
          }
         
         
         
          break;
        case NodeProvider.t:
        case NodeProvider.wt:
                   
          if(getPeekTokenKind() == node.getSymbol().getNumber()){
            followers.add(s);
          }
          break;
         
        default:
View Full Code Here

    if(s==null){
     
    }
   
    else{
      NodeProvider node = s.getNode();
      LinkedList<NodeProvider> stack = s.getStack();
     
      int nodeType = node.getType();
      switch(nodeType){
        case NodeProvider.eps:         
          State follower2 = getNextState(s);
          collextProductionsAndTokens(follower2);
          break;
     
        case NodeProvider.opt:
        case NodeProvider.iter:
         
         
          State sub = new State(node.getSub(), stack);
          State next = getNextState(s);
         
          collextProductionsAndTokens(sub);
         
         
          collextProductionsAndTokens(next);
          break;
        case NodeProvider.alt:
          State alt1 = new State(node.getSub(), stack);
          State alt2 = new State(node.getDown(), stack);
         
         
          collextProductionsAndTokens(alt1);     
         
          if(alt2.getNode().getNode()!=null){
            collextProductionsAndTokens(alt2);
          }
         

          break;
         
        case NodeProvider.nt:
          productionProposals.add(s.getNode());
         
          stack.add(node);
          State first = new State(node.getSymbol().getGraph(), stack);
          collextProductionsAndTokens(first);
         
         
          break;
        case NodeProvider.t:
View Full Code Here

TOP

Related Classes of Coco.NodeProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.