code: def compile_rules(environment):
      """Compiles all the rules from the environment into a list of rules."""
      e = re.escape
      rules = [
          (
              len(environment.comment_start_string),
              TOKEN_COMMENT_BEGIN,
              e(environment.comment_start_string),
          ),
          (
              len(environment.block_start_string),
              TOKEN_BLOCK_BEGIN,
              e(environment.block_start_string),
          ),
          (
              len(environment.variable_start_string),
              TOKEN_VARIABLE_BEGIN,
              e(environment.variable_start_string),
          ),
      ]
  
      if environment.line_statement_prefix is not None:
          rules.append(
              (
                  len(environment.line_statement_prefix),
                  TOKEN_LINESTATEMENT_BEGIN,
                  r"^[ \t\v]*" + e(environment.line_statement_prefix),
              )
          )
      if environment.line_comment_prefix is not None:
          rules.append(
              (
                  len(environment.line_comment_prefix),
                  TOKEN_LINECOMMENT_BEGIN,
                  r"(?:^|(?<=\S))[^\S\r\n]*"
                  + e(environment.line_comment_prefix),
              )
          )
  
      return [x[1:] for x in sorted(rules, reverse=True)]
  
imports: import re
  from ast import literal_eval
  from collections import deque
  from operator import itemgetter
  from ._compat import implements_iterator
  from ._compat import intern
  from ._compat import iteritems
  from ._compat import text_type
  from .exceptions import TemplateSyntaxError
  from .utils import LRUCache
label_desc: Use image node_id 5 for calling a global function with example usage: compile_rules(environment) and returns: unknown