Package org.rascalmpl.parser.gtd.result.struct

Examples of org.rascalmpl.parser.gtd.result.struct.Link


     
      // We know we haven't been here before.
      propagatedReductions.add(startLocation);
     
      ArrayList<Link> edgePrefixes = new ArrayList<Link>();
      Link prefix = (prefixes != null) ? new Link(prefixes[i], nodeResultStore) : new Link(null, nodeResultStore);
      edgePrefixes.add(prefix);
     
      Link resultLink = new Link(edgePrefixes, nextResultStore);
     
      EdgesSet<P> edgeSet = edgesMap.getValue(i);
     
      if(debugListener != null) debugListener.reducing(node, resultLink, edgeSet);
     
View Full Code Here


    if(hasNestingRestrictions){
      filteredParents = getFilteredParents(node.getId());
    }
   
    for(int i = edgesMap.size() - 1; i >= 0; --i){
      Link resultLink = new Link((prefixesMap != null) ? prefixesMap[i] : null, result);
     
      EdgesSet<P> edgeSet = edgesMap.getValue(i);
     
      if(debugListener != null) debugListener.reducing(node, resultLink, edgeSet);
     
View Full Code Here

      int startLocation = edgesMap.getKey(i);
     
      if(propagatedReductions.containsBefore(startLocation, initialSize)) continue; // Prevent duplicate reductions (artifact of the hidden-right-recursion fix).
      propagatedReductions.add(startLocation);
     
      Link resultLink = new Link((prefixesMap != null) ? prefixesMap[i] : null, result);
     
      EdgesSet<P> edgeSet = edgesMap.getValue(i);
     
      if(debugListener != null) debugListener.reducing(node, resultLink, edgeSet);
     
View Full Code Here

      // Initialize the prefixes map.
      prefixesMap = new ArrayList[edgesMap.size()];
     
      if(prefixesMapToAdd == null){ // The predecessor was the first node in the alternative, so the prefix of this node is just the predecessor's result.
        int index = edgesMap.findKey(predecessor.getStartLocation());
        addPrefix(new Link(null, predecessorResult), index);
      }else{ // The predecessor has prefixes.
        int nrOfPrefixes = edgesMapToAdd.size();
        for(int i = nrOfPrefixes - 1; i >= 0; --i){
          ArrayList<Link> prefixes = prefixesMap[i];
          if(prefixes == null){
            prefixes = new ArrayList<Link>(1);
            prefixesMap[i] = prefixes;
          }
         
          prefixes.add(new Link(prefixesMapToAdd[i], predecessorResult));
        }
      }
    }else if(edgesMap != edgesMapToAdd){ // A stack merge occurred (and the production is non-cyclic (expandable nodes, such as lists, can have cyclic child alternatives)).
      // Initialize the prefixes map (if necessary).
      int edgesMapSize = edgesMap.size();
      int possibleMaxSize = edgesMapSize + edgesMapToAdd.size();
      if(prefixesMap == null){
        prefixesMap = new ArrayList[possibleMaxSize];
      }else{
        if(prefixesMap.length < possibleMaxSize){
          ArrayList<Link>[] oldPrefixesMap = prefixesMap;
          prefixesMap = new ArrayList[possibleMaxSize];
          System.arraycopy(oldPrefixesMap, 0, prefixesMap, 0, edgesMapSize);
        }
      }
     
      if(prefixesMapToAdd == null){ // The predecessor was the first node in the alternative, so the prefix of this node is just the predecessor's result.
        addPrefix(new Link(null, predecessorResult), edgesMapSize);
        edgesMap.add(edgesMapToAdd.getKey(0), edgesMapToAdd.getValue(0));
      }else{ // The predecessor has prefixes.
        for(int i = edgesMapToAdd.size() - 1; i >= 0; --i){
          int startLocation = edgesMapToAdd.getKey(i);
          int index = edgesMap.findKeyBefore(startLocation, edgesMapSize); // Only look where needed.
          ArrayList<Link> prefixes;
          if(index == -1){ // No prefix set for the given start location is present yet.
            index = edgesMap.size();
            edgesMap.add(startLocation, edgesMapToAdd.getValue(i));
           
            prefixes = new ArrayList<Link>(1);
            prefixesMap[index] = prefixes;
          }else{ // A prefix set for the given start location is present.
            prefixes = prefixesMap[index];
          }
         
          // Add the prefix to the appropriate prefix set.
          prefixes.add(new Link(prefixesMapToAdd[i], predecessorResult));
        }
      }
    }else{ // A stack merge occurred and the production is self cyclic (expandable nodes, such as lists, can have cyclic child alternatives).
      if(prefixesMapToAdd == null){
        int index = edgesMap.findKey(predecessor.getStartLocation());
        addPrefix(new Link(null, predecessorResult), index);
      }else{
        int nrOfPrefixes = edgesMapToAdd.size();
        for(int i = nrOfPrefixes - 1; i >= 0; --i){
          // Add the prefix to the appropriate prefixes set.
          prefixesMap[i].add(new Link(prefixesMapToAdd[i], predecessorResult));
        }
      }
    }
  }
