public static function rationalFactory(Token $token)
    {
        switch ($token->getType()) {
            case TokenType::PosInt:
            case TokenType::Integer:
                $x = intval($token->getValue());

                return new IntegerNode($x);
            case TokenType::RealNumber:
                $x = floatval(str_replace(',', '.', $token->getValue()));

                return new NumberNode($x);
            case TokenType::Identifier:
                return new VariableNode($token->getValue());
            case TokenType::Constant:
                return new ConstantNode($token->getValue());

            case TokenType::FunctionName:
                return new FunctionNode($token->getValue(), null);
            case TokenType::OpenParenthesis:
                return new SubExpressionNode($token->getValue());

            case TokenType::AdditionOperator:
            case TokenType::SubtractionOperator:
            case TokenType::MultiplicationOperator:
            case TokenType::DivisionOperator:
            case TokenType::ExponentiationOperator:
                return new ExpressionNode(null, $token->getValue(), null);

            case TokenType::FactorialOperator:
                return new PostfixOperatorNode($token->getValue(), null);

            default:
                // echo "Node factory returning null on $token\n";
                return null;
        }
    }