Example #1
0
 public function testRepetitionMax()
 {
     $scanner1 = $this->getScanner('<tok <tok <tok');
     $scanner2 = $this->getScanner('<tok <tok <tok <tok <tok');
     $rep = new \gi\parse\RepetitionParse(0, 4);
     $rep->add($this->angleTok());
     $retval1 = $rep->scan($scanner1);
     $retval2 = $rep->scan($scanner2);
     $context1 = $scanner1->getContext();
     $context2 = $scanner2->getContext();
     self::AssertEquals($context1->resultCount(), 3);
     self::AssertTrue($retval1);
     self::AssertEquals($context2->resultCount(), 4);
     self::AssertTrue($retval2);
 }
Example #2
0
 function expression()
 {
     if (!isset($this->expression)) {
         $this->expression = new \gi\parse\SequenceParse();
         $this->expression->add($this->operand());
         $bools = new \gi\parse\RepetitionParse();
         $whichbool = new \gi\parse\AlternationParse();
         $whichbool->add($this->orExpr());
         $whichbool->add($this->andExpr());
         $bools->add($whichbool);
         $this->expression->add($bools);
     }
     return $this->expression;
 }