Esempio n. 1
0
        string PrintFunction(IFunctionToken funcToken)
        {
            if (funcToken == null)
            {
                return(null);
            }

            string parms = null;

            if (_fixType == FixType.Infix)
            {
                parms = string.Join(
                    ", ",
                    funcToken.Parameters.Select(p =>
                                                p.Category == TokenCategory.OperatorToken
                            ? $"( {p.Accept(this)})"
                            : p.Accept(this)));
            }
            else
            {
                parms = string.Join("", funcToken.Parameters.Select(p => p.Accept(this)));
            }

            switch (_fixType)
            {
            case FixType.Prefix: return($"{funcToken.Name}[{funcToken.Parameters.Count}] {parms}");

            case FixType.Infix: return($"{funcToken.Name}( {parms} ) ");

            case FixType.Postfix: return($"{parms}{funcToken.Name}[{funcToken.Parameters.Count}] ");

            default:
                throw new UnrecognisedTokenException($"Unrecognised fix type {_fixType}");
            }
        }
Esempio n. 2
0
        string PrintFunction(IFunctionToken funcToken)
        {
            if (funcToken == null)
            {
                return(null);
            }

            string parms = null;

            parms = string.Join(
                ",",
                funcToken.Parameters.Select(p =>
                                            p.Category == TokenCategory.OperatorToken
                        ? $"\\left({p.Accept(this)}\\right)"
                        : p.Accept(this)));

            return($"{funcToken.Name}\\left({parms}\\right)");
        }