public function parse($s, $f, $l)
{
// initialize tokenizer
$this->t->init($s, $f, $l);
$x = new JSCompilerContext(false);
$n = $this->Script($x);
if (!$this->t->isDone()) {
throw $this->t->newSyntaxError('Syntax error');
}
return $n;
}
public function execute() { if ($this->hasArg()) { $files = $this->mArgs; } else { $this->maybeHelp(true); // @todo fixme this is a lame API :) exit(1); // it should exit from the above first... } $parser = new JSParser(); foreach ($files as $filename) { wfSuppressWarnings(); $js = file_get_contents($filename); wfRestoreWarnings(); if ($js === false) { $this->output("{$filename} ERROR: could not read file\n"); $this->errs++; continue; } try { $parser->parse($js, $filename, 1); } catch (Exception $e) { $this->errs++; $this->output("{$filename} ERROR: " . $e->getMessage() . "\n"); continue; } $this->output("{$filename} OK\n"); } if ($this->errs > 0) { exit(1); } }