Пример #1
0
 /**
  * return SourceFileManager
  */
 public function newInterpreterManager()
 {
     $aInterpreters = parent::newInterpreterManager();
     // for mvc
     ParserStateTag::singleton()->addTagNames('views', 'view', 'widget', 'form', 'msgqueue', 'view:msgqueue', 'widget:msgqueue', 'resrc', 'link', 'css', 'script', 'js', 'model:foreach', 'model:foreach:end', 'model:data', 'data', 'template', 'model:foreach:else', 'bean', 'menu', 'item');
     return $aInterpreters;
 }
Пример #2
0
 /**
  * @return ParserState
  */
 public static function queryState(IObject $aObject)
 {
     if ($aObject instanceof Tag) {
         return ParserStateTag::singleton();
     } else {
         if ($aObject instanceof AttributeValue) {
             return ParserStateAttribute::singleton();
         } else {
             if ($aObject instanceof Node) {
                 return ParserStateNode::singleton();
             } else {
                 if ($aObject instanceof Macro) {
                     return ParserStateMacro::singleton();
                 } else {
                     if ($aObject instanceof Text) {
                         return ParserStateText::singleton();
                     } else {
                         if ($aObject instanceof ObjectBase) {
                             return ParserStateDefault::singleton();
                         } else {
                             throw new Exception("!?");
                         }
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 public function active(IObject $aParent, string $aSource, $nPosition)
 {
     Assert::type("org\\jecat\\framework\\ui\\xhtml\\Tag", $aParent, 'aParent');
     $sByte = $aSource->byte($nPosition);
     if (in_array($sByte, array('"', "'"))) {
         $nStartPos = $nPosition + 1;
         $sBorder = $sByte;
     } else {
         $nStartPos = $nPosition;
         $sBorder = null;
     }
     $aAttriVal = new AttributeValue(null, $sBorder, $nStartPos, ObjectBase::getLine($aSource, $nStartPos));
     $aParent->attributes()->add($aAttriVal);
     $aAttriVal->setParent($aParent);
     if ($sByte == '=') {
         $aAttriVal->setEndPosition($nPosition);
         $aAttriVal->setSource($sByte);
         return $aParent;
     } else {
         // 只有一个字节的属性值
         $nNextPos = $nPosition + 1;
         if (ParserStateTag::singleton()->examineEnd($aSource, $nNextPos, $aAttriVal)) {
             return $this->complete($aAttriVal, $aSource, $nPosition);
         }
         return $aAttriVal;
     }
 }
Пример #4
0
 public function __construct()
 {
     parent::__construct();
     self::setSingleton($this);
     $this->arrChangeToStates[__NAMESPACE__ . '\\ParserStateTag'] = ParserStateTag::singleton();
     $this->arrChangeToStates[__NAMESPACE__ . '\\ParserStateMacro'] = ParserStateMacro::singleton();
 }
Пример #5
0
 /**
  * return SourceFileManager
  */
 public function newInterpreterManager()
 {
     $aInterpreters = parent::newInterpreterManager();
     // 注册  parser
     $aInterpreters->add(parsers\Parser::singleton());
     $aInterpreters->add(weave\WeaveParser::singleton());
     ParserStateMacro::singleton()->addMacroType('?')->addMacroType('=')->addMacroType('/')->addMacroType('*')->addMacroType('@');
     // for ui
     ParserStateTag::singleton()->addTagNames('if', 'else', 'if:else', 'elseif', 'loop', 'foreach', 'foreach:else', 'while:else', 'dowhile:else', 'do:else', 'loop:else', 'while', 'dowhile', 'do', 'struct:end', 'if:end', 'loop:end', 'while:end', 'dowhile:end', 'foreach:end', 'include', 'function', 'continue', 'break', 'script', 'subtemplate', 'subtemplate:define', 'subtemplate:call', 'nl', 'clear', 'code', 'render:js');
     return $aInterpreters;
 }