1 | <?php |
||
8 | class DefaultFormatter extends BaseFormatter { |
||
9 | |||
10 | private $preCommands; |
||
11 | private $postCommands; |
||
12 | private $showToken = true; |
||
13 | |||
14 | protected function init() { |
||
15 | $this->preCommands = new Queue(); |
||
16 | $this->postCommands = new Queue(); |
||
17 | } |
||
18 | |||
19 | public function addPreWrite($content = '') { |
||
20 | $this->preCommands->enqueue(['write', $content]); |
||
21 | } |
||
22 | |||
23 | public function addPreWriteln($content = '') { |
||
24 | $this->preCommands->enqueue(['writeln', $content]); |
||
25 | } |
||
26 | |||
27 | public function addPreIndent() { |
||
30 | |||
31 | public function addPreOutdent() { |
||
32 | $this->preCommands->enqueue(['outdent']); |
||
33 | } |
||
34 | |||
35 | public function addPostWrite($content = '') { |
||
36 | $this->postCommands->enqueue(['write', $content]); |
||
37 | } |
||
38 | |||
39 | public function addPostWriteln($content = '') { |
||
40 | $this->postCommands->enqueue(['writeln', $content]); |
||
41 | } |
||
42 | |||
43 | public function addPostIndent() { |
||
44 | $this->postCommands->enqueue(['indent']); |
||
45 | } |
||
46 | |||
47 | public function addPostOutdent() { |
||
50 | |||
51 | public function hideToken() { |
||
54 | |||
55 | protected function doVisitToken(Token $token) { |
||
56 | $group = $this->context->getGroupContext(); |
||
57 | |||
58 | // pre commands |
||
59 | $this->processCommands($this->preCommands); |
||
60 | |||
61 | // finish line on semicolon |
||
80 | |||
81 | private function processCommands(Queue $commands) { |
||
102 | |||
103 | } |
||
104 |