当前位置: 首页>>代码示例>>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;未经允许,请勿转载。