1
0
mirror of https://github.com/DanilaFe/abacus synced 2025-04-22 16:37:08 -07:00
Abacus/src/org/nwapw/abacus/lexing/pattern/Match.java

58 lines
1.3 KiB
Java
Raw Normal View History

2017-07-24 20:47:25 -07:00
package org.nwapw.abacus.lexing.pattern;
2017-07-25 22:47:48 -07:00
/**
* A match that has been generated by the lexer.
* @param <T> the type used to represent the ID of the pattern this match belongs to.
*/
2017-07-24 20:47:25 -07:00
public class Match<T> {
2017-07-25 22:47:48 -07:00
/**
* The bottom range of the string, inclusive.
*/
2017-07-24 20:47:25 -07:00
private int from;
2017-07-25 22:47:48 -07:00
/**
* The top range of the string, exclusive.
*/
2017-07-24 20:47:25 -07:00
private int to;
2017-07-25 22:47:48 -07:00
/**
* The pattern type this match matched.
*/
2017-07-24 20:47:25 -07:00
private T type;
2017-07-25 22:47:48 -07:00
/**
* Creates a new match with the given parameters.
* @param from the bottom range of the string.
* @param to the top range of the string.
* @param type the type of the match.
*/
2017-07-24 20:47:25 -07:00
public Match(int from, int to, T type){
this.from = from;
this.to = to;
this.type = type;
}
2017-07-25 22:47:48 -07:00
/**
* Gets the bottom range bound of the string.
* @return the bottom range bound of the string.
*/
2017-07-24 20:47:25 -07:00
public int getFrom() {
return from;
}
2017-07-25 22:47:48 -07:00
/**
* Gets the top range bound of the string.
* @return the top range bound of the string.
*/
2017-07-24 20:47:25 -07:00
public int getTo() {
return to;
}
2017-07-25 22:47:48 -07:00
/**
* Gets the pattern type of the node.
* @return the ID of the pattern that this match matched.
*/
2017-07-24 20:47:25 -07:00
public T getType() {
return type;
}
}