237 $noBlockGrouping =
true;
241 $childs = $n->treeNodes;
243 for ($c = 0, $i = 0, $j = count($childs); $i <
$j; $i++)
277 if ($c > 1 && !$noBlockGrouping)
284 $s .=
'function' . ($n->name ?
' ' . $n->name :
'') .
'(';
286 for ($i = 0, $j = count(
$params); $i <
$j; $i++)
288 $s .=
'){' . $this->
parseTree($n->body,
true) .
'}';
292 $s =
'if(' . $this->
parseTree($n->condition) .
')';
293 $thenPart = $this->
parseTree($n->thenPart);
294 $elsePart = $n->elsePart ? $this->
parseTree($n->elsePart) :
null;
303 if ($thenPart !=
';' && $thenPart[0] !=
'{')
304 $thenPart =
'{' . $thenPart .
'}';
306 $s .= $thenPart .
'else';
309 if ($elsePart[0] !=
'{')
321 $s =
'switch(' . $this->
parseTree($n->discriminant) .
'){';
323 for ($i = 0, $j = count($cases); $i <
$j; $i++)
331 $statement = $this->
parseTree($case->statements,
true);
344 $s =
'for(' . ($n->setup ? $this->
parseTree($n->setup) :
'')
345 .
';' . ($n->condition ? $this->parseTree($n->condition) :
'')
346 .
';' . ($n->update ? $this->parseTree($n->update) :
'') .
')';
356 $s =
'while(' . $this->
parseTree($n->condition) .
')';
376 $s =
'do{' . $this->
parseTree($n->body,
true) .
'}while(' . $this->
parseTree($n->condition) .
')';
381 $s = $n->value . ($n->label ?
' ' . $n->label :
'');
385 $s =
'try{' . $this->
parseTree($n->tryBlock,
true) .
'}';
386 $catchClauses = $n->catchClauses;
387 for ($i = 0, $j = count($catchClauses); $i <
$j; $i++)
389 $t = $catchClauses[
$i];
390 $s .=
'catch(' .
$t->varName . (
$t->guard ?
' if ' . $this->
parseTree(
$t->guard) :
'') .
'){' . $this->
parseTree(
$t->block,
true) .
'}';
392 if ($n->finallyBlock)
393 $s .=
'finally{' . $this->
parseTree($n->finallyBlock,
true) .
'}';
418 $s = $n->value .
' ';
419 $childs = $n->treeNodes;
420 for ($i = 0, $j = count($childs); $i <
$j; $i++)
423 $s .= ($i ?
',' :
'') .
$t->name;
424 $u =
$t->initializer;
432 $left = $this->
parseTree($n->treeNodes[0]);
433 $right = $this->
parseTree($n->treeNodes[1]);
442 if ($this->
isWordChar($right[0]) || $right[0] ==
'\\')
450 $right = $this->
parseTree($n->treeNodes[0]);
454 if ($this->
isWordChar($right[0]) || $right[0] ==
'\\')
461 $s =
'void(' . $this->
parseTree($n->treeNodes[0]) .
')';
465 throw new Exception(
'NOT IMPLEMENTED: DEBUGGER');
471 $childs = $n->treeNodes;
472 for ($i = 0, $j = count($childs); $i <
$j; $i++)
477 if ($expression = $n->expression)
482 $s = $n->label .
':' . $this->
parseTree($n->statement);
486 $childs = $n->treeNodes;
487 for ($i = 0, $j = count($childs); $i <
$j; $i++)
488 $s .= ($i ?
',' :
'') . $this->
parseTree($childs[$i]);
510 $left = $this->
parseTree($n->treeNodes[0]);
511 $right = $this->
parseTree($n->treeNodes[1]);
513 switch ($n->treeNodes[1]->type)
521 $s = $left . $n->type .
' ' .
$right;
526 if ($n->type ==
OP_PLUS && substr($left, -1) == $right[0])
542 $s = $n->value . $this->
parseTree($n->treeNodes[0]);
548 $s = $this->
parseTree($n->treeNodes[0]) . $n->value;
550 $s = $n->value . $this->
parseTree($n->treeNodes[0]);
562 $this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1))
564 $s .=
'.' .
substr($n->treeNodes[1]->value, 1, -1);
566 $s .=
'[' . $this->
parseTree($n->treeNodes[1]) .
']';
570 $childs = $n->treeNodes;
571 for ($i = 0, $j = count($childs); $i <
$j; $i++)
572 $s .= ($i ?
',' :
'') . $this->
parseTree($childs[$i]);
586 $childs = $n->treeNodes;
587 for ($i = 0, $j = count($childs); $i <
$j; $i++)
589 $s .= ($i ?
',' :
'') . $this->
parseTree($childs[$i]);
596 $childs = $n->treeNodes;
597 for ($i = 0, $j = count($childs); $i <
$j; $i++)
606 $this->isValidIdentifier(substr(
$t->treeNodes[0]->value, 1, -1))
610 $s .=
$t->treeNodes[0]->value;
617 $s .=
' ' .
$t->name .
'(';
619 for ($i = 0, $j = count(
$params); $i <
$j; $i++)
640 $n->treeNodes[0]->type,
652 $s =
'(' . $this->
parseTree($n->treeNodes[0]) .
')';
657 throw new Exception(
'UNKNOWN TOKEN TYPE: ' . $n->type);