View Full Code Here

   
    // Initialize the prefixes map.
    prefixesMap = new ArrayList[edgesMap.size()];
   
    if(prefixesMapToAdd == null){ // The predecessor was the first node in the alternative, so the prefix of this node is just the predecessor's result.
      addPrefix(new Link(null, result), edgesMap.findKey(predecessor.getStartLocation()));
    }else{ // The predecessor has prefixes.
      int nrOfPrefixes = edgesMap.size();
      for(int i = nrOfPrefixes - 1; i >= 0; --i){ // Since we reuse the edges map the indexes of the prefixes map will correspond to the same start locations.
        ArrayList<Link> prefixes = new ArrayList<Link>(1);
        prefixesMap[i] = prefixes;
        // Add the prefix to the appropriate prefixes set.
        prefixes.add(new Link(prefixesMapToAdd[i], result));
      }
    }
  }
View Full Code Here

      }
    }
   
    int nrOfAddedEdges = 0;
    if(prefixesMapToAdd == null){ // The predecessor was the first node in the alternative, so the prefix of this node is just the predecessor's result.
      addPrefix(new Link(null, result), edgesMapSize);
      edgesMap.add(predecessor.getStartLocation(), edgesMapToAdd.getValue(0));
      nrOfAddedEdges = 1;
    }else{ // The predecessor has prefixes.
      int fromIndex = edgesMapToAdd.size() - edgesMapSize;
      for(int i = edgesMapToAdd.size() - 1; i >= fromIndex; --i){
        int startLocation = edgesMapToAdd.getKey(i);
       
        // Prefix not present, add it.
        int index = edgesMap.findKey(startLocation);
        ArrayList<Link> prefixes;
        if(index == -1){ // No prefix set for the given start location is present yet.
          index = edgesMap.size();
          edgesMap.add(startLocation, edgesMapToAdd.getValue(i));
         
          prefixes = new ArrayList<Link>(1);
          prefixesMap[index] = prefixes;
         
          ++nrOfAddedEdges;
        }else{ // A prefix set for the given start location is present.
          prefixes = prefixesMap[index];
        }
       
        // Add the prefix to the prefix set.
        prefixes.add(new Link(prefixesMapToAdd[i], result));
      }
    }
   
    return nrOfAddedEdges;
  }
View Full Code Here

    }
   
    int nrOfAddedEdges = 0;
    if(prefixesMapToAdd == null){ // The predecessor was the first node in the alternative, so the prefix of this node is just the predecessor's result.
      // A prefix is not yet present, so add it. As it's the first and only possible nullable prefix, it's guaranteed that there aren't any prefixes for the current start location present yet.
      addPrefix(new Link(null, result), edgesMapSize);
      edgesMap.add(predecessor.getStartLocation(), edgesMapToAdd.getValue(0));
      nrOfAddedEdges = 1;
    }else{ // The predecessor has prefixes.
      int fromIndex = edgesMapToAdd.size() - potentialNewEdges;
      for(int i = edgesMapToAdd.size() - 1; i >= fromIndex; --i){
        int startLocation = edgesMapToAdd.getKey(i);
       
        // Prefix not present, add it.
        int index = edgesMap.findKey(startLocation);
       
        ArrayList<Link> prefixes;
        if(index == -1){ // No prefix set for the given start location is present yet.
          index = edgesMap.size();
          edgesMap.add(startLocation, edgesMapToAdd.getValue(i));
          propagatedPrefixes.set(index);
         
          prefixes = new ArrayList<Link>(1);
          prefixesMap[index] = prefixes;
         
          ++nrOfAddedEdges;
        }else{ // A prefix set for the given start location is present.
          if(propagatedPrefixes.isSet(index)) continue; // Prefix present, abort.
         
          prefixes = prefixesMap[index];
        }
       
        // Add the prefix to the prefix set.
        prefixes.add(new Link(prefixesMapToAdd[i], result));
      }
    }
   
    return nrOfAddedEdges;
  }
View Full Code Here

        return;
      }
     
      // One prefix, so not ambiguous at this point.
      if(prefixes.size() == 1){
        Link prefix = prefixes.get(0);
       
        if(prefix == null){ // Start of the production encountered.
          buildAlternative(converter, nodeConstructorFactory, noChildren, postFix, production, gatheredAlternatives, stack, depth, cycleMark, positionStore, offset, endOffset, filteringTracker, actionExecutor, environment);
          return;
        }
       
        AbstractNode prefixNode = prefix.getNode();
        if(blackList.contains(prefixNode)) return; // 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 cycle, insert it.
View Full Code Here

   
    // Gather all alternative prefixes.
    ArrayList<T> gatheredPrefixes = new ArrayList<T>();
   
    for(int i = prefixes.size() - 1; i >= 0; --i){
      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.
View Full Code Here

      }
     
      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);
        }
       
View Full Code Here

TOP

Related Classes of org.rascalmpl.parser.gtd.result.struct.Link

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.