예제 #1
0
 public function testTokens()
 {
     $input = new ParseInput(array(array('int', 5), array('op', '+'), array('int', 2)));
     $this->assertTrue($input->acceptToken('int', $token));
     $this->assertEquals(5, $token[1]);
     $this->assertFalse($input->acceptToken('int'));
     $this->assertThrows('Jivoo\\Core\\Parse\\ParseException', function () use($input) {
         $input->expectToken('int');
     });
     $token = $input->expectToken('op');
     $this->assertEquals('op', $token[0]);
     $this->assertEquals('+', $token[1]);
 }
예제 #2
0
 public static function parseColumn(ParseInput $input)
 {
     if ($input->acceptToken('model', $mToken)) {
         $input->expectToken('dot');
         if (!$input->acceptToken('field', $fToken)) {
             $fToken = $input->expectToken('name');
         }
         return new FieldAccess($fToken[1], $mToken[1]);
     }
     if (!$input->acceptToken('field', $first)) {
         $first = $input->expectToken('name');
     }
     if ($input->acceptToken('dot')) {
         if (!$input->acceptToken('field', $fToken)) {
             $fToken = $input->expectToken('name');
         }
         return new FieldAccess($fToken[1], $first[1]);
     }
     return new FieldAccess($first[1]);
 }