public function testEatChars() { $buffer = new Buffer("abcdef"); $buffer->nextLine(); $chars = $buffer->eatChars(2); $this->assertSame("ab", $chars); $this->assertSame("cdef", $buffer->getLine()); $this->assertSame(3, $buffer->getColumn()); $chars = $buffer->eatChars(5); $this->assertSame("cdef", $chars); $this->assertSame("", $buffer->getLine()); $this->assertSame(7, $buffer->getColumn()); }
protected function parseFilter(Buffer $buf) { if (!$buf->match('/:(.*)/A', $match)) { return null; } $node = new Filter($match['pos'][0], $match[1]); while (null !== ($next = $buf->peekLine())) { $indent = ''; if ('' !== trim($next)) { $indent = $this->indent->getString(1, $next); if ('' === $indent) { break; } if (strpos($next, $indent) !== 0) { break; } } $buf->nextLine(); $buf->eatChars(strlen($indent)); $str = $this->parseInterpolatedString($buf, false); $node->addChild(new Statement($str->getPosition(), $str)); } return $node; }