Exemplo n.º 1
0
 function parse(PEG_IContext $context)
 {
     if ($context->eos()) {
         return PEG::failure();
     }
     $char = $context->readElement();
     if (isset($this->table[$char])) {
         $offset = $context->tell() - 1;
         $context->seek($offset);
         return $this->table[$char]->parse($context);
     }
     return $char;
 }
Exemplo n.º 2
0
 function parse(PEG_IContext $context)
 {
     list($hit, list($end, $val)) = $context->cache($this);
     if ($hit) {
         $context->seek($end);
         return $val;
     }
     $start = $context->tell();
     $val = $this->parser->parse($context);
     $end = $context->tell();
     $context->save($this, $start, $end, $val);
     return $val;
 }
Exemplo n.º 3
0
 /**
  * @param	PEG_IContext
  */
 public function parse(PEG_IContext $context)
 {
     if ($context->eos()) {
         return PEG::failure();
     }
     $line = $context->readElement();
     $context->seek($context->tell() - 1);
     // 行ディスパッチ
     if (isset($this->lineTable[$line])) {
         return $this->lineTable[$line]->parse($context);
     }
     $char = substr($line, 0, 1);
     if (!isset($this->paragraphCheckTable[$char])) {
         return $this->paragraph->parse($context);
     }
     if (isset($this->firstCharTable[$char])) {
         return $this->firstCharTable[$char]->parse($context);
     }
     return $this->paragraph->parse($context);
 }