当前位置: 首页>>代码示例>>PHP>>正文


PHP Parser::parse方法代码示例

本文整理汇总了PHP中Parser::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::parse方法的具体用法?PHP Parser::parse怎么用?PHP Parser::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser的用法示例。


在下文中一共展示了Parser::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Renders the view
  *
  * @param array $data additional view data
  *
  * @return string
  */
 public function render(array $data = [])
 {
     if (!empty($data)) {
         $this->set($data);
     }
     return $this->parser->parse($this->file, $this->getData());
 }
开发者ID:fuelphp,项目名称:display,代码行数:14,代码来源:View.php

示例2: compile

 /**
  * Compile some CoffeeScript.
  *
  * Available options:
  *
  *  'filename' => The source file, for debugging (formatted into error messages)
  *  'header'   => Add a header to the generated source (default: TRUE)
  *  'rewrite'  => Enable rewriting token stream (debugging)
  *  'tokens'   => Reference to token stream (debugging)
  *  'trace'    => File to write parser trace to (debugging)
  *
  * @param  string  The source CoffeeScript code
  * @param  array   Options (see above)
  *
  * @return string  The resulting JavaScript (if there were no errors)
  */
 static function compile($code, $options = array())
 {
     $lexer = new Lexer($code, $options);
     if (isset($options['filename'])) {
         Parser::$FILE = $options['filename'];
     }
     if (isset($options['tokens'])) {
         $tokens =& $options['tokens'];
     }
     if (isset($options['trace'])) {
         Parser::Trace(fopen($options['trace'], 'w', TRUE), '> ');
     }
     try {
         $parser = new Parser();
         foreach ($tokens = $lexer->tokenize() as $token) {
             $parser->parse($token);
         }
         $js = $parser->parse(NULL)->compile($options);
     } catch (\Exception $e) {
         throw new Error("In {$options['filename']}, " . $e->getMessage());
     }
     if (!isset($options['header']) || $options['header']) {
         $js = '// Generated by CoffeeScript PHP ' . VERSION . "\n" . $js;
     }
     return $js;
 }
开发者ID:CapstoneFleetIntelligience,项目名称:Fleet,代码行数:42,代码来源:Compiler.php

示例3: testParse

 public function testParse()
 {
     $parser = new Parser();
     $this->assertEquals('(0-1)*(1+2)', $parser->parse(' - ( 1 + 2   ) '));
     $this->assertEquals('(0-1)*(1+2)', $parser->parse('-(1+2)'));
     $this->assertEquals('(0-3)*(1+2)', $parser->parse('-3*(1+2)'));
     $this->assertEquals('2*(0-3)*(1+2)', $parser->parse('2*(-3)*(1+2)'));
     $this->assertEquals('2*(0-3)*(1+2)*(0-1)', $parser->parse('2*(-3)*(1+2)*(-1)'));
 }
开发者ID:theki,项目名称:Calculator,代码行数:9,代码来源:ParserTest.php

示例4: itShouldAnalyseAllFiles

 /**
  * @test
  */
 public function itShouldAnalyseAllFiles()
 {
     $files = [fixture('MyClass.php')];
     $nodes = [$this->node];
     $parseRes = $this->parser->parse(Argument::type('string'));
     $this->parser->parse(Argument::type('string'))->shouldBeCalled()->willReturn($nodes);
     $this->nodeTraverser->traverse($nodes)->shouldBeCalled();
     $this->analyser->analyse($files);
 }
开发者ID:rskuipers,项目名称:php-assumptions,代码行数:12,代码来源:AnalyserTest.php

示例5: isValid

 /**
  * Tells whether a rule is valid (as in "can be parsed without error") or not.
  *
  * @return bool
  */
 public function isValid()
 {
     try {
         $this->parsedRule = $this->parser->parse($this->rule);
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
         return \false;
     }
     return \true;
 }
开发者ID:jamoli,项目名称:php-rule-parser,代码行数:15,代码来源:Rule.php

示例6: testParse

 /**
  * @covers BehEh\Sulphur\Parser::parse
  */
 public function testParse()
 {
     $response = $this->parser->parse(file_get_contents(__DIR__ . '/../data/reference.ini'));
     $references = $response->all();
     $reference = $references[0];
     $this->assertEquals(12, $reference->Icon);
     $this->assertEquals('Minor Melee', $reference->Title);
     $this->assertEquals(true, $reference->IsNetworkGame);
     $this->assertEquals(123456, $reference->GameId);
     $this->assertNull($reference->Type);
 }
