Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Compiler\Llk\Sampler\Sampler Class Reference
Inheritance diagram for Hoa\Compiler\Llk\Sampler\Sampler:

Public Member Functions

 __construct (Compiler\Llk\Parser $compiler, Visitor\Visit $tokenSampler)
 
 getCompiler ()
 

Protected Member Functions

 completeToken (Compiler\Llk\Rule\Token $token)
 
 setCurrentNamespace ($namespace)
 
 generateToken (Compiler\Llk\Rule\Token $token)
 

Protected Attributes

 $_compiler = null
 
 $_tokens = null
 
 $_rules = null
 
 $_tokenSampler = null
 
 $_rootRuleName = null
 
 $_currentNamespace = 'default'
 

Detailed Description

Class .

Sampler parent.

Definition at line 51 of file Sampler.php.

Constructor & Destructor Documentation

Hoa\Compiler\Llk\Sampler\Sampler::__construct ( Compiler\Llk\Parser  $compiler,
Visitor\Visit  $tokenSampler 
)

Construct a generator.

Parameters
\Hoa\Compiler\Llk\Parser$compilerCompiler/parser.
\Hoa\Visitor\Visit$tokenSamplerToken sampler.
Returns
void

Definition at line 104 of file Sampler.php.

107  {
108  $this->_compiler = $compiler;
109  $this->_tokens = $compiler->getTokens();
110  $this->_rules = $compiler->getRules();
111  $this->_tokenSampler = $tokenSampler;
112  $this->_rootRuleName = $compiler->getRootRule();
113 
114  return;
115  }

Member Function Documentation

Hoa\Compiler\Llk\Sampler\Sampler::completeToken ( Compiler\Llk\Rule\Token  $token)
protected

Complete a token (namespace and representation). It returns the next namespace.

Parameters
\Hoa\Compiler\Llk\Rule\Token$tokenToken.
Returns
string

Definition at line 134 of file Sampler.php.

135  {
136  if (null !== $token->getRepresentation()) {
138  }
139 
140  $name = $token->getTokenName();
141  $token->setNamespace($this->_currentNamespace);
142  $toNamespace = $this->_currentNamespace;
143 
144  if (isset($this->_tokens[$this->_currentNamespace][$name])) {
145  $token->setRepresentation(
146  $this->_tokens[$this->_currentNamespace][$name]
147  );
148  } else {
149  foreach ($this->_tokens[$this->_currentNamespace] as $_name => $regex) {
150  if (false === strpos($_name, ':')) {
151  continue;
152  }
153 
154  list($_name, $toNamespace) = explode(':', $_name, 2);
155 
156  if ($_name === $name) {
157  break;
158  }
159  }
160 
161  $token->setRepresentation($regex);
162  }
163 
164  return $toNamespace;
165  }

Here is the caller graph for this function:

Hoa\Compiler\Llk\Sampler\Sampler::generateToken ( Compiler\Llk\Rule\Token  $token)
protected

Generate a token value. Complete and set next token namespace.

Parameters
\Hoa\Compiler\Llk\Rule\Token$tokenToken.
Returns
string

Definition at line 188 of file Sampler.php.

189  {
190  $toNamespace = $this->completeToken($token);
191  $this->setCurrentNamespace($toNamespace);
192 
193  return $this->_tokenSampler->visit(
194  $token->getAST()
195  ) . ' '; // use skip token @TODO
196  }
completeToken(Compiler\Llk\Rule\Token $token)
Definition: Sampler.php:134

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Compiler\Llk\Sampler\Sampler::getCompiler ( )

Get compiler.

Returns

Definition at line 122 of file Sampler.php.

123  {
124  return $this->_compiler;
125  }
Hoa\Compiler\Llk\Sampler\Sampler::setCurrentNamespace (   $namespace)
protected

Set current token namespace.

Parameters
string$namespaceToken namespace.
Returns
string

Definition at line 173 of file Sampler.php.

174  {
176  $this->_currentNamespace = $namespace;
177 
178  return $old;
179  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Compiler\Llk\Sampler\Sampler::$_compiler = null
protected

Definition at line 58 of file Sampler.php.

Hoa\Compiler\Llk\Sampler\Sampler::$_currentNamespace = 'default'
protected

Definition at line 93 of file Sampler.php.

Hoa\Compiler\Llk\Sampler\Sampler::$_rootRuleName = null
protected

Definition at line 86 of file Sampler.php.

Hoa\Compiler\Llk\Sampler\Sampler::$_rules = null
protected

Definition at line 72 of file Sampler.php.

Hoa\Compiler\Llk\Sampler\Sampler::$_tokens = null
protected

Definition at line 65 of file Sampler.php.

Hoa\Compiler\Llk\Sampler\Sampler::$_tokenSampler = null
protected

Definition at line 79 of file Sampler.php.


The documentation for this class was generated from the following file: