method parse documentation in bbn\Util\Pparser

function($string) { if (!$string){ // no string, no data return []; } if ($string[0] == '('){ // killer outer parens, as they're unnecessary $string = substr($string, 1, -1); } $this->current = []; $this->stack = []; $this->string = $string; $this->length = \strlen($this->string); // look at each character for ($this->position=0; $this->position < $this->length; $this->position++){ switch ($this->string[$this->position]){ case '(': $this->push(); // push current scope to the stack an begin a new scope array_push($this->stack, $this->current); $this->current = []; break; case ')': $this->push(); // save current scope $t = $this->current; // get the last scope from stack $this->current = array_pop($this->stack); // add just saved scope to current scope $this->current[] = $t; break; /* case ' ': // make each word its own token $this->push(); break; */ default: // remember the offset to do a string capture later // could've also done $buffer .= $string[$position] // but that would just be wasting resources… if ($this->buffer_start === null){ $this->buffer_start = $this->position; } } } return $this->current; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.