2017-09-23 23:43:08 -07:00
|
|
|
package org.nwapw.abacus.lexing;
|
2017-07-24 20:47:25 -07:00
|
|
|
|
2017-07-25 22:47:48 -07:00
|
|
|
/**
|
|
|
|
* A match that has been generated by the lexer.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-25 22:47:48 -07:00
|
|
|
* @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
|
|
|
/**
|
2017-07-29 21:13:32 -07:00
|
|
|
* The content of this match.
|
2017-07-25 22:47:48 -07:00
|
|
|
*/
|
2017-07-29 21:13:32 -07:00
|
|
|
private String content;
|
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.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-29 21:13:32 -07:00
|
|
|
* @param content the content of this match.
|
2017-07-30 21:11:32 -07:00
|
|
|
* @param type the type of the match.
|
2017-07-25 22:47:48 -07:00
|
|
|
*/
|
2017-07-30 21:11:32 -07:00
|
|
|
public Match(String content, T type) {
|
2017-07-29 21:13:32 -07:00
|
|
|
this.content = content;
|
2017-07-24 20:47:25 -07:00
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
2017-07-25 22:47:48 -07:00
|
|
|
/**
|
2017-07-29 21:13:32 -07:00
|
|
|
* Gets the content of this match.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-29 21:13:32 -07:00
|
|
|
* @return the content.
|
2017-07-25 22:47:48 -07:00
|
|
|
*/
|
2017-07-29 21:13:32 -07:00
|
|
|
public String getContent() {
|
|
|
|
return content;
|
2017-07-24 20:47:25 -07:00
|
|
|
}
|
|
|
|
|
2017-07-25 22:47:48 -07:00
|
|
|
/**
|
|
|
|
* Gets the pattern type of the node.
|
2017-07-30 21:11:32 -07:00
|
|
|
*
|
2017-07-25 22:47:48 -07:00
|
|
|
* @return the ID of the pattern that this match matched.
|
|
|
|
*/
|
2017-07-24 20:47:25 -07:00
|
|
|
public T getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|