Example #1
0
 /**
  *
  */
 public function getParams()
 {
     $short_opts = 'hdcsl';
     $long_opts = array('help', 'debug', 'compress', 'strict', 'lexdebug');
     $console = new Console_Getopt();
     $args = $console->readPHPArgv();
     $opts = $console->getopt($args, $short_opts, $long_opts);
     if (PEAR::isError($opts)) {
         echo $opts->getMessage() . PHP_EOL;
         $this->usage(1);
     }
     foreach ($opts[0] as $opt) {
         if ($opt[0] === '--help' || $opt[0] === 'h') {
             $this->usage();
         }
         if ($opt[0] === '--debug' || $opt[0] === 'd') {
             SmartCSS::$debug = true;
         }
         if ($opt[0] === '--compress' || $opt[0] === 'c') {
             SmartCSS::$compress = true;
         }
         if ($opt[0] === '--strict' || $opt[0] === 's') {
             SmartCSS::$strict = true;
         }
         if ($opt[0] === '--lexdebug' || $opt[0] === 'l') {
             SmartCSS::$lexdebug = true;
         }
     }
     if (empty($opts[1])) {
         $this->usage();
     }
     $filename = $opts[1][0];
     if (empty($filename)) {
         $this->usage();
     }
     return $filename;
 }
<?php

require 'initialize.php';
SmartCSS::$compress = true;
function parse($content, $expected, $note = '', $debug = false)
{
    global $t;
    $parser = new SCSS_Parser();
    $lexer = new SCSS_Lexer();
    $lexer->setBuffer($content);
    if ($debug) {
        $lexer->debug = true;
        $parser->debug = true;
    }
    try {
        $parser->yyparse($lexer);
    } catch (Exception $e) {
        echo '[ERROR]' . $e->getMessage() . PHP_EOL;
        var_dump($lexer->lexbuf);
        var_dump($e->getTraceAsString());
        $t->fail('Caught unexpected Exception');
        exit(1);
    }
    $t->is($parser->run(), $expected . PHP_EOL, $note);
    $parser->reset();
}
function throws_ok($content, $message = '')
{
    global $t;
    $parser = new SCSS_Parser();
    $lexer = new SCSS_Lexer();