Package org.rascalmpl.parser.gtd.result

Examples of org.rascalmpl.parser.gtd.result.AbstractNode


      Link prefix = prefixes.get(i);
     
      if(prefix == null){ // List start node encountered.
        buildAlternative(converter, nodeConstructorFactory, noChildren, postFix, production, gatheredAlternatives, stack, depth, cycleMark, positionStore, offset, endOffset, filteringTracker, actionExecutor, environment);
      }else{
        AbstractNode prefixNode = prefix.getNode();
        if(blackList.contains(prefixNode)) continue; // Prefix node is not allowed (due to being part of a cycle already gathered cycle).
       
        if(prefixNode.isEmpty() && !prefixNode.isNonterminalSeparator()){ // Possibly a cycle (separators can't start or end cycles, only elements can).
          CycleNode cycle = gatherCycle(prefix, new AbstractNode[]{prefixNode}, blackList);
          if(cycle != null){ // Encountered a cycle.
            gatherProduction(converter, nodeConstructorFactory, prefix, new ForwardLink<AbstractNode>(NO_NODES, cycle), gatheredPrefixes, production, stack, depth, cycleMark, sharedPrefixCache, positionStore, blackList, offset, endOffset, filteringTracker, actionExecutor, environment);
            continue;
          }
View Full Code Here


 
  /**
   * Gathers the cycle related to the given child.
   */
  private CycleNode gatherCycle(Link child, AbstractNode[] postFix, ArrayList<AbstractNode> blackList){
    AbstractNode originNode = child.getNode();
   
    blackList.add(originNode); // Prevent the cycle node from being traversed again.
   
    OUTER : do{
      ArrayList<Link> prefixes = child.getPrefixes();
      if(prefixes == null){ // Encountered the start of the list (so no cycle detected).
        return null;
      }
     
      int nrOfPrefixes = prefixes.size();
     
      for(int i = nrOfPrefixes - 1; i >= 0; --i){
        Link prefix = prefixes.get(i);
        if(prefix == null) continue;
        AbstractNode prefixNode = prefix.getNode();
       
        if(prefixNode == originNode){ // Cycle detected.
          return new CycleNode(postFix);
        }
       
        if(prefixNode.isEmpty()){ // Only empty nodes can be part of a cycle.
          int length = postFix.length;
          AbstractNode[] newPostFix = new AbstractNode[length + 1];
          System.arraycopy(postFix, 0, newPostFix, 1, length);
          newPostFix[0] = prefixNode;
         
View Full Code Here

 
  /**
   * Gather all the alternatives ending with the given child.
   */
  private void gatherAlternatives(INodeFlattener<T, S> converter, INodeConstructorFactory<T, S> nodeConstructorFactory, Link child, ArrayList<T> gatheredAlternatives, Object production, IndexedStack<AbstractNode> stack, int depth, CycleMark cycleMark, PositionStore positionStore, S sourceLocation, int offset, int endOffset, FilteringTracker filteringTracker, IActionExecutor<T> actionExecutor, Object environment){
    AbstractNode resultNode = child.getNode();
   
    if(!(resultNode.isEpsilon() && child.getPrefixes() == null)){ // Has non-epsilon results.
      gatherProduction(converter, nodeConstructorFactory, child, new ForwardLink<AbstractNode>(NO_NODES, resultNode), gatheredAlternatives, production, stack, depth, cycleMark, positionStore, sourceLocation, offset, endOffset, filteringTracker, actionExecutor, environment);
    }else{ // Has a single epsilon result.
      buildAlternative(converter, nodeConstructorFactory, NO_NODES, gatheredAlternatives, production, stack, depth, cycleMark, positionStore, sourceLocation, offset, endOffset, filteringTracker, actionExecutor, environment);
    }
  }
View Full Code Here

    Object newEnvironment = actionExecutor.enteringProduction(production, environment); // Fire a 'entering production' event to enable environment handling.
   
    int postFixLength = postFix.length;
    ArrayList<T> children = new ArrayList<T>();
    for(int i = 0; i < postFixLength; ++i){
      AbstractNode node = postFix.element;
      postFix = postFix.next;
     
      newEnvironment = actionExecutor.enteringNode(production, i, newEnvironment); // Fire a 'entering node' event when converting a child to enable environment handling.
     
      T constructedNode = converter.convert(nodeConstructorFactory, node, stack, depth, cycleMark, positionStore, filteringTracker, actionExecutor, environment);
View Full Code Here

      AbstractStackNode<IConstructor> failedNode = unmatchableMidProductionNodes.getSecond(i).getCleanCopy(location); // Clone it to prevent by-reference updates of the static version
     
      // Merge the information on the predecessors into the failed node.
      for(int j = failedNodePredecessors.size() - 1; j >= 0; --j){
        AbstractStackNode<IConstructor> predecessor = failedNodePredecessors.getFirst(j);
        AbstractNode predecessorResult = failedNodePredecessors.getSecond(j);
        failedNode.updateNode(predecessor, predecessorResult);
      }
     
      failedNodes.add(failedNode);
    }
View Full Code Here

TOP

Related Classes of org.rascalmpl.parser.gtd.result.AbstractNode

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.