com.almondtools.rexlex.lexer.DynamicLexerBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexlex Show documentation
Show all versions of rexlex Show documentation
Regular expression matchers, searcher, lexers based on deterministic finite automata
The newest version!
package com.almondtools.rexlex.lexer;
import java.util.LinkedHashMap;
import java.util.Map;
import com.almondtools.rexlex.Lexer;
import com.almondtools.rexlex.LexerBuilder;
import com.almondtools.rexlex.Token;
import com.almondtools.rexlex.TokenFactory;
import com.almondtools.rexlex.TokenType;
public class DynamicLexerBuilder implements LexerBuilder {
private TokenFactory factory;
private Map patterns;
private TokenType remainder;
public DynamicLexerBuilder(TokenFactory factory) {
this.factory = factory;
this.patterns = new LinkedHashMap();
}
@Override
public Lexer build() {
return new DynamicLexer(patterns, remainder, factory);
}
@Override
public void matchRemainder(TokenType type) {
this.remainder = type;
}
@Override
public void matchPattern(String pattern, TokenType type) {
this.patterns.put(pattern, type);
}
}