mirror of
https://github.com/DanilaFe/abacus
synced 2024-09-28 09:35:32 -07:00
32 lines
625 B
Java
32 lines
625 B
Java
package org.nwapw.abacus.lexing.pattern;
|
|
|
|
/**
|
|
* A node that matches a single value.
|
|
* @param <T> the type that's used to tell which pattern this node belongs to.
|
|
*/
|
|
public class ValueNode<T> extends PatternNode<T> {
|
|
|
|
/**
|
|
* The value this node matches.
|
|
*/
|
|
private char value;
|
|
|
|
/**
|
|
* Creates a new node that matches the given character.
|
|
* @param value
|
|
*/
|
|
public ValueNode(char value){
|
|
this.value = value;
|
|
}
|
|
|
|
@Override
|
|
public boolean matches(char other) {
|
|
return other == value;
|
|
}
|
|
|
|
@Override
|
|
public char range() {
|
|
return value;
|
|
}
|
|
}
|