Lines Matching refs:this

14  * lexer grammars result in a subclass of this object. A Lexer object
41 * create a single token. `nextToken` will return this object after
44 * If you subclass to allow multiple token emissions, then set this
105 * input char buffer. Use {@see Lexer::setText()} or can set this instance var.
118 $this->input = $input;
119 $this->factory = CommonTokenFactory::default();
120 $this->tokenFactorySourcePair = new Pair($this, $input);
122 // @todo remove this property
123 $this->interp = null;// child classes must populate this
129 if ($this->input !== null) {
130 $this->input->seek(0);// rewind the input
133 $this->token = null;
134 $this->type = Token::INVALID_TYPE;
135 $this->channel = Token::DEFAULT_CHANNEL;
136 $this->tokenStartCharIndex = -1;
137 $this->tokenStartCharPositionInLine = -1;
138 $this->tokenStartLine = -1;
139 $this->text = null;
141 $this->hitEOF = false;
142 $this->mode = self::DEFAULT_MODE;
143 $this->modeStack = [];
145 if ($this->interp !== null) {
146 $this->interp->reset();
151 * Return a token from this source; i.e., match a token on the char stream.
155 if ($this->input === null) {
161 $tokenStartMarker = $this->input->mark();
165 if ($this->hitEOF) {
166 $this->emitEOF();
168 return $this->token;
171 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
175 $this->token = null;
176 $this->channel = Token::DEFAULT_CHANNEL;
177 $this->tokenStartCharIndex = $this->input->getIndex();
178 $this->tokenStartCharPositionInLine = $this->interp->getCharPositionInLine();
179 $this->tokenStartLine = $this->interp->getLine();
180 $this->text = null;
184 $this->type = Token::INVALID_TYPE;
187 $ttype = $this->interp->match($this->input, $this->mode);
189 $this->notifyListeners($e); // report error
190 $this->recover($e);
193 if ($this->input->LA(1) === Token::EOF) {
194 $this->hitEOF = true;
197 if ($this->type === Token::INVALID_TYPE) {
198 $this->type = $ttype;
201 if ($this->type === self::SKIP) {
207 if ($this->type !== self::MORE) {
216 if ($this->token === null) {
217 $this->emit();
220 return $this->token;
225 $this->input->release($tokenStartMarker);
238 $this->type = self::SKIP;
243 $this->type = self::MORE;
248 $this->mode = $m;
253 $this->modeStack[] = $this->mode;
255 $this->mode($m);
260 if (\count($this->modeStack) === 0) {
264 $this->mode(\array_pop($this->modeStack));
266 return $this->mode;
271 return $this->input === null ? '' : $this->input->getSourceName();
276 return $this->input;
281 return $this->factory;
286 $this->factory = $factory;
291 $this->input = null;
292 $this->tokenFactorySourcePair = new Pair($this, $this->input);
294 $this->reset();
300 $this->input = $input;
301 $this->tokenFactorySourcePair = new Pair($this, $this->input);
306 * for efficiency reasons. Subclass and override this method, nextToken,
308 * rather than a single variable as this implementation does).
312 $this->token = $token;
319 * use that to set the token's text. Override this method to emit
324 $token = $this->factory->createEx(
325 $this->tokenFactorySourcePair,
326 $this->type,
327 $this->text,
328 $this->channel,
329 $this->tokenStartCharIndex,
330 $this->getCharIndex() - 1,
331 $this->tokenStartLine,
332 $this->tokenStartCharPositionInLine
335 $this->emitToken($token);
342 if ($this->input === null) {
346 $cpos = $this->getCharPositionInLine();
347 $lpos = $this->getLine();
348 $eof = $this->factory->createEx(
349 $this->tokenFactorySourcePair,
353 $this->input->getIndex(),
354 $this->input->getIndex() - 1,
359 $this->emitToken($eof);
366 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
370 return $this->interp->getLine();
375 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
379 $this->interp->setLine($line);
384 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
388 return $this->interp->getCharPositionInLine();
393 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
397 $this->interp->setCharPositionInLine($charPositionInLine);
405 if ($this->input === null) {
409 return $this->input->getIndex();
417 if ($this->text !== null) {
418 return $this->text;
421 if ($this->interp === null || !$this->interp instanceof LexerATNSimulator) {
425 return $this->input === null ? '' : $this->interp->getText($this->input);
429 * Set the complete text of this token; it wipes any previous changes to the text.
433 $this->text = $text;
438 return $this->token;
446 $this->token = $token;
451 return $this->type;
456 $this->type = $type;
461 return $this->channel;
466 $this->channel = $channel;
494 $token = $this->nextToken();
498 $token = $this->nextToken();
512 if ($this->input !== null && $this->input->LA(1) !== Token::EOF) {
513 if ($re instanceof LexerNoViableAltException && $this->interp !== null) {
515 $this->interp->consume($this->input);
518 $this->input->consume();
525 $start = $this->tokenStartCharIndex;
527 if ($this->input === null) {
530 $stop = $this->input->getIndex();
531 $text = $this->input->getText($start, $stop);
534 $listener = $this->getErrorListenerDispatch();
537 $this,
539 $this->tokenStartLine,
540 $this->tokenStartCharPositionInLine,