'Constructor.
Args:
state_regex: If this regular expression matches the current state this
rule is considered.
regex: A regular expression to try and match from the current point.
actions: A command separated list of method names in the Lexer to call.
next_state: The next state we transition to if this Token matches.
flags: re flags.'

def __init__(self, state_regex, regex, actions, next_state, flags=re.I):

    if state_regex:
        self.state_regex = re.compile(state_regex, ((((re.DOTALL | re.M) | re.S) | re.U) | flags))
    self.regex = re.compile(regex, ((((re.DOTALL | re.M) | re.S) | re.U) | flags))
    self.re_str = regex
    self.actions = []
    if actions:
        self.actions = actions.split(',')
    self.next_state = next_state
