Back to project page NexusData.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...
If you think the Android project NexusData listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.dkharrat.nexusdata.predicate.parser; //from ww w .ja v a 2s . com import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; class LexerGrammar<T> { class TokenRule { private final Pattern pattern; private final T type; TokenRule(Pattern pattern, T type) { this.pattern = pattern; this.type = type; } Pattern getPattern() { return pattern; } T getType() { return type; } } private final List<TokenRule> tokenRules = new LinkedList<TokenRule>(); private final T eofToken; public LexerGrammar(T eofToken) { this.eofToken = eofToken; } void add(String regex, T tokenType) { tokenRules.add(new TokenRule(Pattern.compile("^\\s*(" + regex + ")\\s*"), tokenType)); } List<TokenRule> getRules() { return tokenRules; } T getEofToken() { return eofToken; } }