1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-06-30 06:40:58 -07:00
Abacus/core/src/main/java/org/nwapw/abacus/lexing/pattern/RangeNode.java

36 lines
783 B
Java
Raw Normal View History

package org.nwapw.abacus.lexing.pattern;
2017-07-25 22:47:48 -07:00
/**
* A node that matches a range of characters.
2017-07-30 21:11:32 -07:00
*
2017-07-25 22:47:48 -07:00
* @param <T> the type that's used to tell which pattern this node belongs to.
*/
public class RangeNode<T> extends PatternNode<T> {
2017-07-25 22:47:48 -07:00
/**
* The bottom bound of the range, inclusive.
*/
private char from;
2017-07-25 22:47:48 -07:00
/**
* The top bound of the range, inclusive.
*/
private char to;
2017-07-25 22:47:48 -07:00
/**
* Creates a new range node from the given range.
2017-07-30 21:11:32 -07:00
*
2017-07-25 22:47:48 -07:00
* @param from the bottom bound of the range.
2017-07-30 21:11:32 -07:00
* @param to the top bound of hte range.
2017-07-25 22:47:48 -07:00
*/
2017-07-30 21:11:32 -07:00
public RangeNode(char from, char to) {
this.from = from;
this.to = to;
}
@Override
public boolean matches(char other) {
return other >= from && other <= to;
}
}