public function format(Parser $parser) { $source = 'when'; $source .= PHP_EOL; $parser->openScope(); for ($i = 0, $l = sizeof($this->cases); $i < $l; $i++) { $obj = $this->cases[$i]; $source .= $parser->indent(); $source .= '| '; if (null !== $obj->condition) { $source .= $obj->condition->format($parser); $source .= ' -> '; } else { $source .= 'else '; } $source .= $obj->action->format($parser); if ($i + 1 !== $l) { $source .= ';'; $source .= PHP_EOL; } } $parser->closeScope(); $source .= PHP_EOL; $source .= $parser->indent(); $source .= 'end'; return $this->parenthesize($source); }
public function format(Parser $parser) { $source = 'try'; $source .= PHP_EOL; $parser->openScope(); $source .= $this->try->format($parser); $parser->closeScope(); foreach ($this->rescues as $rescue) { $obj = (object) $rescue; $source .= $parser->indent(); $source .= 'rescue ('; $source .= implode('.', $obj->exception_class); $source .= ' '; $source .= $obj->variable; $source .= ')'; $source .= PHP_EOL; $parser->openScope(); $source .= $obj->body->format($parser); $parser->closeScope(); } if (null !== $this->finally) { $source .= $parser->indent(); $source .= 'finally '; $source .= PHP_EOL; $parser->openScope(); $source .= $this->finally->format($parser); $parser->closeScope(); } $source .= $parser->indent(); $source .= 'end'; $source .= PHP_EOL; return $source; }
public function format(Parser $parser) { $source = ''; foreach ($this->stmt_list as $stmt) { $source .= $parser->indent(); $source .= $stmt->format($parser); } return $source; }
public function format(Parser $parser) { $source = '&{'; if (sizeof($this->body->stmt_list) > 0) { $source .= PHP_EOL; $parser->openScope(); $source .= $this->body->format($parser); $parser->closeScope(); $source .= $parser->indent(); } $source .= '}'; return $this->parenthesize($source); }
public function format(Parser $parser) { $source = 'begin'; $source .= PHP_EOL; $parser->openScope(); foreach ($this->stmt_list as $stmt) { $source .= $parser->indent(); $source .= $stmt->format($parser); } $parser->closeScope(); $source .= $parser->indent(); $source .= 'end'; $source .= PHP_EOL; return $source; }
public function format(Parser $parser) { $source = $parser->indent(); $source .= 'elif '; $source .= $this->condition->format($parser); $source .= PHP_EOL; $parser->openScope(); var_dump($this->body); foreach ($this->body as $stmt) { $source .= $parser->indent(); $source .= $stmt->format($parser); } $parser->closeScope(); return $source; }
public function format(Parser $parser) { $source = 'do '; $first = true; foreach ($this->expr_list as $expr) { if (!$first) { $source .= $parser->indent(); $source .= ' , '; } else { $first = false; } $source .= $expr->format($parser); $source .= PHP_EOL; } return $source; }
public function format(Parser $parser) { $source = 'shape '; $source .= $this->name; $source .= PHP_EOL; $parser->openScope(); foreach ($this->members as $member) { $source .= $parser->indent(); $source .= $member; $source .= PHP_EOL; } $parser->closeScope(); $source .= $parser->indent(); $source .= 'end'; $source .= PHP_EOL; return $source; }
public function format(Parser $parser) { $source = 'enum '; $source .= $this->name; $source .= PHP_EOL; $parser->openScope(); foreach ($this->entries as $entry) { $source .= $parser->indent(); $source .= $entry; $source .= PHP_EOL; } $parser->closeScope(); $source .= $parser->indent(); $source .= 'end'; $source .= PHP_EOL; return $source; }
public function format(Parser $parser) { $source = 'impl '; $source .= $this->formatQualifiedName($this->class_or_shape); if (Tag::T_CLASS === $this->type) { $source .= ' for '; $source .= $this->formatQualifiedName($this->class_for); } $source .= PHP_EOL; $parser->openScope(); $source .= $this->body->format($parser); $parser->closeScope(); $source .= $parser->indent(); $source .= 'end'; $source .= PHP_EOL; return $source; }
public function format(Parser $parser) { $source = 'const '; $first = true; foreach ($this->definitions as $def) { if (!$first) { $source .= $parser->indent(); $source .= ' , '; } else { $first = false; } $source .= $def[0]; $source .= ' :- '; $source .= $def[1]->format($parser); $source .= PHP_EOL; } return $source; }
public function format(Parser $parser) { $source = '@{'; $keys =& $this->keys; $values =& $this->values; if (sizeof($this->keys) > 0) { $source .= PHP_EOL; $parser->openScope(); // Iterate based on index $source .= implode(';' . PHP_EOL, array_map(function ($index) use(&$keys, &$values, $parser) { $subsource = $parser->indent(); $subsource .= $keys[$index]; $subsource .= ' -> '; $subsource .= $values[$index]->format($parser); return $subsource; }, range(0, sizeof($keys) - 1))); $parser->closeScope(); $source .= PHP_EOL; $source .= $parser->indent(); } $source .= '}'; return $this->parenthesize($source); }
public function __construct(Tokenizer $input) { parent::__construct($input); $this->grammar = new Grammar($this); }