Class EnumParserLookaheadActivator<R extends Enum<R>,T extends Enum<T>,V extends Enum<V>>

  extended by<R,T,V>
Type Parameters:
R - type of rule (must be an enum).
T - type of terminal (must be an enum).
V - type of version (must be an enum).
All Implemented Interfaces:

public class EnumParserLookaheadActivator<R extends Enum<R>,T extends Enum<T>,V extends Enum<V>>
extends Object
implements RuleActivator<R>

A rule activator that use parser lookaheads. For each parser state, the implementation used the set of possible terminal given by the parser to find the set corresponding rules to activate. This implementation supposes that rules and terminals are specified using enums. In order to improve speed and memory usage, this activator internally uses EnumSet and EnumMap. This implementation pre-calculate all possibles rule set for all parser state.

Remi Forax
See Also:

Constructor Summary
EnumParserLookaheadActivator(Parser<T,?,?,V> parser, EnumMap<T,EnumSet<R>> terminalMap, Class<R> ruleClass, EnumSet<R> unconditionalRules)
Method Summary
 Iterable<? extends R> activeRules()
          Determines the set of active rules.
 Iterable<? extends R> allRules()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public EnumParserLookaheadActivator(Parser<T,?,?,V> parser,
                                    EnumMap<T,EnumSet<R>> terminalMap,
                                    Class<R> ruleClass,
                                    EnumSet<R> unconditionalRules)
parser - a simple parser
terminalMap - a map that associate a set of rules that create a terminal.
ruleClass - the class of the rule.
unconditionalRules - the set of unconditional rules.
Method Detail


public Iterable<? extends R> activeRules()
Description copied from interface: RuleActivator
Determines the set of active rules. The method activateRules is called before the beginning of new token recognition.

Specified by:
activeRules in interface RuleActivator<R extends Enum<R>>
new set of active rules


public Iterable<? extends R> allRules()
Specified by:
allRules in interface RuleActivator<R extends Enum<R>>