Ejemplo n.º 1
0
 /**
  * Parse the given input
  *
  * @param Input $input
  *
  * @return mixed result
  */
 public function parse(Input $input)
 {
     if ($input->peek(0) === $this->char) {
         $input->consume(1);
         return $input->matchHere($this->char);
     }
     return $input->errorHere("{$this->char} was not found.")->addParser($this);
 }
Ejemplo n.º 2
0
 public function testPeek()
 {
     $input = new Input('1234');
     $this->assertEquals('1', $input->peek(0));
     $this->assertEquals('2', $input->peek(1));
     $this->assertEquals('3', $input->peek(2));
     $this->assertEquals('4', $input->peek(3));
     $this->assertEquals(0, $input->getOffset());
 }