Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }