private function lookupTokenType(Token $token) : int { $type = explode('·', (string) $token)[0]; if (!defined($type)) { $this->fail(self::E_TOKEN_TYPE, $type, $token->line()); } return constant($type); }
private function lookupContext(Token $token, Context $context, string $error) { $symbol = (string) $token; if (null === ($result = $context->get($symbol))) { $this->fail($error, $symbol, $token->line(), json_encode($context->symbols(), self::PRETTY_PRINT)); } return $result; }
private function lookupParser(Token $token) : string { $identifier = (string) $token; $parser = '\\Yay\\' . explode('·', $identifier)[1]; if (!function_exists($parser)) { $this->fail(self::E_BAD_PARSER_NAME, $identifier, $token->line()); } return $parser; }