protected static function compile($stream) { $regex = self::$regex; $options = self::$options; // Load in aliases and macros if (!self::$assetsLoaded) { self::loadAssets(); self::$assetsLoaded = true; } // Set aliases. May be pruned if a vendor target is set self::$aliases = self::$aliasesRaw; self::pruneAliases(); // Parse variables $stream = self::extractVariables($stream); // Calculate the variable stack self::calculateVariables(); self::log(self::$storage->variables); // Place the variables $stream = self::placeVariables($stream); // Normalize whitespace $stream = csscrush_util::normalizeWhiteSpace($stream); // Adjust the stream so we can extract the rules cleanly $map = array('@' => "\n@", '}' => "}\n", '{' => "{\n", ';' => ";\n"); $stream = "\n" . str_replace(array_keys($map), array_values($map), $stream); // Rules $stream = self::extractAndProcessRules($stream); // Alias at-rules (if there are any) $stream = self::aliasAtRules($stream); // print it all back $stream = self::display($stream); // Add in boilerplate if ($options['boilerplate']) { $stream = self::getBoilerplate() . "\n{$stream}"; } self::log(self::$config->data); // Release memory self::$storage = null; return $stream; }