You are here

private function JSParser::Variables in Javascript Aggregator 6

1 call to JSParser::Variables()
JSParser::Statement in ./jsminplus.php

File

./jsminplus.php, line 1149

Class

JSParser

Code

private function Variables($x) {
  $n = new JSNode($this->t);
  do {
    $this->t
      ->mustMatch(TOKEN_IDENTIFIER);
    $n2 = new JSNode($this->t);
    $n2->name = $n2->value;
    if ($this->t
      ->match(OP_ASSIGN)) {
      if ($this->t
        ->currentToken()->assignOp) {
        throw $this->t
          ->newSyntaxError('Invalid variable initialization');
      }
      $n2->initializer = $this
        ->Expression($x, OP_COMMA);
    }
    $n2->readOnly = $n->type == KEYWORD_CONST;
    $n
      ->addNode($n2);
    array_push($x->varDecls, $n2);
  } while ($this->t
    ->match(OP_COMMA));
  return $n;
}