parameters: (environment)
return_statement: return [x[1:] for x in sorted(rules, reverse=True)]
docstring: Compiles all the rules from the environment into a list of rules.
docstring_summary: Compiles all the rules from the environment into a list of rules.
docstring_tokens: Compiles all the rules from the environment into a list of rules .
function: 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)]
function_tokens: def compile_rules ( environment ) : 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 ) ]