當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Context::isComment方法代碼示例

本文整理匯總了PHP中SqlParser\Context::isComment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::isComment方法的具體用法?PHP Context::isComment怎麽用?PHP Context::isComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SqlParser\Context的用法示例。


在下文中一共展示了Context::isComment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testIsComment

 public function testIsComment()
 {
     $this->assertEquals(Token::FLAG_COMMENT_BASH, Context::isComment('#'));
     $this->assertEquals(Token::FLAG_COMMENT_C, Context::isComment('/*'));
     $this->assertEquals(Token::FLAG_COMMENT_C, Context::isComment('*/'));
     $this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment('-- '));
     $this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment("--\t"));
     $this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment("--\n"));
     $this->assertEquals(Token::FLAG_COMMENT_BASH, Context::isComment('# a comment'));
     $this->assertEquals(Token::FLAG_COMMENT_C, Context::isComment('/*comment */'));
     $this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment('-- my comment'));
     $this->assertEquals(null, Context::isComment('--not a comment'));
 }
開發者ID:elrossco22,項目名稱:sql-parser,代碼行數:13,代碼來源:IsMethodsTest.php

示例2: parseComment

 /**
  * Parses a comment.
  *
  * @return Token
  */
 public function parseComment()
 {
     $iBak = $this->last;
     $token = $this->str[$this->last];
     // Bash style comments. (#comment\n)
     if (Context::isComment($token)) {
         while (++$this->last < $this->len && $this->str[$this->last] !== "\n") {
             $token .= $this->str[$this->last];
         }
         $token .= $this->str[$this->last];
         return new Token($token, Token::TYPE_COMMENT, Token::FLAG_COMMENT_BASH);
     }
     // C style comments. (/*comment*\/)
     if (++$this->last < $this->len) {
         $token .= $this->str[$this->last];
         if (Context::isComment($token)) {
             $flags = Token::FLAG_COMMENT_C;
             if ($this->last + 1 < $this->len && $this->str[$this->last + 1] === '!') {
                 // It is a MySQL-specific command.
                 $flags |= Token::FLAG_COMMENT_MYSQL_CMD;
             }
             while (++$this->last < $this->len && ($this->str[$this->last - 1] !== '*' || $this->str[$this->last] !== '/')) {
                 $token .= $this->str[$this->last];
             }
             $token .= $this->str[$this->last];
             return new Token($token, Token::TYPE_COMMENT, $flags);
         }
     }
     // SQL style comments. (-- comment\n)
     if (++$this->last < $this->len) {
         $token .= $this->str[$this->last];
         if (Context::isComment($token)) {
             if ($this->str[$this->last] !== "\n") {
                 // Checking if this comment did not end already (```--\n```).
                 while (++$this->last < $this->len && $this->str[$this->last] !== "\n") {
                     $token .= $this->str[$this->last];
                 }
                 if ($this->last < $this->len) {
                     $token .= $this->str[$this->last];
                 }
             }
             return new Token($token, Token::TYPE_COMMENT, Token::FLAG_COMMENT_SQL);
         }
     }
     $this->last = $iBak;
     return null;
 }
開發者ID:Timandes,項目名稱:phpmyadmin,代碼行數:52,代碼來源:Lexer.php

示例3: parseComment

 /**
  * Parses a comment.
  *
  * @return Token
  */
 public function parseComment()
 {
     $iBak = $this->last;
     $token = $this->str[$this->last];
     // Bash style comments. (#comment\n)
     if (Context::isComment($token)) {
         while (++$this->last < $this->len && $this->str[$this->last] !== "\n") {
             $token .= $this->str[$this->last];
         }
         $token .= "\n";
         // Adding the line ending.
         return new Token($token, Token::TYPE_COMMENT, Token::FLAG_COMMENT_BASH);
     }
     // C style comments. (/*comment*\/)
     if (++$this->last < $this->len) {
         $token .= $this->str[$this->last];
         if (Context::isComment($token)) {
             $flags = Token::FLAG_COMMENT_C;
             // This comment already ended. It may be a part of a
             // previous MySQL specific command.
             if ($token === '*/') {
                 return new Token($token, Token::TYPE_COMMENT, $flags);
             }
             // Checking if this is a MySQL-specific command.
             if ($this->last + 1 < $this->len && $this->str[$this->last + 1] === '!') {
                 $flags |= Token::FLAG_COMMENT_MYSQL_CMD;
                 $token .= $this->str[++$this->last];
                 while (++$this->last < $this->len && '0' <= $this->str[$this->last] && $this->str[$this->last] <= '9') {
                     $token .= $this->str[$this->last];
                 }
                 --$this->last;
                 // We split this comment and parse only its beginning
                 // here.
                 return new Token($token, Token::TYPE_COMMENT, $flags);
             }
             // Parsing the comment.
             while (++$this->last < $this->len && ($this->str[$this->last - 1] !== '*' || $this->str[$this->last] !== '/')) {
                 $token .= $this->str[$this->last];
             }
             // Adding the ending.
             if ($this->last < $this->len) {
                 $token .= $this->str[$this->last];
             }
             return new Token($token, Token::TYPE_COMMENT, $flags);
         }
     }
     // SQL style comments. (-- comment\n)
     if (++$this->last < $this->len) {
         $token .= $this->str[$this->last];
         if (Context::isComment($token)) {
             // Checking if this comment did not end already (```--\n```).
             if ($this->str[$this->last] !== "\n") {
                 while (++$this->last < $this->len && $this->str[$this->last] !== "\n") {
                     $token .= $this->str[$this->last];
                 }
                 $token .= "\n";
                 // Adding the line ending.
             }
             return new Token($token, Token::TYPE_COMMENT, Token::FLAG_COMMENT_SQL);
         }
     }
     $this->last = $iBak;
     return null;
 }
開發者ID:altesien,項目名稱:FinalProject,代碼行數:69,代碼來源:Lexer.php


注:本文中的SqlParser\Context::isComment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。