开发者ID:beheh,项目名称:sulphur,代码行数:14,代码来源:ParserTest.php

示例7: testParseMultpileAgentStrings

 public function testParseMultpileAgentStrings()
 {
     $handle = fopen(dirname(__DIR__) . "/fixtures/agents.txt", "r");
     if ($handle) {
         while (($line = fgets($handle)) !== false) {
             $result = $this->parser->parse($line);
         }
         fclose($handle);
     } else {
         // error opening the file.
     }
 }
开发者ID:udger,项目名称:udger-php,代码行数:12,代码来源:ParserMultipleTest.php

示例8: parse

 /**
  * @param string $version
  * @return Version
  */
 function parse($version)
 {
     if (array_key_exists($version, $this->cache)) {
         $obj = $this->cache[$version];
         unset($this->cache[$version]);
         $this->cache[$version] = $obj;
     } else {
         if (count($this->cache) == $this->limit) {
             array_shift($this->cache);
         }
         $this->cache[$version] = $obj = $this->inner->parse($version);
     }
     return $obj;
 }
开发者ID:andrelohmann,项目名称:semver,代码行数:18,代码来源:CachingParser.php

示例9: WidgetTips

function WidgetTips($id, $params)
{
    global $wgParser;
    wfProfileIn(__METHOD__);
    $user = RequestContext::getMain()->getUser();
    $title = RequestContext::getMain()->getTitle();
    $request = RequestContext::getMain()->getRequest();
    if (isset($params['_widgetTag'])) {
        // work-around for WidgetTag
        $parser = new Parser();
    } else {
        $parser =& $wgParser;
    }
    $parser->mOptions = new ParserOptions($user);
    $tips = WidgetTipsGetTips();
    if ($tips == false) {
        wfProfileOut(__METHOD__);
        return $parser->parse('No tips found in [[Mediawiki:Tips]]! Contact your Wiki admin', $title, $parser->mOptions)->getText();
    }
    $tipsCount = count($tips);
    // check requested operation
    $op = $request->getVal('op') != '' ? $request->getVal('op') : 'rand';
    $tipId = $request->getInt('tipId');
    switch ($op) {
        case 'prev':
            $tipId--;
            if ($tipId < 0) {
                $tipId = $tipsCount - 1;
            }
            break;
        case 'next':
            $tipId++;
            if ($tipId >= $tipsCount) {
                $tipId = 0;
            }
            break;
        default:
            $tipId = array_rand($tips);
    }
    $id = intval(substr($id, 7));
    // prev/next tip selector
    if (!isset($params['_widgetTag'])) {
        $selector = '<div class="WidgetTipsSelector">' . '<a onclick="WidgetTipsChange(' . $id . ', ' . $tipId . ', \'prev\')">&laquo; ' . wfMsg('allpagesprev') . '</a> ' . '<a onclick="WidgetTipsChange(' . $id . ', ' . $tipId . ', \'next\')">' . wfMsg('allpagesnext') . ' &raquo;</a></div>';
    } else {
        // fix RT #26752
        $selector = '';
    }
    wfProfileOut(__METHOD__);
    return $selector . $parser->parse($tips[$tipId], $title, $parser->mOptions)->getText();
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:50,代码来源:WidgetTips.php

示例10: compile

/**
 * Compile some CoffeeScript.
 *
 * @param   $code     The source CoffeeScript code.
 * @param   $options  Compiler options.
 */
function compile($code, $options = array(), &$tokens = NULL)
{
    $lexer = new Lexer($code, $options);
    if (isset($options['file'])) {
        Parser::$FILE = $options['file'];
    }
    if (isset($options['trace'])) {
        Parser::Trace(fopen($options['trace'], 'w', TRUE), '> ');
    }
    $parser = new Parser();
    foreach ($tokens = $lexer->tokenize() as $token) {
        $parser->parse($token);
    }
    return $parser->parse(NULL)->compile($options);
}
开发者ID:TeigneuX,项目名称:php-websocket,代码行数:21,代码来源:coffeescript.php

示例11: getMessagesFormatted

 function getMessagesFormatted($severity = self::MESSAGE_WARNING, $header = null)
 {
     global $wgTitle, $wgUser;
     $ret = '';
     foreach ($this->mMessages as $message) {
         if ($message[1] <= $severity) {
             $ret .= '* ' . $message[0] . "\n";
         }
     }
     if ($ret != '') {
         if (!$this->mParser) {
             $parser = new Parser();
         }
         if ($header == null) {
             $header = '';
         } elseif ($header != '') {
             $header = Html::rawElement('div', array('class' => 'heading'), $header);
         }
         $ret = Html::rawElement('div', array('class' => 'messages'), $header . "\n" . $ret);
         $ret = $parser->parse($ret, $wgTitle, ParserOptions::newFromUser($wgUser));
     } else {
         $ret = null;
     }
     return $ret;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:LingoMessageLog.php

示例12: query

 public function query($q)
 {
     $parser = new Parser($this->user, $q);
     $error = $parser->parse();
     if ($error) {
         return $parser->getError();
     }
     $mysql_query = $parser->getSql();
     $meta = $parser->getObjectMetaData();
     $this->pearDB->startTransaction();
     $result = $this->pearDB->pquery($mysql_query, array());
     $error = $this->pearDB->hasFailedTransaction();
     $this->pearDB->completeTransaction();
     if ($error) {
         throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while performing required operation");
     }
     $noofrows = $this->pearDB->num_rows($result);
     $output = array();
     for ($i = 0; $i < $noofrows; $i++) {
         $row = $this->pearDB->fetchByAssoc($result, $i);
         if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $row["crmid"])) {
             continue;
         }
         $output[] = DataTransform::sanitizeDataWithColumn($row, $meta);
     }
     return $output;
 }
