_tokenName = $tokenName; $this->_unification = $unification; $this->setKept($kept); return; } /** * Get token name. * * @return string */ public function getTokenName() { return $this->_tokenName; } /** * Set token namespace. * * @param string $namespace Namespace. * @return string */ public function setNamespace($namespace) { $old = $this->_namespace; $this->_namespace = $namespace; return $old; } /** * Get token namespace. * * @return string */ public function getNamespace() { return $this->_namespace; } /** * Set representation. * * @param string $regex Representation. * @return string */ public function setRepresentation($regex) { $old = $this->_regex; $this->_regex = $regex; return $old; } /** * Get token representation. * * @return string */ public function getRepresentation() { return $this->_regex; } /** * Get AST of the token representation. * * @return \Hoa\Compiler\Llk\TreeNode */ public function getAST() { if (null === static::$_regexCompiler) { $stream = new File\Read('hoa://Library/Regex/Grammar.pp'); $stream->rewind(); static::$_regexCompiler = Compiler\Llk::load($stream); } if (null === $this->_ast) { $this->_ast = static::$_regexCompiler->parse( $this->getRepresentation() ); } return $this->_ast; } /** * Set token value. * * @param string $value Value. * @return string */ public function setValue($value) { $old = $this->_value; $this->_value = $value; return $old; } /** * Get token value. * * @return string */ public function getValue() { return $this->_value; } /** * Set whether the token is kept or not in the AST. * * @param bool $kept Kept. * @return bool */ public function setKept($kept) { $old = $this->_kept; $this->_kept = $kept; return $old; } /** * Check whether the token is kept in the AST or not. * * @return bool */ public function isKept() { return $this->_kept; } /** * Get unification index. * * @return int */ public function getUnificationIndex() { return $this->_unification; } }