All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.parse.SyntaxNodeComparator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.parse;

import java.util.Comparator;

public class SyntaxNodeComparator implements Comparator {
   
   private final boolean reverse;
   
   public SyntaxNodeComparator() {
      this(false);
   }
   
   public SyntaxNodeComparator(boolean reverse) {
      this.reverse = reverse;
   }

   @Override
   public int compare(SyntaxNode left, SyntaxNode right) {
      Integer leftMark = left.getStart();
      Integer rightMark = right.getStart();
      
      if(reverse) {
         return rightMark.compareTo(leftMark); 
      }
      return leftMark.compareTo(rightMark);  
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy