Lines Matching full:token
24 public const DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
25 public const HIDDEN = Token::HIDDEN_CHANNEL;
39 * The goal of all lexer rules/methods is to create a token object.
41 * create a single token. `nextToken` will return this object after
44 * If you subclass to allow multiple token emissions, then set this
45 * to the last token to be matched or something nonnull so that
46 * the auto token emit mechanism will not emit another token.
48 * @var Token|null
50 public $token; variable in Antlr\\Antlr4\\Runtime\\Lexer
53 * What character index in the stream did the current token start at?
54 * Needed, for example, to get the text for current token. Set at
62 * The line on which the first character of the token resides.
76 * Once we see EOF on char stream, next token will be EOF.
84 * The channel number for the current token.
88 public $channel = Token::DEFAULT_CHANNEL;
91 * The token type for the current token.
95 public $type = Token::INVALID_TYPE;
104 * You can set the text for the current token to override what is in the
133 $this->token = null;
134 $this->type = Token::INVALID_TYPE;
135 $this->channel = Token::DEFAULT_CHANNEL;
151 * Return a token from this source; i.e., match a token on the char stream.
153 public function nextToken() : ?Token
160 // guaranteed at least have text of current token
168 return $this->token;
175 $this->token = null;
176 $this->channel = Token::DEFAULT_CHANNEL;
184 $this->type = Token::INVALID_TYPE;
193 if ($this->input->LA(1) === Token::EOF) {
197 if ($this->type === Token::INVALID_TYPE) {
216 if ($this->token === null) {
220 return $this->token;
230 * Instruct the lexer to skip creating a token for current lexer rule
231 * and look for another token. `nextToken` knows to keep looking when
232 * a lexer rule finishes with token set to SKIP_TOKEN. Recall that
233 * if `token === null` at end of any token rule, it creates one for you
310 public function emitToken(Token $token) : void argument
312 $this->token = $token;
316 * The standard method called to automatically emit a token at the
317 * outermost lexical rule. The token object should point into the
319 * use that to set the token's text. Override this method to emit
320 * custom Token objects or provide a new factory.
322 public function emit() : Token
324 $token = $this->factory->createEx(
335 $this->emitToken($token);
337 return $token;
340 public function emitEOF() : Token
350 Token::EOF,
352 Token::DEFAULT_CHANNEL,
413 * Return the text matched so far for the current token or any text override.
429 * Set the complete text of this token; it wipes any previous changes to the text.
436 public function getToken() : ?Token
438 return $this->token;
444 public function setToken(Token $token) : void argument
446 $this->token = $token;
486 * Return a list of all Token objects in input char stream.
487 * Forces load of all tokens. Does not include EOF token.
489 * @return array<Token>
494 $token = $this->nextToken();
496 while ($token && $token->getType() !== Token::EOF) {
497 $tokens[] = $token;
498 $token = $this->nextToken();
506 * a token, so do the easy thing and just kill a character and hope
512 if ($this->input !== null && $this->input->LA(1) !== Token::EOF) {
541 \sprintf('token recognition error at: \'%s\'', $text),