code: def _compile_rules(self):
          
          for state, table in self.RULES.items():
              patterns = list()
              actions = list()
              nextstates = list()
              for i, row in enumerate(table):
                  if len(row) == 2:
                      pattern, _action = row
                      nextstate = None
                  elif len(row) == 3:
                      pattern, _action, nextstate = row
                  else:
                      fstr = "invalid RULES: state {}, row {}"
                      raise CompileError(fstr.format(state, i))
                  patterns.append(pattern)
                  actions.append(_action)
                  nextstates.append(nextstate)
              reobj = re.compile('|'.join("(" + p + ")" for p in patterns))
              self._rules[state] = (reobj, actions, nextstates)
docs: Compile the rules into the internal lexer state.