All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.almondtools.rexlex.lexer.DynamicLexerBuilder Maven / Gradle / Ivy

Go to download

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);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy