Package eu.bandm.tools.lexic
Class TokenRuleSet<T>
java.lang.Object
eu.bandm.tools.lexic.TokenRuleSet<T>
- Type Parameters:
T
- the type of token types
A set of token rules together with a precendence relation between
token types.
An object of this class completely defines the lexical structure of a formal language.
FIXME: documentation of union and precedence
-
Constructor Summary
ConstructorDescriptionTokenRuleSet
(TokenRule<T>... rules) Creates a new instance with the given rules and the empty precedence relation.TokenRuleSet
(Collection<? extends TokenRule<T>> rules) Creates a new instance with the given rules and the empty precedence relation.TokenRuleSet
(BiPredicate<? super T, ? super T> precedenceOracle, TokenRule<T>... rules) Creates a new instance with the given rules and precedence relation.TokenRuleSet
(BiPredicate<? super T, ? super T> precedenceOracle, Collection<? extends TokenRule<T>> rules) Creates a new instance with the given rules and precedence relation. -
Method Summary
Modifier and TypeMethodDescriptionfilterByPrecedence
(Collection<T> types) Returns the preferred token types from a given collection according to the precedence relation.getRules()
Returns the set of token rules.
-
Constructor Details
-
TokenRuleSet
Creates a new instance with the given rules and the empty precedence relation.- Parameters:
rules
- the token rules
-
TokenRuleSet
@SafeVarargs public TokenRuleSet(BiPredicate<? super T, ? super T> precedenceOracle, TokenRule<T>... rules) Creates a new instance with the given rules and precedence relation.- Parameters:
precedenceOracle
- a predicate that encodes the precedence relationrules
- the token rules
-
TokenRuleSet
Creates a new instance with the given rules and the empty precedence relation.- Parameters:
rules
- the token rules
-
TokenRuleSet
public TokenRuleSet(BiPredicate<? super T, ? super T> precedenceOracle, Collection<? extends TokenRule<T>> rules) Creates a new instance with the given rules and precedence relation.- Parameters:
precedenceOracle
- a predicate that encodes the precedence relationrules
- the token rules
-
-
Method Details
-
getRules
Returns the set of token rules.- Returns:
- an unmodifiable set containing the token rules
-
filterByPrecedence
Returns the preferred token types from a given collection according to the precedence relation.- Parameters:
types
- a collection of token types- Returns:
- a list containing only the preferred among the given token types
-