source: applications/nimpad/trunk/lib/PEG/And.php @ 1490

SVN
Revision 1490, 860 bytes checked in by anatoo, 10 months ago (diff)

0.2ブランチのリビジョン1489,1488の変更をtrunkに取り込んだ

Line 
1<?php
2/**
3 * @package PEG
4 * @author anatoo<anatoo@nequal.jp>
5 * @license http://www.opensource.org/licenses/mit-license.php MIT License
6 * @version $Id: And.php 655 2009-04-12 07:26:42Z anatoo $
7 */
8
9class PEG_And implements PEG_IParser
10{
11    protected $arr = array();
12   
13    function __construct(Array $arr)
14    {
15        foreach ($arr as $p) $this->with($p);
16    }
17   
18    protected function with(PEG_IParser $p)
19    {
20        $this->arr[] = $p;
21    }
22   
23    function parse(PEG_IContext $c)
24    {
25        $arr = $this->arr;
26        if (!$arr) return PEG::failure();
27        for ($i = 0; $i < count($arr) - 1 ; $i++) {
28            $offset = $c->tell();
29            if ($arr[$i]->parse($c) instanceof PEG_Failure) return PEG::failure();
30            $c->seek($offset);
31        }
32        return $arr[$i]->parse($c);
33    }
34}
Note: See TracBrowser for help on using the repository browser.