示例#1
0
 public function setTheOther(self $aToken = null)
 {
     // 先解除原有配对的token关系
     if ($this->aTheOther) {
         // nothing to do
         if ($this->aTheOther === $aToken) {
             return;
         }
         $this->aTheOther->setTheOther(null);
         $this->aTheOther = null;
     }
     // 设置一个配对的 闭合token
     if ($aToken) {
         $thisTokenType = $this->tokenType();
         if ($this->isOpen()) {
             if (!self::isPair($thisTokenType, $aToken->tokenType())) {
                 throw new ClassCompileException(null, $aToken, "遇到意外的闭合token类型,“%s”和“%s”类型不匹配。", array($thisTokenType, $aToken->tokenTypeName()));
             }
         } else {
             if (!self::isPair($aToken->tokenType(), $thisTokenType)) {
                 throw new ClassCompileException(null, $aToken, "遇到意外的闭合token类型,“%s”和“%s”类型不匹配。", array($thisTokenType, $aToken->tokenTypeName()));
             }
         }
         $this->aTheOther = $aToken;
         $aToken->aTheOther = $this;
     }
 }
示例#2
0
 public function setArgListToken(ClosureToken $aTokenArgList)
 {
     if ($aTokenArgList->tokenType() != Token::T_BRACE_ROUND_OPEN or $aTokenArgList->sourceCode() != '(') {
         throw new ClassCompileException(null, $aTokenArgList, "参数 \$aTokenArgList 必须是一个内容为 “(” 的Token对象");
     }
     $this->aTokenArgList = $aTokenArgList;
 }
示例#3
0
 /**
  * 设置class body 开始的大括号token
  */
 public function setBodyToken(ClosureToken $aTokenBody)
 {
     if ($aTokenBody->tokenType() != Token::T_BRACE_OPEN or $aTokenBody->sourceCode() != '{') {
         throw new ClassCompileException(null, $aTokenBody, "参数 \$aTokenBody 必须是一个内容为 “{” 的Token对象");
     }
     $this->aTokenBody = $aTokenBody;
 }