Exemple #1
0
 public static function forType($type)
 {
     return CommonToken::forInput($input = null, $type);
 }
 /** The standard method called to automatically emit a token at the
  *  outermost lexical rule.  The token object should point into the
  *  char buffer start..stop.  If there is a text override in 'text',
  *  use that to set the token's text.  Override this method to emit
  *  custom Token objects.
  *
  *  If you are building trees, then you should also override
  *  Parser or TreeParser.getMissingSymbol().
  */
 public function emit($token = null)
 {
     if ($token == null) {
         $token = CommonToken::forInput($this->input, $this->state->type, $this->state->channel, $this->state->tokenStartCharIndex, $this->getCharIndex() - 1);
         $token->setLine($this->state->tokenStartLine);
         $token->setText($this->state->text);
         $token->setCharPositionInLine($this->state->tokenStartCharPositionInLine);
     }
     $this->state->token = $token;
     return $token;
 }