예제 #1
0
 /**
  * Parse
  *
  * @param   text.parser.generic.AbstractLexer lexer
  * @return  var result of the last reduction, if any.
  * @throws  text.parser.generic.ParseException if an exception occurs during parsing.
  */
 public function parse(AbstractLexer $lexer)
 {
     $this->messages = array(self::ERROR => [], self::WARNING => []);
     try {
         $result = $this->yyparse($lexer);
     } catch (Throwable $e) {
         throw new ParseException($e->getMessage(), $e);
     }
     if (!empty($this->messages[self::ERROR])) {
         $p = new ParseException(sizeof($this->messages[self::ERROR]) . ' parse error(s) occurred.', null, $this->messages[self::ERROR]);
         $p->setCause(new FormatException("[\n" . $p->formattedErrors() . ']'));
         throw $p;
     }
     return $result;
 }
 /**
  * Called when parsing fails
  *
  * @param   xp.compiler.io.Source src
  * @param   text.parser.generic.ParseException reason
  */
 public function parsingFailed(Source $src, \text\parser\generic\ParseException $reason)
 {
     $this->writer->writeLine('*** @', $src, ':');
     $this->writer->writeLine($reason->compoundMessage());
 }
 /**
  * Called when parsing fails
  *
  * @param   xp.compiler.io.Source src
  * @param   text.parser.generic.ParseException reason
  */
 public function parsingFailed(Source $src, \text\parser\generic\ParseException $reason)
 {
     $this->writer->writeLine($src, ': ', $reason->compoundMessage());
     $reason->printStackTrace();
 }
 /**
  * Called when parsing fails
  *
  * @param   xp.compiler.io.Source src
  * @param   text.parser.generic.ParseException reason
  */
 public function parsingFailed(Source $src, \text\parser\generic\ParseException $reason)
 {
     $this->writer->write('P');
     $this->failed++;
     $this->messages[$src->getURI()] = $reason->getCause()->compoundMessage();
 }