public function parse($string) { parent::parse($string); if (!empty($this->stack)) { $this->textToTag(''); } return $this->res; }
private function process() { if (!$this->ptokens) { return; } // empty file $this->setupContext(); do { $cur_token = $this->ptokens[$this->current_pos]; $i_code = $cur_token[PHPCF_KEY_CODE]; $i_text = $cur_token[PHPCF_KEY_TEXT]; if ($this->debug_enabled) { $debug_code = sprintf("%30s", $i_code); $whitespaces = str_repeat(' ', max(0, 30 - strlen($i_text))); $msg = $debug_code . " " . $this->humanWhiteSpace($i_text, true) . $whitespaces; $msg .= " " . $this->FSM->getStackPath(); fwrite(STDERR, $msg . PHP_EOL); } $rule_context = $this->getContext(); if (empty($this->controls[$i_code])) { $this->exec[] = $i_text; $this->exec_ctx[] = $rule_context; continue; } $i_controls = $this->controls[$i_code]; $i_context_controls = false; if (!empty($i_controls[$this->context])) { $i_context_controls = $i_controls[$this->context]; } elseif (!empty($i_controls[PHPCF_KEY_ALL])) { $i_context_controls = $i_controls[PHPCF_KEY_ALL]; } if (!empty($i_context_controls)) { $this->processControls($i_context_controls, $rule_context); } else { $this->exec[] = $i_text; $this->exec_ctx[] = $rule_context; } } while ($this->nextParsedToken()); $this->FSM->finalize(); $final_state = $this->FSM->getStackPath(); $valid_states = ['CTX_PHP' => true, 'CTX_DEFAULT' => true]; if (!isset($valid_states[$final_state])) { throw new \RuntimeException("Internal formatter error: final state must be CTX_PHP or CTX_DEFAULT, got '{$final_state}'"); } }
public function parse($s) { parent::parse($s); $this->bubble(); return $this->res; }