org.snapscript.parse.SyntaxNodeComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
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);
}
}