开发者ID:vtiger-jp,项目名称:vtigercrm-5.1.x-ja,代码行数:27,代码来源:VtigerModuleOperation.php

示例13: testCreate

 /**
  * @covers Geissler\Converter\Standard\CSL\Creator::create
  * @covers Geissler\Converter\Standard\CSL\Creator::getType
  * @covers Geissler\Converter\Standard\CSL\Creator::createPerson
  * @covers Geissler\Converter\Standard\CSL\Creator::createDate
  * @covers Geissler\Converter\Standard\CSL\Creator::retrieve
  * @dataProvider dataProviderForCreate
  */
 public function testCreate($input, $titles, $types, $authors = false, $issued = false, $issuedFull = false)
 {
     $parser = new Parser();
     $this->assertTrue($parser->parse($input));
     $this->assertTrue($this->object->create($parser->retrieve()));
     $csl = json_decode($this->object->retrieve(), true);
     $count = 0;
     foreach ($csl as $entry) {
         $this->assertEquals($titles[$count], $entry['title']);
         $this->assertEquals($types[$count], $entry['type']);
         if ($authors !== false) {
             $countAuthors = count($authors[$count]);
             for ($i = 0; $i < $countAuthors; $i++) {
                 $this->assertEquals($authors[$count][$i]['family'], $entry['author'][$i]['family']);
                 $this->assertEquals($authors[$count][$i]['given'], $entry['author'][$i]['given']);
             }
         }
         if ($issued !== false && isset($issued[$count]) == true) {
             $this->assertEquals($issued[$count]['year'], $entry['issued'][0]['year']);
             $this->assertArrayNotHasKey('day', $entry['issued'][0]);
             $this->assertArrayNotHasKey('month', $entry['issued'][0]);
         }
         if ($issuedFull !== false && isset($issuedFull[$count]) == true) {
             $this->assertEquals($issuedFull[$count]['year'], $entry['issued'][0]['year']);
             $this->assertEquals($issuedFull[$count]['day'], $entry['issued'][0]['day']);
             $this->assertEquals($issuedFull[$count]['month'], $entry['issued'][0]['month']);
         }
         $count++;
     }
 }
开发者ID:avvertix,项目名称:converter,代码行数:38,代码来源:CreatorTest.php

示例14: run

 private function run($name, $options, $contents)
 {
     require_once CORE_DIR . 'parser.php';
     $parser = new Parser();
     $data = html_entity_decode($parser->parse($contents, $options));
     return file_put_contents(strtolower($name) . '.php', $data) ? true : false;
 }
开发者ID:robertabramski,项目名称:pep,代码行数:7,代码来源:generate.php

示例15: getInfo

 /**
  * Get the package information
  *
  * @return Info
  */
 public function getInfo()
 {
     exec("rpm -qi {$this->packageName}", $rawInfo);
     $rawInfo = implode("\n", $rawInfo);
     $parser = new Parser();
     return $parser->parse($rawInfo);
 }
开发者ID:wildlyinaccurate,项目名称:rpminfo,代码行数:12,代码来源:Query.php


注:本文中的Parser::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。