Lines Matching defs:position

101      * position and return the matching one.
104 * lookahead position against all of the provided tokens. If a match is
118 * The position parameter may be provided to enforce a match on an
119 * arbitrary token stream position. Therefore unlimited lookahead is
123 * @param int $position
129 $expectedTokens, int $position = 0, bool $allowEndOfTokens = FALSE
133 return $this->lookahead(array($expectedTokens), $position, $allowEndOfTokens);
138 if ($allowEndOfTokens === TRUE && (!isset($this->_tokens[$position]))) {
143 if ($this->matchToken($position, $token)) {
144 return $this->_tokens[$position];
149 throw $this->handleMismatch($expectedTokens, $position);
153 * Validate if the of the token stream is reached. The position parameter
156 * @param int $position
159 protected function endOfTokens(int $position = 0): bool {
160 return (count($this->_tokens) <= $position);
189 // increase position until the end of the token stream is reached or
191 $position = 0;
193 while (count($this->_tokens) > $position) {
195 if ($found = $this->matchToken($position, $token)) {
196 ++$position;
206 if ($position > 0) {
207 array_splice($this->_tokens, 0, $position);
234 * Returns true if the token at the given position exists and the provided
235 * token type matches type of the token at this position, false otherwise.
237 * @param int $position
241 protected function matchToken(int $position, int $type): bool {
242 if (!isset($this->_tokens[$position])) {
251 return ($this->_tokens[$position]->type === $type);
258 * @param int $position
261 private function handleMismatch($expectedTokens, $position = 0) {
263 if (!isset($this->_tokens[$position])) {
268 return new Exception\TokenMismatchException($this->_tokens[$position], $expectedTokens);