예제 #1
0
 public function getContent()
 {
     if (empty($this->parsedContent)) {
         $this->parsedContent = $this->parser->parse($this->content);
     }
     return $this->parsedContent;
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function getAnnotations(\Reflector $reflector)
 {
     $this->parser->setReflector($reflector);
     $annotations = $this->parser->parse();
     $annotation = new Annotation($annotations);
     return $annotation;
 }
 /**
  * @inheritdoc
  */
 public function parse($definition)
 {
     if (is_array($definition)) {
         return array_map(array($this, 'parse'), $definition);
     }
     return $this->parser->parse($definition);
 }
예제 #4
0
 /**
  * Parse a given file for defintions of classes, traits and interfaces
  *
  * @param SourceFile $source file to process
  *
  * @return ParseResult
  */
 public function parse(SourceFile $source)
 {
     if ($this->cache->hasResult($source)) {
         return $this->cache->getResult($source);
     }
     $result = $this->parser->parse($source);
     $this->cache->addResult($source, $result);
     return $result;
 }
예제 #5
0
 /**
  * @return mixed
  */
 public function start()
 {
     // Input
     echo 'Formel: ';
     $formula = trim(fgets(STDIN));
     // Processing
     $formulaObj = $this->parser->parse($formula);
     $result = $this->calculator->calculate($formulaObj);
     // Output
     echo 'Ergebnis: ';
     echo $result;
     echo "\n";
 }
 function createOperand($value, $operator = null)
 {
     $operand = array();
     switch ($operator) {
         case '+':
             $operand['operator'] = 'add';
             break;
         case '-':
             $operand['operator'] = 'subtract';
             break;
         case '*':
             $operand['operator'] = 'multiply';
             break;
         case '/':
             $operand['operator'] = 'divide';
             break;
     }
     $value = trim($value);
     if ($value != '') {
         if ($value[0] == '(' && substr($value, -1, 1) == ')') {
             $value = substr($value, 1, -1);
             $value = trim($value);
         }
     }
     if ($value == '') {
         throw new ParserException($value);
     }
     $operand['value'] = $this->operandParser->parse($value);
     return $operand;
 }
예제 #7
0
파일: Getopt.php 프로젝트: yeriomin/getopt
 /**
  * Get option value based on its definition
  *
  * @param \Yeriomin\Getopt\OptionDefinition $definition
  * @return mixed
  * @throws GetoptException
  */
 private function getOptionValue(OptionDefinition $definition)
 {
     $nameShort = $definition->getShort();
     $nameLong = $definition->getLong();
     $valueShort = $this->parser->getOptionShort($nameShort);
     $valueLong = $this->parser->getOptionLong($nameLong);
     if ($nameShort !== null && $nameLong !== null && $valueShort !== null && $valueLong !== null && $valueShort !== $valueLong) {
         throw new GetoptException('Both -' . $nameShort . ' and --' . $nameLong . ' given, with non-matching values. Make up your mind.');
     }
     return $valueShort !== null ? $valueShort : $valueLong;
 }
 function parse($expression)
 {
     $expression = trim($expression);
     if (!preg_match('/^(\\w)+\\(/', $expression)) {
         throw new ParserException($expression);
     }
     if (substr($expression, -1, 1) != ')') {
         throw new ParserException($expression);
     }
     $open = strpos($expression, '(');
     $results = array('type' => 'function', 'name' => substr($expression, 0, $open));
     $arguments = trim(substr($expression, $open + 1, -1));
     if ($arguments != '') {
         $parsedArguments = array();
         foreach ($this->explodeArguments($arguments) as $argument) {
             $parsedArguments[] = $this->argumentParser->parse($argument);
         }
         $results['arguments'] = $parsedArguments;
     }
     return $results;
 }
예제 #9
0
파일: Parser.php 프로젝트: tomkukral/obedar
 /**
  * Adds a new parser to be used
  *
  * @param ParserInterface $parser
  */
 public function add(ParserInterface $parser)
 {
     foreach ($parser->supports() as $support) {
         $this->parsers[$support] = $parser;
     }
 }
예제 #10
0
 public function setNextHook(ParserInterface $nextHook)
 {
     $this->nextHook = $nextHook;
     $nextHook->initHook($this);
     return $nextHook;
 }
예제 #11
0
 /**
  * @return \Payu\Response\ResponseAbstract
  */
 public function parse()
 {
     return $this->parser->parse($this->rawResponse);
 }
예제 #12
0
 /**
  * @param string $resource
  * @param array  $requirements
  *
  * @return string
  */
 private function getResourceCollectionUrl($resource, array $parameters, array $requirements = [])
 {
     $resource = $this->parser->parse($resource, $requirements);
     return $this->appendQueryString($this->baseUrl . '/' . $resource, $parameters);
 }
예제 #13
0
 /**
  * Builds the requested page content and returns the html in a string.
  *
  * @param string $uri
  *
  * @return string
  */
 public function buildPageContent($uri)
 {
     $content = $this->loadFileContent($uri);
     return $this->parser->render($content);
 }
예제 #14
0
 /**
  * Parse the inbound request.
  *
  * @return ParserInterface
  */
 public function parse()
 {
     return $this->parser->parse();
 }