public static IStringable Build(List <Token> tokens) { // try to build Numerable INumerable inu = NumerableBuilder.Build(tokens); if (!inu.IsNull()) { return(inu as IStringable); } // try to build Timeable ITimeable itim = TimeableBuilder.Build(tokens); if (!itim.IsNull()) { return(itim as IStringable); } // remove first and last bracket if it is there while (tokens[0].GetTokenType().Equals(TokenType.BracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.BracketOff) && !Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal)) { List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList(); tokensCopy.RemoveAt(tokens.Count - 1); tokensCopy.RemoveAt(0); tokens = tokensCopy; } // try to build simple one-token Stringable if (tokens.Count == 1) { if (tokens[0].GetTokenType().Equals(TokenType.Variable)) { string str = tokens[0].GetContent(); if (InterVariables.GetInstance().Contains(str, InterVarType.String)) { return(new StringVariableRefer(str)); } else { // try to build reference to date or clock time IStringable istr = BuildTimeVariableRefer(tokens[0]); if (!istr.IsNull()) { return(istr); } } } if (tokens[0].GetTokenType().Equals(TokenType.StringConstant)) { return(new StringConstant(tokens[0].GetContent())); } } //try to build string function if (Functions.IsPossibleFunction(tokens)) { IStringable istr = StringFunction.Build(tokens); if (!istr.IsNull()) { return(istr); } } // try to build string ternary if (TernaryBuilder.IsPossibleTernary(tokens)) { IStringable istr = TernaryBuilder.BuildStringTernary(tokens); if (!istr.IsNull()) { return(istr); } } // try to build reference to n-th element of list of strings if (tokens.Count > 3 && tokens[0].GetTokenType().Equals(TokenType.Variable) && tokens[1].GetTokenType().Equals(TokenType.SquareBracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.SquareBracketOff)) { IStringable istr = BuildListElement(tokens); if (!istr.IsNull()) { return(istr); } } // try to build concatenated string -> text merged by + if (TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Plus) && !TokenGroups.ContainsTokenOutsideBrackets(tokens, TokenType.Comma)) { return(BuildConcatenated(tokens)); } else { return(null); } }