/** * Sets the input data to be tokenized. * * @param string $input The input to be tokenized. */ public function setSource(Source\String $source) { /*{{{*/ $this->source = $source; $this->encoding = $source->getEncoding(); $this->is_ascii = Encoding::isSameEncoding($this->encoding, 'ascii'); mb_regex_encoding($this->encoding); $this->lines = $source->getLines(); $this->numlines = $source->getNumLines(); $this->reset(); }
h1{ foo:; bar; baz: fuschia; } h1{ color: red; rotation: 77\$\$ } p { color:green; color{;color:maroon} color:blue; color:yellow; border:none } p{color:red} p{ foo:bar; bar:calc(2 + 5 * (3-6)); baz:boo } */ /* Discards the rule til end of stylesheet, since no matching bracket can be found */ /*p{ foo:bar; foo{;bar("baz)};"; baz:boo } h1{}*/ EOS; $timer = new Benchmark_Timer(); //$nb_iterations = 1; $timer->start(); $source = new Source\String($css); $timer->setMarker(sprintf("Source init: %s", $source->getEncoding())); $lexer = new Css\Lexer(); $lexer->setSource($source); $timer->setMarker("Lexer init"); //$token = $lexer->nextToken(); //while ($token->type !== Css\Lexer::T_EOF) { //echo $lexer->getLiteral($token) . PHP_EOL; //$token = $lexer->nextToken(); //} //echo $lexer->getLiteral($token) . PHP_EOL; //$timer->setMarker("Tokenization end"); $parser = new Css\Parser($lexer); $parser->setStrict(false); $stylesheet = $parser->parseStyleSheet(); $timer->setMarker("Parsing end");
/** * @param string $url * @param string $contents * @param string $encoding **/ public function __construct($url, $contents, $encoding = "utf-8") { $this->url = $url; parent::__construct($contents, $encoding); }