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/Match.java

48 lines
978 B
Java
Raw Normal View History

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
/**
* The content of this match.
2017-07-25 22:47:48 -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
*
* @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) {
this.content = content;
2017-07-24 20:47:25 -07:00
this.type = type;
}
2017-07-25 22:47:48 -07:00
/**
* Gets the content of this match.
2017-07-30 21:11:32 -07:00
*
* @return the content.
2017-07-25 22:47:48 -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;
}
}