/** * @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("!?"); } } } } } } }
public function __construct() { parent::__construct(); self::setSingleton($this); $this->arrChangeToStates[__NAMESPACE__ . '\\ParserStateMacro'] = ParserStateMacro::singleton(); $this->arrChangeToStates[__NAMESPACE__ . '\\ParserStateAttribute'] = ParserStateAttribute::singleton(); }
/** * 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; }