diff --git a/build-support/solutions/Spring.Net.Core.2008.sln b/build-support/solutions/Spring.Net.Core.2008.sln index 7d77c74d..d477c873 100644 --- a/build-support/solutions/Spring.Net.Core.2008.sln +++ b/build-support/solutions/Spring.Net.Core.2008.sln @@ -19,6 +19,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Services.2008", "..\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Services.Tests.2008", "..\..\test\Spring\Spring.Services.Tests\Spring.Services.Tests.2008.csproj", "{4374F018-9738-46BF-A399-4594CEE75B21}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.2008", "..\..\src\Spring\Spring.Data\Spring.Data.2008.csproj", "{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.Tests.2008", "..\..\test\Spring\Spring.Data.Tests\Spring.Data.Tests.2008.csproj", "{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -119,6 +123,26 @@ Global {4374F018-9738-46BF-A399-4594CEE75B21}.Release|Any CPU.Build.0 = Release|Any CPU {4374F018-9738-46BF-A399-4594CEE75B21}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {4374F018-9738-46BF-A399-4594CEE75B21}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|.NET.ActiveCfg = Debug|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|.NET.ActiveCfg = Release|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.Build.0 = Release|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|.NET.ActiveCfg = Debug|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|.NET.ActiveCfg = Release|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Any CPU.Build.0 = Release|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Spring/Spring.Core/Core/TypeResolution/GenericArgumentsHolder.cs b/src/Spring/Spring.Core/Core/TypeResolution/GenericArgumentsHolder.cs index c6dfedfd..1d5727c9 100644 --- a/src/Spring/Spring.Core/Core/TypeResolution/GenericArgumentsHolder.cs +++ b/src/Spring/Spring.Core/Core/TypeResolution/GenericArgumentsHolder.cs @@ -1,5 +1,5 @@ -#region License - +#region License + /* * Copyright © 2002-2005 the original author or authors. * @@ -14,210 +14,353 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - -#endregion - -#if NET_2_0 - -#region Imports - -using System.Collections; - -using Spring.Util; - -#endregion - -namespace Spring.Core.TypeResolution -{ - /// - /// Holder for the generic arguments when using type parameters. - /// - /// - ///

- /// Type parameters can be applied to classes, interfaces, - /// structures, methods, delegates, etc... - ///

- ///
- public class GenericArgumentsHolder - { - #region Constants - - /// - /// The generic arguments prefix. - /// - public const char GenericArgumentsPrefix = '<'; - - /// - /// The generic arguments suffix. - /// - public const char GenericArgumentsSuffix = '>'; - - /// - /// The character that separates a list of generic arguments. - /// - public const char GenericArgumentsSeparator = ','; - - #endregion - - #region Fields - - private string unresolvedGenericTypeName; - private string unresolvedGenericMethodName; - private string[] unresolvedGenericArguments; - - #endregion - - #region Constructor (s) / Destructor - - /// - /// Creates a new instance of the GenericArgumentsHolder class. - /// - /// - /// The string value to parse looking for a generic definition - /// and retrieving its generic arguments. - /// - public GenericArgumentsHolder(string value) - { - ParseGenericArguments(value); - } - - #endregion - - #region Properties - - /// - /// The (unresolved) generic type name portion - /// of the original value when parsing a generic type. - /// - public string GenericTypeName - { - get { return unresolvedGenericTypeName; } - } - - /// - /// The (unresolved) generic method name portion - /// of the original value when parsing a generic method. - /// - public string GenericMethodName - { - get { return unresolvedGenericMethodName; } - } - - /// - /// Is the string value contains generic arguments ? - /// - /// - ///

- /// A generic argument can be a type parameter or a type argument. - ///

- ///
- public bool ContainsGenericArguments - { - get - { - return (unresolvedGenericArguments != null && - unresolvedGenericArguments.Length > 0); - } - } - - /// - /// Is generic arguments only contains type parameters ? - /// - public bool IsGenericDefinition - { - get - { - if (unresolvedGenericArguments == null) - return false; - - foreach (string arg in unresolvedGenericArguments) - { - if (arg.Length > 0) - return false; - } - return true; - } - } - - #endregion - - #region Methods - - /// - /// Returns an array of unresolved generic arguments types. - /// - /// - ///

- /// A empty string represents a type parameter that - /// did not have been substituted by a specific type. - ///

- ///
- /// - /// An array of strings that represents the unresolved generic - /// arguments types or an empty array if not generic. - /// - public string[] GetGenericArguments() - { - if (unresolvedGenericArguments == null) - return StringUtils.EmptyStrings; - - return unresolvedGenericArguments; - } - - private void ParseGenericArguments(string originalString) - { - int argsStartIndex - = originalString.IndexOf(GenericArgumentsPrefix); - if (argsStartIndex < 0) - { - unresolvedGenericTypeName = originalString; - unresolvedGenericMethodName = originalString; - } - else - { - int argsEndIndex = - originalString.LastIndexOf(GenericArgumentsSuffix); - if (argsEndIndex != -1) - { - unresolvedGenericMethodName = originalString.Remove( - argsStartIndex, argsEndIndex - argsStartIndex + 1); - - SplitGenericArguments(originalString.Substring( - argsStartIndex + 1, argsEndIndex - argsStartIndex - 1)); - - unresolvedGenericTypeName = originalString.Replace( - originalString.Substring(argsStartIndex, argsEndIndex - argsStartIndex + 1), - "`" + unresolvedGenericArguments.Length); - } - } - } - - private void SplitGenericArguments(string originalArgs) - { - IList args = new ArrayList(); - - int index = 0; - int cursor = originalArgs.IndexOf(GenericArgumentsSeparator, index); - while (cursor != -1) - { - string arg = originalArgs.Substring(index, cursor - index); - if (arg.Split(GenericArgumentsPrefix).Length == - arg.Split(GenericArgumentsSuffix).Length) - { - args.Add(arg.Trim()); - index = cursor + 1; - } - cursor = originalArgs.IndexOf(GenericArgumentsSeparator, cursor + 1); - } - args.Add(originalArgs.Substring(index, originalArgs.Length - index).Trim()); - - unresolvedGenericArguments = new string[args.Count]; - args.CopyTo(unresolvedGenericArguments, 0); - } - - #endregion - } -} - -#endif + */ + +#endregion + +#if NET_2_0 + +#region Imports + +using System.Collections; +using System.Text.RegularExpressions; +using Spring.Util; + +#endregion + +namespace Spring.Core.TypeResolution +{ + /// + /// Holder for the generic arguments when using type parameters. + /// + /// + ///

+ /// Type parameters can be applied to classes, interfaces, + /// structures, methods, delegates, etc... + ///

+ ///
+ public class GenericArgumentsHolder + { + #region Constants + + private static readonly Regex ClrPattern = new Regex( + "^" + + @"(?'name'\w[\w\d\.]+)" + + @"`\d+\s*\[" + + @"(?'args'(?>[^\[\]]+|\[(?)|\](?<-DEPTH>))*(?(DEPTH)(?!)))" + + @"\]" + + @"(?'remainder'.*)" + + @"$" + , RegexOptions.CultureInvariant | RegexOptions.Compiled + ); + + private static readonly Regex CSharpPattern = new Regex( + "^" + + @"(?'name'\w[\w\d\.]+)" + + @"<" + + @"(?'args'.*)" + + @">" + + @"(?'remainder'.*)" + + @"$" + , RegexOptions.CultureInvariant | RegexOptions.Compiled + ); + + private static Regex GenericArgumentListPattern = new Regex( + @",(" + + @"(\[(?>[^\[\]]+|\[(?)|\](?<-DEPTH>))*(?(DEPTH)(?!))\])" // capture anything between matching brackets + + @"|" + + @"([^,\[\]]*)" // alternatively capture any string that doesn't contain brackets and commas + + @")+" + ); + + /// + /// The generic arguments prefix. + /// + public const char GenericArgumentsQuotePrefix = '['; + + /// + /// The generic arguments suffix. + /// + public const char GenericArgumentsQuoteSuffix = ']'; + + /// + /// The generic arguments prefix. + /// + public const char GenericArgumentsPrefix = '<'; + + /// + /// The generic arguments suffix. + /// + public const char GenericArgumentsSuffix = '>'; + + /// + /// The character that separates a list of generic arguments. + /// + public const char GenericArgumentsSeparator = ','; + + #endregion + + #region Fields + + private string unresolvedGenericTypeName; + private string unresolvedGenericMethodName; + private string[] unresolvedGenericArguments; + private string arrayDeclaration; + + #endregion + + #region Constructor (s) / Destructor + + /// + /// Creates a new instance of the GenericArgumentsHolder class. + /// + /// + /// The string value to parse looking for a generic definition + /// and retrieving its generic arguments. + /// + public GenericArgumentsHolder(string value) + { + ParseGenericTypeDeclaration(value); + } + + #endregion + + #region Properties + + /// + /// The (unresolved) generic type name portion + /// of the original value when parsing a generic type. + /// + public string GenericTypeName + { + get { return unresolvedGenericTypeName; } + } + + /// + /// The (unresolved) generic method name portion + /// of the original value when parsing a generic method. + /// + public string GenericMethodName + { + get { return unresolvedGenericMethodName; } + } + + /// + /// Is the string value contains generic arguments ? + /// + /// + ///

+ /// A generic argument can be a type parameter or a type argument. + ///

+ ///
+ public bool ContainsGenericArguments + { + get + { + return (unresolvedGenericArguments != null && + unresolvedGenericArguments.Length > 0); + } + } + + /// + /// Is generic arguments only contains type parameters ? + /// + public bool IsGenericDefinition + { + get + { + if (unresolvedGenericArguments == null) + return false; + + foreach (string arg in unresolvedGenericArguments) + { + if (arg.Length > 0) + return false; + } + return true; + } + } + + /// + /// Returns the array declaration portion of the definition, e.g. "[,]" + /// + /// + public string GetArrayDeclaration() + { + return arrayDeclaration; + } + + /// + /// Is this an array type definition? + /// + public bool IsArrayDeclaration + { + get { return arrayDeclaration != null; } + } + + #endregion + + #region Methods + + /// + /// Returns an array of unresolved generic arguments types. + /// + /// + ///

+ /// A empty string represents a type parameter that + /// did not have been substituted by a specific type. + ///

+ ///
+ /// + /// An array of strings that represents the unresolved generic + /// arguments types or an empty array if not generic. + /// + public string[] GetGenericArguments() + { + if (unresolvedGenericArguments == null) + return StringUtils.EmptyStrings; + + return unresolvedGenericArguments; + } + + private void ParseGenericTypeDeclaration(string originalString) + { + if (originalString.IndexOf('[') == -1 && originalString.IndexOf('<') == -1) + { + // nothing to do + unresolvedGenericTypeName = originalString; + unresolvedGenericMethodName = originalString; + return; + } + + originalString = originalString.Trim(); + + bool isClrStyleNotation = originalString.IndexOf('`') > -1; + + Match m = (isClrStyleNotation) + ? ClrPattern.Match(originalString) + : CSharpPattern.Match(originalString); + + if (m == null || !m.Success) + { + unresolvedGenericTypeName = originalString; + unresolvedGenericMethodName = originalString; + return; + } + + Group g = m.Groups["args"]; + unresolvedGenericArguments = ParseGenericArgumentList(g.Value); + + string name = m.Groups["name"].Value; + string remainder = m.Groups["remainder"].Value.Trim(); + + // check, if we're dealing with an array type declaration + if (remainder.Length > 0 && remainder.IndexOf('[') > -1) + { + string[] remainderParts = StringUtils.Split(remainder, ",", false, false, "[]"); + string arrayPart = remainderParts[0].Trim(); + if (arrayPart[0] == '[' && arrayPart[arrayPart.Length-1] == ']') + { + arrayDeclaration = arrayPart; + remainder = ", " + string.Join(",", remainderParts, 1, remainderParts.Length - 1); + } + } + + unresolvedGenericMethodName = name + remainder; + unresolvedGenericTypeName = name + "`" + unresolvedGenericArguments.Length + remainder; + + + + // char lBoundary = isClrStyleNotation ? '[' : GenericArgumentsPrefix; + // char rBoundary = isClrStyleNotation ? ']' : GenericArgumentsSuffix; + // + // int argsStartIndex = originalString.IndexOf(lBoundary); + // if (argsStartIndex < 0) + // { + // unresolvedGenericTypeName = originalString; + // unresolvedGenericMethodName = originalString; + // } + // else + // { + // int argsEndIndex = originalString.LastIndexOf(rBoundary); + // if (argsEndIndex != -1) + // { + // unresolvedGenericMethodName = originalString.Remove( + // argsStartIndex, argsEndIndex - argsStartIndex + 1); + // + // unresolvedGenericArguments = ParseGenericArgumentList(originalString.Substring( + // argsStartIndex + 1, argsEndIndex - argsStartIndex - 1)); + // + // unresolvedGenericTypeName = originalString.Replace( + // originalString.Substring(argsStartIndex, argsEndIndex - argsStartIndex + 1), + // "`" + unresolvedGenericArguments.Length); + // } + // } + } + + private static string[] ParseGenericArgumentList(string originalArgs) + { + string[] args = StringUtils.Split(originalArgs, ",", true, false, "[]<>" ); + // remove quotes if necessary + for(int i=0;i 1 && arg[0] == '[') + { + args[i] = arg.Substring(1, arg.Length - 2); + } + } + return args; +// ArrayList args = new ArrayList(); +// originalArgs = originalArgs.Trim(); +// if (originalArgs.Length == 0) +// { +// return new string[0]; +// } +// +// if (originalArgs.IndexOf(',') == -1) +// { +// return new string[] { originalArgs }; +// } +// +// // pattern assumes "(,)+" +// originalArgs = "," + originalArgs; +// +// foreach (Match match in GenericArgumentListPattern.Matches(originalArgs)) +// { +// string arg = match.Groups["args"].Value.Trim(' ', '\t', '[', ']'); +// args.Add(arg); +// } + + // Match m = GenericArgumentListPattern.Match(originalArgs); + // if (m != null && m.Success) + // { + // Group g = m.Groups[0]; + // foreach (Capture capture in g.Captures) + // { + // string arg = capture.Value.Trim(' ', '\t', '[', ']'); + // args.Add(arg); + // } + // } + // int index = 0; + // int cursor = originalArgs.IndexOf(GenericArgumentsSeparator, index); + // while (cursor != -1) + // { + // string arg = originalArgs.Substring(index, cursor - index); + // if (arg.Split(GenericArgumentsPrefix).Length == + // arg.Split(GenericArgumentsSuffix).Length) + // { + // args.Add(arg.Trim()); + // index = cursor + 1; + // } + // cursor = originalArgs.IndexOf(GenericArgumentsSeparator, cursor + 1); + // } + // args.Add(originalArgs.Substring(index, originalArgs.Length - index).Trim()); + +// return (string[])args.ToArray(typeof(string)); + } + #endregion + } +} + +#endif diff --git a/src/Spring/Spring.Core/Core/TypeResolution/GenericTypeResolver.cs b/src/Spring/Spring.Core/Core/TypeResolution/GenericTypeResolver.cs index 2dfe9a48..e4106dee 100644 --- a/src/Spring/Spring.Core/Core/TypeResolution/GenericTypeResolver.cs +++ b/src/Spring/Spring.Core/Core/TypeResolution/GenericTypeResolver.cs @@ -75,6 +75,11 @@ namespace Spring.Core.TypeResolution genericArgs[i] = TypeResolutionUtils.ResolveType(unresolvedGenericArgs[i]); } type = type.MakeGenericType(genericArgs); + } + if (genericInfo.IsArrayDeclaration) + { + typeName = string.Format("{0}{1},{2}", type.FullName, genericInfo.GetArrayDeclaration(), type.Assembly.FullName); + type = null; } } } diff --git a/src/Spring/Spring.Core/Expressions/Expression.g b/src/Spring/Spring.Core/Expressions/Expression.g index fb58a31e..5683d6a6 100644 --- a/src/Spring/Spring.Core/Expressions/Expression.g +++ b/src/Spring/Spring.Core/Expressions/Expression.g @@ -190,13 +190,17 @@ property ; reference - : AT! LPAREN! (cn:contextName! COLON!)? id:qualifiedId! RPAREN! + : AT! LPAREN! (cn:contextName! COLON!)? id:qualifiedId! RPAREN! { #reference = #([EXPR, "ref", "Spring.Context.Support.ReferenceNode"], #cn, #id); } - ; + ; + +contextName + : STRING_LITERAL + | qualifiedId (DIV qualifiedId)* + ; indexer - : - LBRACKET^ argument (COMMA! argument)* RBRACKET! + : LBRACKET^ argument (COMMA! argument)* RBRACKET! ; projection @@ -220,10 +224,14 @@ lastSelection ; type - : TYPE! tn:qualifiedId! (LBRACKET RBRACKET)? (COMMA qualifiedId)? RPAREN! - { #type = #([EXPR, tn_AST.getText(), "Spring.Expressions.TypeNode"], #type); } + : TYPE! tn:typename! RPAREN! + { #type = #([EXPR, tn_AST.getText(), "Spring.Expressions.TypeNode"], #type); } ; - + +typename + : ID^ (~RPAREN)* + ; + attribute : AT! LBRACKET! tn:qualifiedId! (ctorArgs)? RBRACKET! { #attribute = #([EXPR, tn_AST.getText(), "Spring.Expressions.AttributeNode"], #attribute); } @@ -278,9 +286,6 @@ namedArgument qualifiedId : ID^ (DOT ID)* ; -contextName : ID^ (DIV ID)* - ; - literal : NULL_LITERAL | INTEGER_LITERAL @@ -339,6 +344,12 @@ WS : (' ' AT: '@' ; +BACKTICK: '`' + ; + +BACKSLASH: '\\' + ; + PIPE: '|' ; @@ -444,12 +455,15 @@ LAMBDA: "{|" DOT_ESCAPED: "\\." ; +QUOTE: '\'' + ; + STRING_LITERAL - : '\''! (APOS|~'\'')* '\''! + : QUOTE! (APOS|~'\'')* QUOTE! ; -protected -APOS : '\''! '\'' +protected +APOS : QUOTE! QUOTE ; ID @@ -495,6 +509,7 @@ protected DECIMAL_DIGIT : '0'..'9' ; + protected INTEGER_TYPE_SUFFIX : diff --git a/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs b/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs index 11fd3f42..3fe3e414 100644 --- a/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs +++ b/src/Spring/Spring.Core/Expressions/ExpressionEvaluator.cs @@ -54,7 +54,8 @@ namespace Spring.Expressions /// Value of the last node in the expression. public static object GetValue(object root, string expression) { - return Expression.Parse(expression).GetValue(root, null); + IExpression exp = Expression.Parse(expression); + return exp.GetValue(root, null); } /// @@ -66,7 +67,8 @@ namespace Spring.Expressions /// Value of the last node in the expression. public static object GetValue(object root, string expression, IDictionary variables) { - return Expression.Parse(expression).GetValue(root, variables); + IExpression exp = Expression.Parse(expression); + return exp.GetValue(root, variables); } /// @@ -78,7 +80,8 @@ namespace Spring.Expressions /// Value to set last node to. public static void SetValue(object root, string expression, object newValue) { - Expression.Parse(expression).SetValue(root, null, newValue); + IExpression exp = Expression.Parse(expression); + exp.SetValue(root, null, newValue); } /// @@ -91,7 +94,8 @@ namespace Spring.Expressions /// Value to set last node to. public static void SetValue(object root, string expression, IDictionary variables, object newValue) { - Expression.Parse(expression).SetValue(root, variables, newValue); + IExpression exp = Expression.Parse(expression); + exp.SetValue(root, variables, newValue); } } } \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs index e6923693..645dda64 100644 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs +++ b/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs @@ -66,22 +66,22 @@ namespace Spring.Expressions public const int DOLLAR = 33; public const int COMMA = 34; public const int AT = 35; - public const int LBRACKET = 36; - public const int RBRACKET = 37; - public const int PROJECT = 38; - public const int RCURLY = 39; - public const int SELECT = 40; - public const int SELECT_FIRST = 41; - public const int SELECT_LAST = 42; - public const int TYPE = 43; - public const int LAMBDA = 44; - public const int PIPE = 45; - public const int LITERAL_new = 46; - public const int LCURLY = 47; - public const int INTEGER_LITERAL = 48; - public const int HEXADECIMAL_INTEGER_LITERAL = 49; - public const int REAL_LITERAL = 50; - public const int STRING_LITERAL = 51; + public const int STRING_LITERAL = 36; + public const int LBRACKET = 37; + public const int RBRACKET = 38; + public const int PROJECT = 39; + public const int RCURLY = 40; + public const int SELECT = 41; + public const int SELECT_FIRST = 42; + public const int SELECT_LAST = 43; + public const int TYPE = 44; + public const int LAMBDA = 45; + public const int PIPE = 46; + public const int LITERAL_new = 47; + public const int LCURLY = 48; + public const int INTEGER_LITERAL = 49; + public const int HEXADECIMAL_INTEGER_LITERAL = 50; + public const int REAL_LITERAL = 51; public const int LITERAL_date = 52; public const int EQUAL = 53; public const int NOT_EQUAL = 54; @@ -90,15 +90,18 @@ namespace Spring.Expressions public const int GREATER_THAN = 57; public const int GREATER_THAN_OR_EQUAL = 58; public const int WS = 59; - public const int DOT_ESCAPED = 60; - public const int APOS = 61; - public const int NUMERIC_LITERAL = 62; - public const int DECIMAL_DIGIT = 63; - public const int INTEGER_TYPE_SUFFIX = 64; - public const int HEX_DIGIT = 65; - public const int EXPONENT_PART = 66; - public const int SIGN = 67; - public const int REAL_TYPE_SUFFIX = 68; + public const int BACKTICK = 60; + public const int BACKSLASH = 61; + public const int DOT_ESCAPED = 62; + public const int QUOTE = 63; + public const int APOS = 64; + public const int NUMERIC_LITERAL = 65; + public const int DECIMAL_DIGIT = 66; + public const int INTEGER_TYPE_SUFFIX = 67; + public const int HEX_DIGIT = 68; + public const int EXPONENT_PART = 69; + public const int SIGN = 70; + public const int REAL_TYPE_SUFFIX = 71; // CLOVER:OFF @@ -132,7 +135,7 @@ namespace Spring.Expressions literals.Add("or", 9); literals.Add("is", 11); literals.Add("like", 13); - literals.Add("new", 46); + literals.Add("new", 47); literals.Add("date", 52); literals.Add("false", 6); } @@ -164,6 +167,12 @@ tryAgain: theRetToken = returnToken_; break; } + case '`': + { + mBACKTICK(true); + theRetToken = returnToken_; + break; + } case '|': { mPIPE(true); @@ -254,18 +263,6 @@ tryAgain: theRetToken = returnToken_; break; } - case '\\': - { - mDOT_ESCAPED(true); - theRetToken = returnToken_; - break; - } - case '\'': - { - mSTRING_LITERAL(true); - theRetToken = returnToken_; - break; - } default: if ((cached_LA1=='?') && (cached_LA2=='?')) { @@ -312,10 +309,22 @@ tryAgain: mLAMBDA(true); theRetToken = returnToken_; } + else if ((cached_LA1=='\\') && (cached_LA2=='.')) { + mDOT_ESCAPED(true); + theRetToken = returnToken_; + } + else if ((cached_LA1=='\'') && ((cached_LA2 >= '\u0000' && cached_LA2 <= '\ufffe'))) { + mSTRING_LITERAL(true); + theRetToken = returnToken_; + } else if ((cached_LA1=='0') && (cached_LA2=='x')) { mHEXADECIMAL_INTEGER_LITERAL(true); theRetToken = returnToken_; } + else if ((cached_LA1=='\\') && (true)) { + mBACKSLASH(true); + theRetToken = returnToken_; + } else if ((cached_LA1=='!') && (true)) { mBANG(true); theRetToken = returnToken_; @@ -348,6 +357,10 @@ tryAgain: mGREATER_THAN(true); theRetToken = returnToken_; } + else if ((cached_LA1=='\'') && (true)) { + mQUOTE(true); + theRetToken = returnToken_; + } else if ((tokenSet_0_.member(cached_LA1)) && (true)) { mID(true); theRetToken = returnToken_; @@ -442,6 +455,34 @@ tryAgain: returnToken_ = _token; } + public void mBACKTICK(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException +{ + int _ttype; IToken _token=null; int _begin=text.Length; + _ttype = BACKTICK; + + match('`'); + if (_createToken && (null == _token) && (_ttype != Token.SKIP)) + { + _token = makeToken(_ttype); + _token.setText(text.ToString(_begin, text.Length-_begin)); + } + returnToken_ = _token; + } + + public void mBACKSLASH(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException +{ + int _ttype; IToken _token=null; int _begin=text.Length; + _ttype = BACKSLASH; + + match('\\'); + if (_createToken && (null == _token) && (_ttype != Token.SKIP)) + { + _token = makeToken(_ttype); + _token.setText(text.ToString(_begin, text.Length-_begin)); + } + returnToken_ = _token; + } + public void mPIPE(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; IToken _token=null; int _begin=text.Length; @@ -932,6 +973,20 @@ tryAgain: returnToken_ = _token; } + public void mQUOTE(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException +{ + int _ttype; IToken _token=null; int _begin=text.Length; + _ttype = QUOTE; + + match('\''); + if (_createToken && (null == _token) && (_ttype != Token.SKIP)) + { + _token = makeToken(_ttype); + _token.setText(text.ToString(_begin, text.Length-_begin)); + } + returnToken_ = _token; + } + public void mSTRING_LITERAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; IToken _token=null; int _begin=text.Length; @@ -939,7 +994,7 @@ tryAgain: int _saveIndex = 0; _saveIndex = text.Length; - match('\''); + mQUOTE(false); text.Length = _saveIndex; { // ( ... )* for (;;) @@ -953,14 +1008,14 @@ tryAgain: } else { - goto _loop156_breakloop; + goto _loop160_breakloop; } } -_loop156_breakloop: ; +_loop160_breakloop: ; } // ( ... )* _saveIndex = text.Length; - match('\''); + mQUOTE(false); text.Length = _saveIndex; if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { @@ -977,9 +1032,9 @@ _loop156_breakloop: ; int _saveIndex = 0; _saveIndex = text.Length; - match('\''); + mQUOTE(false); text.Length = _saveIndex; - match('\''); + mQUOTE(false); if (_createToken && (null == _token) && (_ttype != Token.SKIP)) { _token = makeToken(_ttype); @@ -1075,11 +1130,11 @@ _loop156_breakloop: ; } default: { - goto _loop161_breakloop; + goto _loop165_breakloop; } } } -_loop161_breakloop: ; +_loop165_breakloop: ; } // ( ... )* _ttype = testLiteralsTable(_ttype); if (_createToken && (null == _token) && (_ttype != Token.SKIP)) @@ -1095,11 +1150,11 @@ _loop161_breakloop: ; int _ttype; IToken _token=null; int _begin=text.Length; _ttype = NUMERIC_LITERAL; - bool synPredMatched164 = false; + bool synPredMatched168 = false; if (((cached_LA1=='.') && ((cached_LA2 >= '0' && cached_LA2 <= '9')))) { - int _m164 = mark(); - synPredMatched164 = true; + int _m168 = mark(); + synPredMatched168 = true; inputState.guessing++; try { { @@ -1109,16 +1164,16 @@ _loop161_breakloop: ; } catch (RecognitionException) { - synPredMatched164 = false; + synPredMatched168 = false; } - rewind(_m164); + rewind(_m168); inputState.guessing--; } - if ( synPredMatched164 ) + if ( synPredMatched168 ) { match('.'); { // ( ... )+ - int _cnt166=0; + int _cnt170=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1127,12 +1182,12 @@ _loop161_breakloop: ; } else { - if (_cnt166 >= 1) { goto _loop166_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt170 >= 1) { goto _loop170_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt166++; + _cnt170++; } -_loop166_breakloop: ; +_loop170_breakloop: ; } // ( ... )+ { if ((cached_LA1=='E'||cached_LA1=='e')) @@ -1158,16 +1213,16 @@ _loop166_breakloop: ; } } else { - bool synPredMatched172 = false; + bool synPredMatched176 = false; if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_1_.member(cached_LA2)))) { - int _m172 = mark(); - synPredMatched172 = true; + int _m176 = mark(); + synPredMatched176 = true; inputState.guessing++; try { { { // ( ... )+ - int _cnt171=0; + int _cnt175=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1176,12 +1231,12 @@ _loop166_breakloop: ; } else { - if (_cnt171 >= 1) { goto _loop171_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt175 >= 1) { goto _loop175_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt171++; + _cnt175++; } -_loop171_breakloop: ; +_loop175_breakloop: ; } // ( ... )+ match('.'); mDECIMAL_DIGIT(false); @@ -1189,15 +1244,15 @@ _loop171_breakloop: ; } catch (RecognitionException) { - synPredMatched172 = false; + synPredMatched176 = false; } - rewind(_m172); + rewind(_m176); inputState.guessing--; } - if ( synPredMatched172 ) + if ( synPredMatched176 ) { { // ( ... )+ - int _cnt174=0; + int _cnt178=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1206,16 +1261,16 @@ _loop171_breakloop: ; } else { - if (_cnt174 >= 1) { goto _loop174_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt178 >= 1) { goto _loop178_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt174++; + _cnt178++; } -_loop174_breakloop: ; +_loop178_breakloop: ; } // ( ... )+ match('.'); { // ( ... )+ - int _cnt176=0; + int _cnt180=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1224,12 +1279,12 @@ _loop174_breakloop: ; } else { - if (_cnt176 >= 1) { goto _loop176_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt180 >= 1) { goto _loop180_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt176++; + _cnt180++; } -_loop176_breakloop: ; +_loop180_breakloop: ; } // ( ... )+ { if ((cached_LA1=='E'||cached_LA1=='e')) @@ -1255,16 +1310,16 @@ _loop176_breakloop: ; } } else { - bool synPredMatched183 = false; + bool synPredMatched187 = false; if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_4_.member(cached_LA2)))) { - int _m183 = mark(); - synPredMatched183 = true; + int _m187 = mark(); + synPredMatched187 = true; inputState.guessing++; try { { { // ( ... )+ - int _cnt181=0; + int _cnt185=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1273,12 +1328,12 @@ _loop176_breakloop: ; } else { - if (_cnt181 >= 1) { goto _loop181_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt185 >= 1) { goto _loop185_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt181++; + _cnt185++; } -_loop181_breakloop: ; +_loop185_breakloop: ; } // ( ... )+ { mEXPONENT_PART(false); @@ -1287,15 +1342,15 @@ _loop181_breakloop: ; } catch (RecognitionException) { - synPredMatched183 = false; + synPredMatched187 = false; } - rewind(_m183); + rewind(_m187); inputState.guessing--; } - if ( synPredMatched183 ) + if ( synPredMatched187 ) { { // ( ... )+ - int _cnt185=0; + int _cnt189=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1304,12 +1359,12 @@ _loop181_breakloop: ; } else { - if (_cnt185 >= 1) { goto _loop185_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt189 >= 1) { goto _loop189_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt185++; + _cnt189++; } -_loop185_breakloop: ; +_loop189_breakloop: ; } // ( ... )+ { mEXPONENT_PART(false); @@ -1329,16 +1384,16 @@ _loop185_breakloop: ; } } else { - bool synPredMatched192 = false; + bool synPredMatched196 = false; if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_5_.member(cached_LA2)))) { - int _m192 = mark(); - synPredMatched192 = true; + int _m196 = mark(); + synPredMatched196 = true; inputState.guessing++; try { { { // ( ... )+ - int _cnt190=0; + int _cnt194=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1347,12 +1402,12 @@ _loop185_breakloop: ; } else { - if (_cnt190 >= 1) { goto _loop190_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt194 >= 1) { goto _loop194_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt190++; + _cnt194++; } -_loop190_breakloop: ; +_loop194_breakloop: ; } // ( ... )+ { mREAL_TYPE_SUFFIX(false); @@ -1361,15 +1416,15 @@ _loop190_breakloop: ; } catch (RecognitionException) { - synPredMatched192 = false; + synPredMatched196 = false; } - rewind(_m192); + rewind(_m196); inputState.guessing--; } - if ( synPredMatched192 ) + if ( synPredMatched196 ) { { // ( ... )+ - int _cnt194=0; + int _cnt198=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1378,12 +1433,12 @@ _loop190_breakloop: ; } else { - if (_cnt194 >= 1) { goto _loop194_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt198 >= 1) { goto _loop198_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt194++; + _cnt198++; } -_loop194_breakloop: ; +_loop198_breakloop: ; } // ( ... )+ { mREAL_TYPE_SUFFIX(false); @@ -1395,7 +1450,7 @@ _loop194_breakloop: ; } else if (((cached_LA1 >= '0' && cached_LA1 <= '9')) && (true)) { { // ( ... )+ - int _cnt197=0; + int _cnt201=0; for (;;) { if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) @@ -1404,12 +1459,12 @@ _loop194_breakloop: ; } else { - if (_cnt197 >= 1) { goto _loop197_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt201 >= 1) { goto _loop201_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt197++; + _cnt201++; } -_loop197_breakloop: ; +_loop201_breakloop: ; } // ( ... )+ { if ((tokenSet_6_.member(cached_LA1))) @@ -1469,43 +1524,6 @@ _loop197_breakloop: ; case 'e': { match("e"); - { // ( ... )* - for (;;) - { - if ((cached_LA1=='+'||cached_LA1=='-')) - { - mSIGN(false); - } - else - { - goto _loop209_breakloop; - } - - } -_loop209_breakloop: ; - } // ( ... )* - { // ( ... )+ - int _cnt211=0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt211 >= 1) { goto _loop211_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } - } - - _cnt211++; - } -_loop211_breakloop: ; - } // ( ... )+ - break; - } - case 'E': - { - match("E"); { // ( ... )* for (;;) { @@ -1540,6 +1558,43 @@ _loop215_breakloop: ; } // ( ... )+ break; } + case 'E': + { + match("E"); + { // ( ... )* + for (;;) + { + if ((cached_LA1=='+'||cached_LA1=='-')) + { + mSIGN(false); + } + else + { + goto _loop217_breakloop; + } + + } +_loop217_breakloop: ; + } // ( ... )* + { // ( ... )+ + int _cnt219=0; + for (;;) + { + if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) + { + mDECIMAL_DIGIT(false); + } + else + { + if (_cnt219 >= 1) { goto _loop219_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + } + + _cnt219++; + } +_loop219_breakloop: ; + } // ( ... )+ + break; + } default: { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); @@ -1667,7 +1722,7 @@ _loop215_breakloop: ; match("0x"); { // ( ... )+ - int _cnt201=0; + int _cnt205=0; for (;;) { if ((tokenSet_7_.member(cached_LA1))) @@ -1676,12 +1731,12 @@ _loop215_breakloop: ; } else { - if (_cnt201 >= 1) { goto _loop201_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } + if (_cnt205 >= 1) { goto _loop205_breakloop; } else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn());; } } - _cnt201++; + _cnt205++; } -_loop201_breakloop: ; +_loop205_breakloop: ; } // ( ... )+ { if ((tokenSet_6_.member(cached_LA1))) diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs index ad96467e..a00102bb 100644 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs +++ b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs @@ -60,22 +60,22 @@ namespace Spring.Expressions public const int DOLLAR = 33; public const int COMMA = 34; public const int AT = 35; - public const int LBRACKET = 36; - public const int RBRACKET = 37; - public const int PROJECT = 38; - public const int RCURLY = 39; - public const int SELECT = 40; - public const int SELECT_FIRST = 41; - public const int SELECT_LAST = 42; - public const int TYPE = 43; - public const int LAMBDA = 44; - public const int PIPE = 45; - public const int LITERAL_new = 46; - public const int LCURLY = 47; - public const int INTEGER_LITERAL = 48; - public const int HEXADECIMAL_INTEGER_LITERAL = 49; - public const int REAL_LITERAL = 50; - public const int STRING_LITERAL = 51; + public const int STRING_LITERAL = 36; + public const int LBRACKET = 37; + public const int RBRACKET = 38; + public const int PROJECT = 39; + public const int RCURLY = 40; + public const int SELECT = 41; + public const int SELECT_FIRST = 42; + public const int SELECT_LAST = 43; + public const int TYPE = 44; + public const int LAMBDA = 45; + public const int PIPE = 46; + public const int LITERAL_new = 47; + public const int LCURLY = 48; + public const int INTEGER_LITERAL = 49; + public const int HEXADECIMAL_INTEGER_LITERAL = 50; + public const int REAL_LITERAL = 51; public const int LITERAL_date = 52; public const int EQUAL = 53; public const int NOT_EQUAL = 54; @@ -84,15 +84,18 @@ namespace Spring.Expressions public const int GREATER_THAN = 57; public const int GREATER_THAN_OR_EQUAL = 58; public const int WS = 59; - public const int DOT_ESCAPED = 60; - public const int APOS = 61; - public const int NUMERIC_LITERAL = 62; - public const int DECIMAL_DIGIT = 63; - public const int INTEGER_TYPE_SUFFIX = 64; - public const int HEX_DIGIT = 65; - public const int EXPONENT_PART = 66; - public const int SIGN = 67; - public const int REAL_TYPE_SUFFIX = 68; + public const int BACKTICK = 60; + public const int BACKSLASH = 61; + public const int DOT_ESCAPED = 62; + public const int QUOTE = 63; + public const int APOS = 64; + public const int NUMERIC_LITERAL = 65; + public const int DECIMAL_DIGIT = 66; + public const int INTEGER_TYPE_SUFFIX = 67; + public const int HEX_DIGIT = 68; + public const int EXPONENT_PART = 69; + public const int SIGN = 70; + public const int REAL_TYPE_SUFFIX = 71; // CLOVER:OFF @@ -1129,10 +1132,10 @@ _loop26_breakloop: ; case FALSE: case TRUE: case NULL_LITERAL: + case STRING_LITERAL: case INTEGER_LITERAL: case HEXADECIMAL_INTEGER_LITERAL: case REAL_LITERAL: - case STRING_LITERAL: case LITERAL_date: { literal(); @@ -1623,7 +1626,7 @@ _loop40_breakloop: ; match(AT); match(LPAREN); { - if ((LA(1)==ID) && (LA(2)==COLON||LA(2)==DIV)) + if ((LA(1)==ID||LA(1)==STRING_LITERAL) && (LA(2)==COLON||LA(2)==DIV||LA(2)==DOT)) { contextName(); if (0 == inputState.guessing) @@ -1705,11 +1708,11 @@ _loop40_breakloop: ; } else { - goto _loop63_breakloop; + goto _loop66_breakloop; } } -_loop63_breakloop: ; +_loop66_breakloop: ; } // ( ... )* match(RBRACKET); indexer_AST = (Spring.Expressions.SpringAST)currentAST.root; @@ -1836,52 +1839,11 @@ _loop63_breakloop: ; try { // for error handling match(TYPE); - qualifiedId(); + typename(); if (0 == inputState.guessing) { tn_AST = (Spring.Expressions.SpringAST)returnAST; } - { - if ((LA(1)==LBRACKET)) - { - Spring.Expressions.SpringAST tmp51_AST = null; - tmp51_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp51_AST); - match(LBRACKET); - Spring.Expressions.SpringAST tmp52_AST = null; - tmp52_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp52_AST); - match(RBRACKET); - } - else if ((LA(1)==RPAREN||LA(1)==COMMA)) { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - - } - { - if ((LA(1)==COMMA)) - { - Spring.Expressions.SpringAST tmp53_AST = null; - tmp53_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp53_AST); - match(COMMA); - qualifiedId(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST)returnAST); - } - } - else if ((LA(1)==RPAREN)) { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - - } match(RPAREN); if (0==inputState.guessing) { @@ -1920,11 +1882,11 @@ _loop63_breakloop: ; Spring.Expressions.SpringAST type_AST = null; try { // for error handling - bool synPredMatched83 = false; + bool synPredMatched87 = false; if (((LA(1)==LITERAL_new) && (LA(2)==ID))) { - int _m83 = mark(); - synPredMatched83 = true; + int _m87 = mark(); + synPredMatched87 = true; inputState.guessing++; try { { @@ -1935,12 +1897,12 @@ _loop63_breakloop: ; } catch (RecognitionException) { - synPredMatched83 = false; + synPredMatched87 = false; } - rewind(_m83); + rewind(_m87); inputState.guessing--; } - if ( synPredMatched83 ) + if ( synPredMatched87 ) { match(LITERAL_new); qualifiedId(); @@ -2003,9 +1965,9 @@ _loop63_breakloop: ; Spring.Expressions.SpringAST projection_AST = null; try { // for error handling - Spring.Expressions.ProjectionNode tmp56_AST = null; - tmp56_AST = (Spring.Expressions.ProjectionNode) astFactory.create(LT(1), "Spring.Expressions.ProjectionNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp56_AST); + Spring.Expressions.ProjectionNode tmp53_AST = null; + tmp53_AST = (Spring.Expressions.ProjectionNode) astFactory.create(LT(1), "Spring.Expressions.ProjectionNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp53_AST); match(PROJECT); expression(); if (0 == inputState.guessing) @@ -2038,9 +2000,9 @@ _loop63_breakloop: ; Spring.Expressions.SpringAST selection_AST = null; try { // for error handling - Spring.Expressions.SelectionNode tmp58_AST = null; - tmp58_AST = (Spring.Expressions.SelectionNode) astFactory.create(LT(1), "Spring.Expressions.SelectionNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp58_AST); + Spring.Expressions.SelectionNode tmp55_AST = null; + tmp55_AST = (Spring.Expressions.SelectionNode) astFactory.create(LT(1), "Spring.Expressions.SelectionNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp55_AST); match(SELECT); expression(); if (0 == inputState.guessing) @@ -2061,11 +2023,11 @@ _loop63_breakloop: ; } else { - goto _loop67_breakloop; + goto _loop70_breakloop; } } -_loop67_breakloop: ; +_loop70_breakloop: ; } // ( ... )* match(RCURLY); selection_AST = (Spring.Expressions.SpringAST)currentAST.root; @@ -2093,9 +2055,9 @@ _loop67_breakloop: ; Spring.Expressions.SpringAST firstSelection_AST = null; try { // for error handling - Spring.Expressions.SelectionFirstNode tmp61_AST = null; - tmp61_AST = (Spring.Expressions.SelectionFirstNode) astFactory.create(LT(1), "Spring.Expressions.SelectionFirstNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp61_AST); + Spring.Expressions.SelectionFirstNode tmp58_AST = null; + tmp58_AST = (Spring.Expressions.SelectionFirstNode) astFactory.create(LT(1), "Spring.Expressions.SelectionFirstNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp58_AST); match(SELECT_FIRST); expression(); if (0 == inputState.guessing) @@ -2128,9 +2090,9 @@ _loop67_breakloop: ; Spring.Expressions.SpringAST lastSelection_AST = null; try { // for error handling - Spring.Expressions.SelectionLastNode tmp63_AST = null; - tmp63_AST = (Spring.Expressions.SelectionLastNode) astFactory.create(LT(1), "Spring.Expressions.SelectionLastNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp63_AST); + Spring.Expressions.SelectionLastNode tmp60_AST = null; + tmp60_AST = (Spring.Expressions.SelectionLastNode) astFactory.create(LT(1), "Spring.Expressions.SelectionLastNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp60_AST); match(SELECT_LAST); expression(); if (0 == inputState.guessing) @@ -2163,9 +2125,9 @@ _loop67_breakloop: ; Spring.Expressions.SpringAST listInitializer_AST = null; try { // for error handling - Spring.Expressions.ListInitializerNode tmp65_AST = null; - tmp65_AST = (Spring.Expressions.ListInitializerNode) astFactory.create(LT(1), "Spring.Expressions.ListInitializerNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp65_AST); + Spring.Expressions.ListInitializerNode tmp62_AST = null; + tmp62_AST = (Spring.Expressions.ListInitializerNode) astFactory.create(LT(1), "Spring.Expressions.ListInitializerNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp62_AST); match(LCURLY); expression(); if (0 == inputState.guessing) @@ -2186,11 +2148,11 @@ _loop67_breakloop: ; } else { - goto _loop92_breakloop; + goto _loop96_breakloop; } } -_loop92_breakloop: ; +_loop96_breakloop: ; } // ( ... )* match(RCURLY); listInitializer_AST = (Spring.Expressions.SpringAST)currentAST.root; @@ -2219,9 +2181,9 @@ _loop92_breakloop: ; try { // for error handling match(POUND); - Spring.Expressions.MapInitializerNode tmp69_AST = null; - tmp69_AST = (Spring.Expressions.MapInitializerNode) astFactory.create(LT(1), "Spring.Expressions.MapInitializerNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp69_AST); + Spring.Expressions.MapInitializerNode tmp66_AST = null; + tmp66_AST = (Spring.Expressions.MapInitializerNode) astFactory.create(LT(1), "Spring.Expressions.MapInitializerNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp66_AST); match(LCURLY); mapEntry(); if (0 == inputState.guessing) @@ -2242,11 +2204,11 @@ _loop92_breakloop: ; } else { - goto _loop95_breakloop; + goto _loop99_breakloop; } } -_loop95_breakloop: ; +_loop99_breakloop: ; } // ( ... )* match(RCURLY); mapInitializer_AST = (Spring.Expressions.SpringAST)currentAST.root; @@ -2398,9 +2360,9 @@ _loop95_breakloop: ; try { // for error handling match(POUND); - Spring.Expressions.FunctionNode tmp79_AST = null; - tmp79_AST = (Spring.Expressions.FunctionNode) astFactory.create(LT(1), "Spring.Expressions.FunctionNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp79_AST); + Spring.Expressions.FunctionNode tmp76_AST = null; + tmp76_AST = (Spring.Expressions.FunctionNode) astFactory.create(LT(1), "Spring.Expressions.FunctionNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp76_AST); match(ID); methodArgs(); if (0 == inputState.guessing) @@ -2433,9 +2395,9 @@ _loop95_breakloop: ; try { // for error handling match(POUND); - Spring.Expressions.VariableNode tmp81_AST = null; - tmp81_AST = (Spring.Expressions.VariableNode) astFactory.create(LT(1), "Spring.Expressions.VariableNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp81_AST); + Spring.Expressions.VariableNode tmp78_AST = null; + tmp78_AST = (Spring.Expressions.VariableNode) astFactory.create(LT(1), "Spring.Expressions.VariableNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp78_AST); match(ID); var_AST = (Spring.Expressions.SpringAST)currentAST.root; } @@ -2527,9 +2489,9 @@ _loop57_breakloop: ; try { // for error handling match(DOLLAR); - Spring.Expressions.LocalFunctionNode tmp86_AST = null; - tmp86_AST = (Spring.Expressions.LocalFunctionNode) astFactory.create(LT(1), "Spring.Expressions.LocalFunctionNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp86_AST); + Spring.Expressions.LocalFunctionNode tmp83_AST = null; + tmp83_AST = (Spring.Expressions.LocalFunctionNode) astFactory.create(LT(1), "Spring.Expressions.LocalFunctionNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp83_AST); match(ID); methodArgs(); if (0 == inputState.guessing) @@ -2562,9 +2524,9 @@ _loop57_breakloop: ; try { // for error handling match(DOLLAR); - Spring.Expressions.LocalVariableNode tmp88_AST = null; - tmp88_AST = (Spring.Expressions.LocalVariableNode) astFactory.create(LT(1), "Spring.Expressions.LocalVariableNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp88_AST); + Spring.Expressions.LocalVariableNode tmp85_AST = null; + tmp85_AST = (Spring.Expressions.LocalVariableNode) astFactory.create(LT(1), "Spring.Expressions.LocalVariableNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp85_AST); match(ID); localVar_AST = (Spring.Expressions.SpringAST)currentAST.root; } @@ -2591,9 +2553,9 @@ _loop57_breakloop: ; Spring.Expressions.SpringAST property_AST = null; try { // for error handling - Spring.Expressions.PropertyOrFieldNode tmp89_AST = null; - tmp89_AST = (Spring.Expressions.PropertyOrFieldNode) astFactory.create(LT(1), "Spring.Expressions.PropertyOrFieldNode"); - astFactory.addASTChild(ref currentAST, (AST)tmp89_AST); + Spring.Expressions.PropertyOrFieldNode tmp86_AST = null; + tmp86_AST = (Spring.Expressions.PropertyOrFieldNode) astFactory.create(LT(1), "Spring.Expressions.PropertyOrFieldNode"); + astFactory.addASTChild(ref currentAST, (AST)tmp86_AST); match(ID); property_AST = (Spring.Expressions.SpringAST)currentAST.root; } @@ -2650,33 +2612,50 @@ _loop57_breakloop: ; Spring.Expressions.SpringAST contextName_AST = null; try { // for error handling - Spring.Expressions.QualifiedIdentifier tmp90_AST = null; - tmp90_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp90_AST); - match(ID); - { // ( ... )* - for (;;) + if ((LA(1)==STRING_LITERAL)) + { + Spring.Expressions.SpringAST tmp87_AST = null; + tmp87_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp87_AST); + match(STRING_LITERAL); + contextName_AST = (Spring.Expressions.SpringAST)currentAST.root; + } + else if ((LA(1)==ID)) { + qualifiedId(); + if (0 == inputState.guessing) { - if ((LA(1)==DIV)) - { - Spring.Expressions.SpringAST tmp91_AST = null; - tmp91_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp91_AST); - match(DIV); - Spring.Expressions.SpringAST tmp92_AST = null; - tmp92_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp92_AST); - match(ID); - } - else - { - goto _loop110_breakloop; - } - + astFactory.addASTChild(ref currentAST, (AST)returnAST); } -_loop110_breakloop: ; - } // ( ... )* - contextName_AST = (Spring.Expressions.SpringAST)currentAST.root; + { // ( ... )* + for (;;) + { + if ((LA(1)==DIV)) + { + Spring.Expressions.SpringAST tmp88_AST = null; + tmp88_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp88_AST); + match(DIV); + qualifiedId(); + if (0 == inputState.guessing) + { + astFactory.addASTChild(ref currentAST, (AST)returnAST); + } + } + else + { + goto _loop63_breakloop; + } + + } +_loop63_breakloop: ; + } // ( ... )* + contextName_AST = (Spring.Expressions.SpringAST)currentAST.root; + } + else + { + throw new NoViableAltException(LT(1), getFilename()); + } + } catch (RecognitionException ex) { @@ -2701,31 +2680,31 @@ _loop110_breakloop: ; Spring.Expressions.SpringAST qualifiedId_AST = null; try { // for error handling - Spring.Expressions.QualifiedIdentifier tmp93_AST = null; - tmp93_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp93_AST); + Spring.Expressions.QualifiedIdentifier tmp89_AST = null; + tmp89_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp89_AST); match(ID); { // ( ... )* for (;;) { if ((LA(1)==DOT)) { - Spring.Expressions.SpringAST tmp94_AST = null; - tmp94_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp94_AST); + Spring.Expressions.SpringAST tmp90_AST = null; + tmp90_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp90_AST); match(DOT); - Spring.Expressions.SpringAST tmp95_AST = null; - tmp95_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp95_AST); + Spring.Expressions.SpringAST tmp91_AST = null; + tmp91_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp91_AST); match(ID); } else { - goto _loop107_breakloop; + goto _loop111_breakloop; } } -_loop107_breakloop: ; +_loop111_breakloop: ; } // ( ... )* qualifiedId_AST = (Spring.Expressions.SpringAST)currentAST.root; } @@ -2744,6 +2723,53 @@ _loop107_breakloop: ; returnAST = qualifiedId_AST; } + public void typename() //throws RecognitionException, TokenStreamException +{ + + returnAST = null; + ASTPair currentAST = new ASTPair(); + Spring.Expressions.SpringAST typename_AST = null; + + try { // for error handling + Spring.Expressions.QualifiedIdentifier tmp92_AST = null; + tmp92_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp92_AST); + match(ID); + { // ( ... )* + for (;;) + { + if ((tokenSet_17_.member(LA(1)))) + { + Spring.Expressions.SpringAST tmp93_AST = null; + tmp93_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp93_AST); + matchNot(RPAREN); + } + else + { + goto _loop76_breakloop; + } + + } +_loop76_breakloop: ; + } // ( ... )* + typename_AST = (Spring.Expressions.SpringAST)currentAST.root; + } + catch (RecognitionException ex) + { + if (0 == inputState.guessing) + { + reportError(ex); + recover(ex,tokenSet_18_); + } + else + { + throw ex; + } + } + returnAST = typename_AST; + } + public void ctorArgs() //throws RecognitionException, TokenStreamException { @@ -2775,11 +2801,11 @@ _loop107_breakloop: ; } else { - goto _loop100_breakloop; + goto _loop104_breakloop; } } -_loop100_breakloop: ; +_loop104_breakloop: ; } // ( ... )* } else if ((LA(1)==RPAREN)) { @@ -2817,9 +2843,9 @@ _loop100_breakloop: ; try { // for error handling { - Spring.Expressions.SpringAST tmp99_AST = null; - tmp99_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp99_AST); + Spring.Expressions.SpringAST tmp97_AST = null; + tmp97_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp97_AST); match(ID); { // ( ... )* for (;;) @@ -2827,18 +2853,18 @@ _loop100_breakloop: ; if ((LA(1)==COMMA)) { match(COMMA); - Spring.Expressions.SpringAST tmp101_AST = null; - tmp101_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp101_AST); + Spring.Expressions.SpringAST tmp99_AST = null; + tmp99_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp99_AST); match(ID); } else { - goto _loop80_breakloop; + goto _loop84_breakloop; } } -_loop80_breakloop: ; +_loop84_breakloop: ; } // ( ... )* } if (0==inputState.guessing) @@ -2859,7 +2885,7 @@ _loop80_breakloop: ; if (0 == inputState.guessing) { reportError(ex); - recover(ex,tokenSet_17_); + recover(ex,tokenSet_19_); } else { @@ -2942,9 +2968,9 @@ _loop80_breakloop: ; Spring.Expressions.SpringAST arrayRank_AST = null; try { // for error handling - Spring.Expressions.SpringAST tmp103_AST = null; - tmp103_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.makeASTRoot(ref currentAST, (AST)tmp103_AST); + Spring.Expressions.SpringAST tmp101_AST = null; + tmp101_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.makeASTRoot(ref currentAST, (AST)tmp101_AST); match(LBRACKET); { if ((tokenSet_8_.member(LA(1)))) @@ -2968,11 +2994,11 @@ _loop80_breakloop: ; } else { - goto _loop89_breakloop; + goto _loop93_breakloop; } } -_loop89_breakloop: ; +_loop93_breakloop: ; } // ( ... )* } else if ((LA(1)==RBRACKET)) { @@ -2991,7 +3017,7 @@ _loop89_breakloop: ; if (0 == inputState.guessing) { reportError(ex); - recover(ex,tokenSet_18_); + recover(ex,tokenSet_20_); } else { @@ -3038,7 +3064,7 @@ _loop89_breakloop: ; if (0 == inputState.guessing) { reportError(ex); - recover(ex,tokenSet_19_); + recover(ex,tokenSet_21_); } else { @@ -3056,11 +3082,11 @@ _loop89_breakloop: ; Spring.Expressions.SpringAST namedArgument_AST = null; try { // for error handling - bool synPredMatched104 = false; + bool synPredMatched108 = false; if (((LA(1)==ID) && (LA(2)==ASSIGN))) { - int _m104 = mark(); - synPredMatched104 = true; + int _m108 = mark(); + synPredMatched108 = true; inputState.guessing++; try { { @@ -3070,16 +3096,16 @@ _loop89_breakloop: ; } catch (RecognitionException) { - synPredMatched104 = false; + synPredMatched108 = false; } - rewind(_m104); + rewind(_m108); inputState.guessing--; } - if ( synPredMatched104 ) + if ( synPredMatched108 ) { - Spring.Expressions.NamedArgumentNode tmp107_AST = null; - tmp107_AST = (Spring.Expressions.NamedArgumentNode) astFactory.create(LT(1), "Spring.Expressions.NamedArgumentNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp107_AST); + Spring.Expressions.NamedArgumentNode tmp105_AST = null; + tmp105_AST = (Spring.Expressions.NamedArgumentNode) astFactory.create(LT(1), "Spring.Expressions.NamedArgumentNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp105_AST); match(ID); match(ASSIGN); expression(); @@ -3089,7 +3115,7 @@ _loop89_breakloop: ; } namedArgument_AST = (Spring.Expressions.SpringAST)currentAST.root; } - else if ((tokenSet_8_.member(LA(1))) && (tokenSet_20_.member(LA(2)))) { + else if ((tokenSet_8_.member(LA(1))) && (tokenSet_22_.member(LA(2)))) { argument(); if (0 == inputState.guessing) { @@ -3108,7 +3134,7 @@ _loop89_breakloop: ; if (0 == inputState.guessing) { reportError(ex); - recover(ex,tokenSet_21_); + recover(ex,tokenSet_23_); } else { @@ -3128,16 +3154,16 @@ _loop89_breakloop: ; try { // for error handling if ((LA(1)==TRUE)) { - Spring.Expressions.BooleanLiteralNode tmp109_AST = null; - tmp109_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST)tmp109_AST); + Spring.Expressions.BooleanLiteralNode tmp107_AST = null; + tmp107_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); + astFactory.addASTChild(ref currentAST, (AST)tmp107_AST); match(TRUE); boolLiteral_AST = (Spring.Expressions.SpringAST)currentAST.root; } else if ((LA(1)==FALSE)) { - Spring.Expressions.BooleanLiteralNode tmp110_AST = null; - tmp110_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST)tmp110_AST); + Spring.Expressions.BooleanLiteralNode tmp108_AST = null; + tmp108_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); + astFactory.addASTChild(ref currentAST, (AST)tmp108_AST); match(FALSE); boolLiteral_AST = (Spring.Expressions.SpringAST)currentAST.root; } @@ -3170,22 +3196,22 @@ _loop89_breakloop: ; Spring.Expressions.SpringAST dateLiteral_AST = null; try { // for error handling - Spring.Expressions.DateLiteralNode tmp111_AST = null; - tmp111_AST = (Spring.Expressions.DateLiteralNode) astFactory.create(LT(1), "Spring.Expressions.DateLiteralNode"); - astFactory.makeASTRoot(ref currentAST, (AST)tmp111_AST); + Spring.Expressions.DateLiteralNode tmp109_AST = null; + tmp109_AST = (Spring.Expressions.DateLiteralNode) astFactory.create(LT(1), "Spring.Expressions.DateLiteralNode"); + astFactory.makeASTRoot(ref currentAST, (AST)tmp109_AST); match(LITERAL_date); match(LPAREN); - Spring.Expressions.SpringAST tmp113_AST = null; - tmp113_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp113_AST); + Spring.Expressions.SpringAST tmp111_AST = null; + tmp111_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp111_AST); match(STRING_LITERAL); { if ((LA(1)==COMMA)) { match(COMMA); - Spring.Expressions.SpringAST tmp115_AST = null; - tmp115_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST)tmp115_AST); + Spring.Expressions.SpringAST tmp113_AST = null; + tmp113_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); + astFactory.addASTChild(ref currentAST, (AST)tmp113_AST); match(STRING_LITERAL); } else if ((LA(1)==RPAREN)) { @@ -3229,7 +3255,7 @@ _loop89_breakloop: ; } static public void initializeASTFactory( ASTFactory factory ) { - factory.setMaxNodeType(68); + factory.setMaxNodeType(71); } public static readonly string[] tokenNames_ = new string[] { @@ -3269,6 +3295,7 @@ _loop89_breakloop: ; @"""DOLLAR""", @"""COMMA""", @"""AT""", + @"""STRING_LITERAL""", @"""LBRACKET""", @"""RBRACKET""", @"""PROJECT""", @@ -3284,7 +3311,6 @@ _loop89_breakloop: ; @"""INTEGER_LITERAL""", @"""HEXADECIMAL_INTEGER_LITERAL""", @"""REAL_LITERAL""", - @"""STRING_LITERAL""", @"""date""", @"""EQUAL""", @"""NOT_EQUAL""", @@ -3293,7 +3319,10 @@ _loop89_breakloop: ; @"""GREATER_THAN""", @"""GREATER_THAN_OR_EQUAL""", @"""WS""", + @"""BACKTICK""", + @"""BACKSLASH""", @"""DOT_ESCAPED""", + @"""QUOTE""", @"""APOS""", @"""NUMERIC_LITERAL""", @"""DECIMAL_DIGIT""", @@ -3312,25 +3341,25 @@ _loop89_breakloop: ; public static readonly BitSet tokenSet_0_ = new BitSet(mk_tokenSet_0_()); private static long[] mk_tokenSet_1_() { - long[] data = { 704379224066L, 0L}; + long[] data = { 1391573991426L, 0L}; return data; } public static readonly BitSet tokenSet_1_ = new BitSet(mk_tokenSet_1_()); private static long[] mk_tokenSet_2_() { - long[] data = { 567462303507644162L, 0L}; + long[] data = { 567471030881189634L, 0L}; return data; } public static readonly BitSet tokenSet_2_ = new BitSet(mk_tokenSet_2_()); private static long[] mk_tokenSet_3_() { - long[] data = { 704382894082L, 0L}; + long[] data = { 1391577661442L, 0L}; return data; } public static readonly BitSet tokenSet_3_ = new BitSet(mk_tokenSet_3_()); private static long[] mk_tokenSet_4_() { - long[] data = { 704382894594L, 0L}; + long[] data = { 1391577661954L, 0L}; return data; } public static readonly BitSet tokenSet_4_ = new BitSet(mk_tokenSet_4_()); @@ -3342,55 +3371,55 @@ _loop89_breakloop: ; public static readonly BitSet tokenSet_5_ = new BitSet(mk_tokenSet_5_()); private static long[] mk_tokenSet_6_() { - long[] data = { 704382894850L, 0L}; + long[] data = { 1391577662210L, 0L}; return data; } public static readonly BitSet tokenSet_6_ = new BitSet(mk_tokenSet_6_()); private static long[] mk_tokenSet_7_() { - long[] data = { 567454257431609090L, 0L}; + long[] data = { 567454944626376450L, 0L}; return data; } public static readonly BitSet tokenSet_7_ = new BitSet(mk_tokenSet_7_()); private static long[] mk_tokenSet_8_() { - long[] data = { 8971308922667200L, 0L}; + long[] data = { 8935437355811008L, 0L}; return data; } public static readonly BitSet tokenSet_8_ = new BitSet(mk_tokenSet_8_()); private static long[] mk_tokenSet_9_() { - long[] data = { 567454257456774914L, 0L}; + long[] data = { 567454944651542274L, 0L}; return data; } public static readonly BitSet tokenSet_9_ = new BitSet(mk_tokenSet_9_()); private static long[] mk_tokenSet_10_() { - long[] data = { 567454257691655938L, 0L}; + long[] data = { 567454944886423298L, 0L}; return data; } public static readonly BitSet tokenSet_10_ = new BitSet(mk_tokenSet_10_()); private static long[] mk_tokenSet_11_() { - long[] data = { 8971308360630464L, 0L}; + long[] data = { 8935436793774272L, 0L}; return data; } public static readonly BitSet tokenSet_11_ = new BitSet(mk_tokenSet_11_()); private static long[] mk_tokenSet_12_() { - long[] data = { 567454257960091394L, 0L}; + long[] data = { 567454945154858754L, 0L}; return data; } public static readonly BitSet tokenSet_12_ = new BitSet(mk_tokenSet_12_()); private static long[] mk_tokenSet_13_() { - long[] data = { 8045547552768L, 0L}; + long[] data = { 16085726330880L, 0L}; return data; } public static readonly BitSet tokenSet_13_ = new BitSet(mk_tokenSet_13_()); private static long[] mk_tokenSet_14_() { - long[] data = { 154619084800L, 0L}; + long[] data = { 292058038272L, 0L}; return data; } public static readonly BitSet tokenSet_14_ = new BitSet(mk_tokenSet_14_()); @@ -3402,40 +3431,52 @@ _loop89_breakloop: ; public static readonly BitSet tokenSet_15_ = new BitSet(mk_tokenSet_15_()); private static long[] mk_tokenSet_16_() { - long[] data = { 223338627072L, 0L}; + long[] data = { 412388491264L, 0L}; return data; } public static readonly BitSet tokenSet_16_ = new BitSet(mk_tokenSet_16_()); private static long[] mk_tokenSet_17_() { - long[] data = { 35184372088832L, 0L}; + long[] data = { -262160L, 255L, 0L, 0L}; return data; } public static readonly BitSet tokenSet_17_ = new BitSet(mk_tokenSet_17_()); private static long[] mk_tokenSet_18_() { - long[] data = { 567603040995999490L, 0L}; + long[] data = { 262144L, 0L}; return data; } public static readonly BitSet tokenSet_18_ = new BitSet(mk_tokenSet_18_()); private static long[] mk_tokenSet_19_() { - long[] data = { 566935683072L, 0L}; + long[] data = { 70368744177664L, 0L}; return data; } public static readonly BitSet tokenSet_19_ = new BitSet(mk_tokenSet_19_()); private static long[] mk_tokenSet_20_() { - long[] data = { 576460065104330688L, 0L}; + long[] data = { 567752505857900290L, 0L}; return data; } public static readonly BitSet tokenSet_20_ = new BitSet(mk_tokenSet_20_()); private static long[] mk_tokenSet_21_() { - long[] data = { 17180131328L, 0L}; + long[] data = { 1116691496960L, 0L}; return data; } public static readonly BitSet tokenSet_21_ = new BitSet(mk_tokenSet_21_()); + private static long[] mk_tokenSet_22_() + { + long[] data = { 576459377909563328L, 0L}; + return data; + } + public static readonly BitSet tokenSet_22_ = new BitSet(mk_tokenSet_22_()); + private static long[] mk_tokenSet_23_() + { + long[] data = { 17180131328L, 0L}; + return data; + } + public static readonly BitSet tokenSet_23_ = new BitSet(mk_tokenSet_23_()); } } diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs index 1f47e89a..af698c55 100644 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs +++ b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs @@ -38,22 +38,22 @@ namespace Spring.Expressions public const int DOLLAR = 33; public const int COMMA = 34; public const int AT = 35; - public const int LBRACKET = 36; - public const int RBRACKET = 37; - public const int PROJECT = 38; - public const int RCURLY = 39; - public const int SELECT = 40; - public const int SELECT_FIRST = 41; - public const int SELECT_LAST = 42; - public const int TYPE = 43; - public const int LAMBDA = 44; - public const int PIPE = 45; - public const int LITERAL_new = 46; - public const int LCURLY = 47; - public const int INTEGER_LITERAL = 48; - public const int HEXADECIMAL_INTEGER_LITERAL = 49; - public const int REAL_LITERAL = 50; - public const int STRING_LITERAL = 51; + public const int STRING_LITERAL = 36; + public const int LBRACKET = 37; + public const int RBRACKET = 38; + public const int PROJECT = 39; + public const int RCURLY = 40; + public const int SELECT = 41; + public const int SELECT_FIRST = 42; + public const int SELECT_LAST = 43; + public const int TYPE = 44; + public const int LAMBDA = 45; + public const int PIPE = 46; + public const int LITERAL_new = 47; + public const int LCURLY = 48; + public const int INTEGER_LITERAL = 49; + public const int HEXADECIMAL_INTEGER_LITERAL = 50; + public const int REAL_LITERAL = 51; public const int LITERAL_date = 52; public const int EQUAL = 53; public const int NOT_EQUAL = 54; @@ -62,15 +62,18 @@ namespace Spring.Expressions public const int GREATER_THAN = 57; public const int GREATER_THAN_OR_EQUAL = 58; public const int WS = 59; - public const int DOT_ESCAPED = 60; - public const int APOS = 61; - public const int NUMERIC_LITERAL = 62; - public const int DECIMAL_DIGIT = 63; - public const int INTEGER_TYPE_SUFFIX = 64; - public const int HEX_DIGIT = 65; - public const int EXPONENT_PART = 66; - public const int SIGN = 67; - public const int REAL_TYPE_SUFFIX = 68; + public const int BACKTICK = 60; + public const int BACKSLASH = 61; + public const int DOT_ESCAPED = 62; + public const int QUOTE = 63; + public const int APOS = 64; + public const int NUMERIC_LITERAL = 65; + public const int DECIMAL_DIGIT = 66; + public const int INTEGER_TYPE_SUFFIX = 67; + public const int HEX_DIGIT = 68; + public const int EXPONENT_PART = 69; + public const int SIGN = 70; + public const int REAL_TYPE_SUFFIX = 71; } } diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt index 5e36c13e..245f3efe 100644 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt +++ b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt @@ -32,22 +32,22 @@ ID=32 DOLLAR=33 COMMA=34 AT=35 -LBRACKET=36 -RBRACKET=37 -PROJECT=38 -RCURLY=39 -SELECT=40 -SELECT_FIRST=41 -SELECT_LAST=42 -TYPE=43 -LAMBDA=44 -PIPE=45 -LITERAL_new="new"=46 -LCURLY=47 -INTEGER_LITERAL=48 -HEXADECIMAL_INTEGER_LITERAL=49 -REAL_LITERAL=50 -STRING_LITERAL=51 +STRING_LITERAL=36 +LBRACKET=37 +RBRACKET=38 +PROJECT=39 +RCURLY=40 +SELECT=41 +SELECT_FIRST=42 +SELECT_LAST=43 +TYPE=44 +LAMBDA=45 +PIPE=46 +LITERAL_new="new"=47 +LCURLY=48 +INTEGER_LITERAL=49 +HEXADECIMAL_INTEGER_LITERAL=50 +REAL_LITERAL=51 LITERAL_date="date"=52 EQUAL=53 NOT_EQUAL=54 @@ -56,12 +56,15 @@ LESS_THAN_OR_EQUAL=56 GREATER_THAN=57 GREATER_THAN_OR_EQUAL=58 WS=59 -DOT_ESCAPED=60 -APOS=61 -NUMERIC_LITERAL=62 -DECIMAL_DIGIT=63 -INTEGER_TYPE_SUFFIX=64 -HEX_DIGIT=65 -EXPONENT_PART=66 -SIGN=67 -REAL_TYPE_SUFFIX=68 +BACKTICK=60 +BACKSLASH=61 +DOT_ESCAPED=62 +QUOTE=63 +APOS=64 +NUMERIC_LITERAL=65 +DECIMAL_DIGIT=66 +INTEGER_TYPE_SUFFIX=67 +HEX_DIGIT=68 +EXPONENT_PART=69 +SIGN=70 +REAL_TYPE_SUFFIX=71 diff --git a/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs b/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs index 04cf208f..27cd2cae 100644 --- a/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs +++ b/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs @@ -1,5 +1,5 @@ -#region License - +#region License + /* * Copyright © 2002-2005 the original author or authors. * @@ -14,84 +14,86 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - -#endregion - -using System; -using System.Runtime.Serialization; -using antlr.collections; - -namespace Spring.Expressions -{ - /// - /// Represents parsed named argument node in the expression. - /// - /// Aleksandar Seovic - [Serializable] - public class QualifiedIdentifier : BaseNode - { - private const string ESCAPE_CHAR = "\\"; - - private string identifier; - - /// - /// Create a new instance - /// - public QualifiedIdentifier():base() - { - } - - /// - /// Create a new instance from SerializationInfo - /// - protected QualifiedIdentifier(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - - /// - /// Returns the value of the named argument defined by this node. - /// - /// Context to evaluate expressions against. - /// Current expression evaluation context. - /// Node's value. - protected override object Get(object context, EvaluationContext evalContext) - { - if (identifier == null) - { - lock (this) - { - if (identifier == null) - { - identifier = base.getText(); - if (identifier != null) - { - identifier = identifier.Replace(ESCAPE_CHAR,""); // remove all occurrences of escape char - } - AST node = this.getFirstChild(); - while (node != null) - { - identifier += node.getText(); - node = node.getNextSibling(); - } - } - } - } - - return identifier; - } - - /// - /// Overrides getText to allow easy way to get fully - /// qualified identifier. - /// - /// - /// Fully qualified identifier as a string. - /// - public override string getText() - { - return (string) Get(null, null); - } - } + */ + +#endregion + +using System; +using System.Runtime.Serialization; +using antlr.collections; + +namespace Spring.Expressions +{ + /// + /// Represents parsed named argument node in the expression. + /// + /// Aleksandar Seovic + [Serializable] + public class QualifiedIdentifier : BaseNode + { + private const string ESCAPE_CHAR = "\\"; + + private string identifier; + + /// + /// Create a new instance + /// + public QualifiedIdentifier() + : base() + { + } + + /// + /// Create a new instance from SerializationInfo + /// + protected QualifiedIdentifier(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + /// + /// Returns the value of the named argument defined by this node. + /// + /// Context to evaluate expressions against. + /// Current expression evaluation context. + /// Node's value. + protected override object Get(object context, EvaluationContext evalContext) + { + if (identifier == null) + { + lock (this) + { + if (identifier == null) + { + identifier = this.getText(); + } + } + } + + return identifier; + } + + /// + /// Overrides getText to allow easy way to get fully + /// qualified identifier. + /// + /// + /// Fully qualified identifier as a string. + /// + public override string getText() + { + string tmp = base.getText(); + if (tmp != null) + { + tmp = tmp.Replace(ESCAPE_CHAR, ""); // remove all occurrences of escape char + } + AST node = this.getFirstChild(); + while (node != null) + { + tmp = string.Concat(tmp, node.getText()); + node = node.getNextSibling(); + } + return tmp; + } + } } \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/TypeNode.cs b/src/Spring/Spring.Core/Expressions/TypeNode.cs index 1808d53d..d6d15f4f 100644 --- a/src/Spring/Spring.Core/Expressions/TypeNode.cs +++ b/src/Spring/Spring.Core/Expressions/TypeNode.cs @@ -1,5 +1,5 @@ -#region License - +#region License + /* * Copyright © 2002-2005 the original author or authors. * @@ -14,70 +14,87 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - -#endregion - -using System; -using System.Runtime.Serialization; - -using antlr.collections; -using Spring.Core.TypeResolution; - -namespace Spring.Expressions -{ - /// - /// Represents parsed type node in the navigation expression. - /// - /// Aleksandar Seovic - [Serializable] - public class TypeNode : BaseNode - { - private Type type; - - /// - /// Create a new instance - /// - public TypeNode():base() - { - } - - /// - /// Create a new instance from SerializationInfo - /// - protected TypeNode(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - - /// - /// Returns node's value for the given context. - /// - /// Context to evaluate expressions against. - /// Current expression evaluation context. - /// Node's value. - protected override object Get(object context, EvaluationContext evalContext) - { - if (type == null) - { - lock (this) - { - if (type == null) - { - string typeName = this.getText(); - AST node = this.getFirstChild(); - while (node != null) - { - typeName += node.getText(); - node = node.getNextSibling(); - } - - type = TypeResolutionUtils.ResolveType(typeName); - } - } - } - - return type; - } - } + */ + +#endregion + +using System; +using System.Runtime.Serialization; + +using antlr.collections; +using Spring.Core.TypeResolution; + +namespace Spring.Expressions +{ + /// + /// Represents parsed type node in the navigation expression. + /// + /// Aleksandar Seovic + [Serializable] + public class TypeNode : BaseNode + { + private Type type; + + /// + /// Create a new instance + /// + public TypeNode() + : base() + { + } + + /// + /// Create a new instance from SerializationInfo + /// + protected TypeNode(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + /// + /// Returns node's value for the given context. + /// + /// Context to evaluate expressions against. + /// Current expression evaluation context. + /// Node's value. + protected override object Get(object context, EvaluationContext evalContext) + { + if (type == null) + { + lock(this) + { + type = TypeResolutionUtils.ResolveType(getText()); + } + } + + return type; + } + + /// + /// Overrides getText to allow easy way to get fully + /// qualified typename. + /// + /// + /// Fully qualified typename as a string. + /// + public override string getText() + { + string tmp = base.getText(); +// if (tmp != null && TypeRegistry.ContainsAlias(tmp)) +// { +// Type type = TypeRegistry.ResolveType(tmp); +// if (type != null) +// { +// tmp = type.AssemblyQualifiedName; +// } +// } + AST node = this.getFirstChild(); + while (node != null) + { + tmp += node.getText(); + node = node.getNextSibling(); + } + return tmp; + } + } } \ No newline at end of file diff --git a/src/Spring/Spring.Core/Spring.Core.2008.csproj b/src/Spring/Spring.Core/Spring.Core.2008.csproj index 8d34df10..ee55c3ad 100644 --- a/src/Spring/Spring.Core/Spring.Core.2008.csproj +++ b/src/Spring/Spring.Core/Spring.Core.2008.csproj @@ -1,7 +1,7 @@  Local - 9.0.21022 + 9.0.30729 2.0 {710961A3-0DF4-49E4-A26E-F5B9C044AC84} Debug @@ -1121,7 +1121,7 @@ - rem $(ProjectDir)..\..\..\build-support\tools\antlr-2.7.6\antlr-2.7.6.exe -o $(ProjectDir)Expressions\Parser $(ProjectDir)Expressions\Expression.g + $(ProjectDir)..\..\..\build-support\tools\antlr-2.7.6\antlr-2.7.6.exe -o $(ProjectDir)Expressions\Parser $(ProjectDir)Expressions\Expression.g diff --git a/src/Spring/Spring.Core/Util/StringUtils.cs b/src/Spring/Spring.Core/Util/StringUtils.cs index 279168ab..90b8232d 100644 --- a/src/Spring/Spring.Core/Util/StringUtils.cs +++ b/src/Spring/Spring.Core/Util/StringUtils.cs @@ -1,5 +1,5 @@ -#region License - +#region License + /* * Copyright © 2002-2005 the original author or authors. * @@ -14,561 +14,685 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - -#endregion - -#region Imports - -using System; -using System.Collections; -using System.Globalization; -using System.Text; - -#endregion - -namespace Spring.Util -{ - /// - /// Miscellaneous utility methods. - /// - /// - ///

- /// Mainly for internal use within the framework. - ///

- ///
- /// Rod Johnson - /// Juergen Hoeller - /// Keith Donald - /// Aleksandar Seovic (.NET) - /// Mark Pollack (.NET) - /// Rick Evans (.NET) - public sealed class StringUtils - { - /// - /// An empty array of instances. - /// - public static readonly string[] EmptyStrings = new string[] {}; - - /// - /// The string that signals the start of an Ant-style expression. - /// - private const string AntExpressionPrefix = "${"; - - /// - /// The string that signals the end of an Ant-style expression. - /// - private const string AntExpressionSuffix = "}"; - - #region Constructor (s) / Destructor - - // CLOVER:OFF - - /// - /// Creates a new instance of the class. - /// - /// - ///

- /// This is a utility class, and as such exposes no public constructors. - ///

- ///
- private StringUtils() - { - } - - // CLOVER:ON - - #endregion - - /// - /// Tokenize the given into a - /// array. - /// - /// - ///

- /// If is , returns an empty - /// array. - ///

- ///

- /// If is or the empty - /// , returns a array with one - /// element: itself. - ///

- ///
- /// The to tokenize. - /// - /// The delimiter characters, assembled as a . - /// - /// - /// Trim the tokens via . - /// - /// - /// Omit empty tokens from the result array. - /// An array of the tokens. - public static string[] Split( - string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens) - { - if (s == null) - { - return new string[0]; - } - if (StringUtils.IsNullOrEmpty(delimiters)) - { - return new string[] {s}; - } - string[] tmp = s.Split(delimiters.ToCharArray()); - // short circuit if String.Split default behavior is ok - if (!trimTokens && !ignoreEmptyTokens) - { - return tmp; - } - else - { - ArrayList tokens = new ArrayList(tmp.Length); - for (int i = 0; i < tmp.Length; ++i) - { - string token = (trimTokens ? tmp[i].Trim() : tmp[i]); - if (!(ignoreEmptyTokens && token.Length == 0)) - { - tokens.Add(token); - } - } - return (string[]) tokens.ToArray(typeof (string)); - } - } - - /// - /// Convert a CSV list into an array of s. - /// - /// A CSV list. - /// - /// An array of s, or the empty array - /// if is . - /// - public static string[] CommaDelimitedListToStringArray(string s) - { - return DelimitedListToStringArray(s, ","); - } - - /// - /// Take a which is a delimited list - /// and convert it to a array. - /// - /// - ///

- /// If the supplied is a - /// or zero-length string, then a single element - /// array composed of the supplied - /// will be - /// eturned. If the supplied - /// is , then an empty, - /// zero-length array will be returned. - ///

- ///
- /// - /// The to be parsed. - /// - /// - /// The delimeter (this will not be returned). Note that only the first - /// character of the supplied is used. - /// - /// - /// An array of the tokens in the list. - /// - public static string[] DelimitedListToStringArray(string input, string delimiter) - { - if (input == null) - { - return new string[0]; - } - if (!HasLength(delimiter)) - { - return new string[] {input}; - } - return input.Split(delimiter[0]); - } - - /// - /// Convenience method to return an - /// as a delimited - /// (e.g. CSV) . - /// - /// - /// The to parse. - /// - /// - /// The delimiter to use (probably a ','). - /// - /// The delimited string representation. - public static string CollectionToDelimitedString( - ICollection c, string delimiter) - { - if (c == null) - { - return "null"; - } - StringBuilder sb = new StringBuilder(); - int i = 0; - foreach (object obj in c) - { - if (i++ > 0) - { - sb.Append(delimiter); - } - sb.Append(obj); - } - return sb.ToString(); - } - - /// - /// Convenience method to return an - /// as a CSV - /// . - /// - /// - /// The to display. - /// - /// The delimited string representation. - public static string CollectionToCommaDelimitedString( - ICollection collection) - { - return CollectionToDelimitedString(collection, ","); - } - - /// - /// Convenience method to return an array as a CSV - /// . - /// - /// - /// The array to parse. Elements may be of any type ( - /// will be called on each - /// element). - /// - public static string ArrayToCommaDelimitedString(object[] source) - { - return ArrayToDelimitedString(source, ","); - } - - /// - /// Convenience method to return a - /// array as a delimited (e.g. CSV) . - /// - /// - /// The array to parse. Elements may be of any type ( - /// will be called on each - /// element). - /// - /// - /// The delimiter to use (probably a ','). - /// - public static string ArrayToDelimitedString( - object[] source, string delimiter) - { - if (source == null) - { - return "null"; - } - else - { - return StringUtils.CollectionToDelimitedString(source, delimiter); - } - } - - /// Checks if a string has length. - /// - /// The string to check, may be . - /// - /// - /// if the string has length and is not - /// . - /// - /// - /// - /// StringUtils.HasLength(null) = false - /// StringUtils.HasLength("") = false - /// StringUtils.HasLength(" ") = true - /// StringUtils.HasLength("Hello") = true - /// - /// - public static bool HasLength(string target) - { - return (target != null && target.Length > 0); - } - - /// - /// Checks if a has text. - /// - /// - ///

- /// More specifically, returns if the string is - /// not , it's is > - /// zero (0), and it has at least one non-whitespace character. - ///

- ///
- /// - /// The string to check, may be . - /// - /// - /// if the is not - /// , - /// > zero (0), and does not consist - /// solely of whitespace. - /// - /// - /// - /// StringUtils.HasText(null) = false - /// StringUtils.HasText("") = false - /// StringUtils.HasText(" ") = false - /// StringUtils.HasText("12345") = true - /// StringUtils.HasText(" 12345 ") = true - /// - /// - public static bool HasText(string target) - { - if (target == null) - { - return false; - } - else - { - return HasLength(target.Trim()); - } - } - - /// - /// Checks if a is - /// or an empty string. - /// - /// - ///

- /// More specifically, returns if the string is - /// , it's is equal - /// to zero (0), or it is composed entirely of whitespace - /// characters. - ///

- ///
- /// - /// The string to check, may (obviously) be . - /// - /// - /// if the is - /// , has a length equal to zero (0), or - /// is composed entirely of whitespace characters. - /// - /// - /// - /// StringUtils.IsNullOrEmpty(null) = true - /// StringUtils.IsNullOrEmpty("") = true - /// StringUtils.IsNullOrEmpty(" ") = true - /// StringUtils.IsNullOrEmpty("12345") = false - /// StringUtils.IsNullOrEmpty(" 12345 ") = false - /// - /// - public static bool IsNullOrEmpty(string target) - { - return !HasText(target); - } - - /// - /// Strips first and last character off the string. - /// - /// The string to strip. - /// The stripped string. - public static string StripFirstAndLastCharacter(string text) - { - if (text != null - && text.Length > 2) - { - return text.Substring(1, text.Length - 2); - } - else - { - return String.Empty; - } - } - - /// - /// Returns a list of Ant-style expressions from the specified text. - /// - /// The text to inspect. - /// - /// A list of expressions that exist in the specified text. - /// - /// - /// If any of the expressions in the supplied - /// is empty (${}). - /// - public static IList GetAntExpressions(string text) - { - IList expressions = new ArrayList(); - if (StringUtils.HasText(text)) - { - int start = text.IndexOf(AntExpressionPrefix); - while (start >= 0) - { - int end = text.IndexOf(AntExpressionSuffix, start + 2); - if (end == -1) - { - // terminator character not found, so let's quit... - start = -1; - } - else - { - string exp = text.Substring(start + 2, end - start - 2); - if(StringUtils.IsNullOrEmpty(exp)) - { - throw new FormatException( - string.Format("Empty {0}{1} value found in text : '{2}'.", - AntExpressionPrefix, - AntExpressionSuffix, - text)); - } - if (expressions.IndexOf(exp) < 0) - { - expressions.Add(exp); - } - start = text.IndexOf(AntExpressionPrefix, end); - } - } - } - return expressions; - } - - /// - /// Replaces Ant-style expression placeholder with expression value. - /// - /// - ///

- /// - ///

- ///
- /// The string to set the value in. - /// The name of the expression to set. - /// The expression value. - /// - /// A new string with the expression value set; the - /// value if the supplied - /// is , has a length - /// equal to zero (0), or is composed entirely of whitespace - /// characters. - /// - public static string SetAntExpression(string text, string expression, object expValue) - { - if (StringUtils.IsNullOrEmpty(text)) - { - return String.Empty; - } - if (expValue == null) - { - expValue = String.Empty; - } - return text.Replace( - StringUtils.Surround(AntExpressionPrefix, expression, AntExpressionSuffix), expValue.ToString()); - } - - /// - /// Surrounds (prepends and appends) the string value of the supplied - /// to the supplied . - /// - /// - ///

- /// The return value of this method call is always guaranteed to be non - /// . If every value passed as a parameter to this method is - /// , the string will be returned. - ///

- ///
- /// - /// The prefix and suffix that respectively will be prepended and - /// appended to the target . If this value - /// is not a value, it's attendant - /// value will be used. - /// - /// - /// The target that is to be surrounded. If this value is not a - /// value, it's attendant - /// value will be used. - /// - /// The surrounded string. - public static string Surround(object fix, object target) - { - return StringUtils.Surround(fix, target, fix); - } - - /// - /// Surrounds (prepends and appends) the string values of the supplied - /// and to the supplied - /// . - /// - /// - ///

- /// The return value of this method call is always guaranteed to be non - /// . If every value passed as a parameter to this method is - /// , the string will be returned. - ///

- ///
- /// - /// The value that will be prepended to the . If this value - /// is not a value, it's attendant - /// value will be used. - /// - /// - /// The target that is to be surrounded. If this value is not a - /// value, it's attendant - /// value will be used. - /// - /// - /// The value that will be appended to the . If this value - /// is not a value, it's attendant - /// value will be used. - /// - /// The surrounded string. - public static string Surround(object prefix, object target, object suffix) - { - return string.Format( - CultureInfo.InvariantCulture, "{0}{1}{2}", prefix, target, suffix); - } - - /// - /// Converts escaped characters (for example "\t") within a string - /// to their real character. - /// - /// The string to convert. - /// The converted string. - public static string ConvertEscapedCharacters( string inputString ) - { - StringBuilder sb = new StringBuilder(inputString.Length); - for (int i = 0 ; i < inputString.Length ; i++) - { - if (inputString[i].Equals('\\')) - { - i++; - if (inputString[i].Equals('t')) - { - sb.Append('\t'); - } - else if (inputString[i].Equals('r')) - { - sb.Append('\r'); - } - else if (inputString[i].Equals('n')) - { - sb.Append('\n'); - } - else if (inputString[i].Equals('\\')) - { - sb.Append('\\'); - } - else - { - sb.Append("\\" + inputString[i]); - } - } - else - { - sb.Append(inputString[i]); - } - } - return sb.ToString(); - } - } + */ + +#endregion + +#region Imports + +using System; +using System.Collections; +using System.Globalization; +using System.Text; + +#endregion + +namespace Spring.Util +{ + /// + /// Miscellaneous utility methods. + /// + /// + ///

+ /// Mainly for internal use within the framework. + ///

+ ///
+ /// Rod Johnson + /// Juergen Hoeller + /// Keith Donald + /// Aleksandar Seovic (.NET) + /// Mark Pollack (.NET) + /// Rick Evans (.NET) + /// Erich Eichinger (.NET) + public sealed class StringUtils + { + /// + /// An empty array of instances. + /// + public static readonly string[] EmptyStrings = new string[] { }; + + /// + /// The string that signals the start of an Ant-style expression. + /// + private const string AntExpressionPrefix = "${"; + + /// + /// The string that signals the end of an Ant-style expression. + /// + private const string AntExpressionSuffix = "}"; + + #region Constructor (s) / Destructor + + // CLOVER:OFF + + /// + /// Creates a new instance of the class. + /// + /// + ///

+ /// This is a utility class, and as such exposes no public constructors. + ///

+ ///
+ private StringUtils() + { + } + + // CLOVER:ON + + #endregion + + /// + /// Tokenize the given into a + /// array. + /// + /// + ///

+ /// If is , returns an empty + /// array. + ///

+ ///

+ /// If is or the empty + /// , returns a array with one + /// element: itself. + ///

+ ///
+ /// The to tokenize. + /// + /// The delimiter characters, assembled as a . + /// + /// + /// Trim the tokens via . + /// + /// + /// Omit empty tokens from the result array. + /// An array of the tokens. + public static string[] Split( + string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens) + { + return Split(s, delimiters, trimTokens, ignoreEmptyTokens, null); + } + + /// + /// Tokenize the given into a + /// array. + /// + /// + ///

+ /// If is , returns an empty + /// array. + ///

+ ///

+ /// If is or the empty + /// , returns a array with one + /// element: itself. + ///

+ ///
+ /// The to tokenize. + /// + /// The delimiter characters, assembled as a . + /// + /// + /// Trim the tokens via . + /// + /// + /// Omit empty tokens from the result array. + /// + /// + /// Pairs of quote characters. within a pair of quotes are ignored + /// + /// An array of the tokens. + public static string[] Split( + string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens, string quoteChars) + { + if (s == null) + { + return new string[0]; + } + if (delimiters==null || delimiters.Length==0) + { + return new string[] { s }; + } + if (quoteChars == null) + { + quoteChars = string.Empty; + } + AssertUtils.IsTrue( quoteChars.Length % 2 == 0, "the number of quote characters must be even" ); + + char[] delimiterChars = delimiters.ToCharArray(); + + // scan separator positions + int[] delimiterPositions = new int[s.Length]; + int count = MakeDelimiterPositionList(s, delimiterChars, quoteChars, delimiterPositions); + + ArrayList tokens = new ArrayList(count+1); + int startIndex = 0; + for (int ixSep = 0; ixSep < count; ixSep++) + { + string token = s.Substring(startIndex, delimiterPositions[ixSep] - startIndex); + if (trimTokens) + { + token = token.Trim(); + } + if (!(ignoreEmptyTokens && token.Length == 0)) + { + tokens.Add(token); + } + startIndex = delimiterPositions[ixSep] + 1; + } + // add remainder + if (startIndex < s.Length) + { + string token = s.Substring(startIndex); + if (trimTokens) + { + token = token.Trim(); + } + if (!(ignoreEmptyTokens && token.Length == 0)) + { + tokens.Add(token); + } + } + else if (startIndex == s.Length) + { + if (!(ignoreEmptyTokens)) + { + tokens.Add(string.Empty); + } + } + + return (string[])tokens.ToArray(typeof(string)); + } + + private static int MakeDelimiterPositionList(string s, char[] delimiters, string quoteChars, int[] delimiterPositions) + { + int count = 0; + int quoteNestingDepth = 0; + char expectedQuoteOpenChar = '\0'; + char expectedQuoteCloseChar = '\0'; + + for (int ixCurChar = 0; ixCurChar < s.Length; ixCurChar++) + { + char curChar = s[ixCurChar]; + + for (int ixCurDelim = 0; ixCurDelim < delimiters.Length; ixCurDelim++) + { + if (delimiters[ixCurDelim] == curChar) + { + if (quoteNestingDepth == 0) + { + delimiterPositions[count] = ixCurChar; + count++; + break; + } + } + + if (quoteNestingDepth == 0) + { + // check, if we're facing an opening char + for (int ixCurQuoteChar = 0; ixCurQuoteChar < quoteChars.Length; ixCurQuoteChar+=2) + { + if (quoteChars[ixCurQuoteChar] == curChar) + { + quoteNestingDepth++; + expectedQuoteOpenChar = curChar; + expectedQuoteCloseChar = quoteChars[ixCurQuoteChar + 1]; + break; + } + } + } + else + { + // check if we're facing an expected open or close char + if (curChar == expectedQuoteOpenChar) + { + quoteNestingDepth++; + } + else if (curChar == expectedQuoteCloseChar) + { + quoteNestingDepth--; + } + } + } + } + return count; + } + + /// + /// Convert a CSV list into an array of s. + /// + /// + /// Values may also be quoted using doublequotes. + /// + /// A CSV list. + /// + /// An array of s, or the empty array + /// if is . + /// + public static string[] CommaDelimitedListToStringArray(string s) + { + return Split(s, ",", false, false, "\"\""); + } + + /// + /// Take a which is a delimited list + /// and convert it to a array. + /// + /// + ///

+ /// If the supplied is a + /// or zero-length string, then a single element + /// array composed of the supplied + /// will be + /// eturned. If the supplied + /// is , then an empty, + /// zero-length array will be returned. + ///

+ ///
+ /// + /// The to be parsed. + /// + /// + /// The delimeter (this will not be returned). Note that only the first + /// character of the supplied is used. + /// + /// + /// An array of the tokens in the list. + /// + public static string[] DelimitedListToStringArray(string input, string delimiter) + { + if (input == null) + { + return new string[0]; + } + if (!HasLength(delimiter)) + { + return new string[] { input }; + } + // return input.Split(delimiter[0]); + return Split(input, delimiter, false, false, null); + } + + /// + /// Convenience method to return an + /// as a delimited + /// (e.g. CSV) . + /// + /// + /// The to parse. + /// + /// + /// The delimiter to use (probably a ','). + /// + /// The delimited string representation. + public static string CollectionToDelimitedString( + ICollection c, string delimiter) + { + if (c == null) + { + return "null"; + } + StringBuilder sb = new StringBuilder(); + int i = 0; + foreach (object obj in c) + { + if (i++ > 0) + { + sb.Append(delimiter); + } + sb.Append(obj); + } + return sb.ToString(); + } + + /// + /// Convenience method to return an + /// as a CSV + /// . + /// + /// + /// The to display. + /// + /// The delimited string representation. + public static string CollectionToCommaDelimitedString( + ICollection collection) + { + return CollectionToDelimitedString(collection, ","); + } + + /// + /// Convenience method to return an array as a CSV + /// . + /// + /// + /// The array to parse. Elements may be of any type ( + /// will be called on each + /// element). + /// + public static string ArrayToCommaDelimitedString(object[] source) + { + return ArrayToDelimitedString(source, ","); + } + + /// + /// Convenience method to return a + /// array as a delimited (e.g. CSV) . + /// + /// + /// The array to parse. Elements may be of any type ( + /// will be called on each + /// element). + /// + /// + /// The delimiter to use (probably a ','). + /// + public static string ArrayToDelimitedString( + object[] source, string delimiter) + { + if (source == null) + { + return "null"; + } + else + { + return StringUtils.CollectionToDelimitedString(source, delimiter); + } + } + + /// Checks if a string has length. + /// + /// The string to check, may be . + /// + /// + /// if the string has length and is not + /// . + /// + /// + /// + /// StringUtils.HasLength(null) = false + /// StringUtils.HasLength("") = false + /// StringUtils.HasLength(" ") = true + /// StringUtils.HasLength("Hello") = true + /// + /// + public static bool HasLength(string target) + { + return (target != null && target.Length > 0); + } + + /// + /// Checks if a has text. + /// + /// + ///

+ /// More specifically, returns if the string is + /// not , it's is > + /// zero (0), and it has at least one non-whitespace character. + ///

+ ///
+ /// + /// The string to check, may be . + /// + /// + /// if the is not + /// , + /// > zero (0), and does not consist + /// solely of whitespace. + /// + /// + /// + /// StringUtils.HasText(null) = false + /// StringUtils.HasText("") = false + /// StringUtils.HasText(" ") = false + /// StringUtils.HasText("12345") = true + /// StringUtils.HasText(" 12345 ") = true + /// + /// + public static bool HasText(string target) + { + if (target == null) + { + return false; + } + else + { + return HasLength(target.Trim()); + } + } + + /// + /// Checks if a is + /// or an empty string. + /// + /// + ///

+ /// More specifically, returns if the string is + /// , it's is equal + /// to zero (0), or it is composed entirely of whitespace + /// characters. + ///

+ ///
+ /// + /// The string to check, may (obviously) be . + /// + /// + /// if the is + /// , has a length equal to zero (0), or + /// is composed entirely of whitespace characters. + /// + /// + /// + /// StringUtils.IsNullOrEmpty(null) = true + /// StringUtils.IsNullOrEmpty("") = true + /// StringUtils.IsNullOrEmpty(" ") = true + /// StringUtils.IsNullOrEmpty("12345") = false + /// StringUtils.IsNullOrEmpty(" 12345 ") = false + /// + /// + public static bool IsNullOrEmpty(string target) + { + return !HasText(target); + } + + /// + /// Strips first and last character off the string. + /// + /// The string to strip. + /// The stripped string. + public static string StripFirstAndLastCharacter(string text) + { + if (text != null + && text.Length > 2) + { + return text.Substring(1, text.Length - 2); + } + else + { + return String.Empty; + } + } + + /// + /// Returns a list of Ant-style expressions from the specified text. + /// + /// The text to inspect. + /// + /// A list of expressions that exist in the specified text. + /// + /// + /// If any of the expressions in the supplied + /// is empty (${}). + /// + public static IList GetAntExpressions(string text) + { + IList expressions = new ArrayList(); + if (StringUtils.HasText(text)) + { + int start = text.IndexOf(AntExpressionPrefix); + while (start >= 0) + { + int end = text.IndexOf(AntExpressionSuffix, start + 2); + if (end == -1) + { + // terminator character not found, so let's quit... + start = -1; + } + else + { + string exp = text.Substring(start + 2, end - start - 2); + if (StringUtils.IsNullOrEmpty(exp)) + { + throw new FormatException( + string.Format("Empty {0}{1} value found in text : '{2}'.", + AntExpressionPrefix, + AntExpressionSuffix, + text)); + } + if (expressions.IndexOf(exp) < 0) + { + expressions.Add(exp); + } + start = text.IndexOf(AntExpressionPrefix, end); + } + } + } + return expressions; + } + + /// + /// Replaces Ant-style expression placeholder with expression value. + /// + /// + ///

+ /// + ///

+ ///
+ /// The string to set the value in. + /// The name of the expression to set. + /// The expression value. + /// + /// A new string with the expression value set; the + /// value if the supplied + /// is , has a length + /// equal to zero (0), or is composed entirely of whitespace + /// characters. + /// + public static string SetAntExpression(string text, string expression, object expValue) + { + if (StringUtils.IsNullOrEmpty(text)) + { + return String.Empty; + } + if (expValue == null) + { + expValue = String.Empty; + } + return text.Replace( + StringUtils.Surround(AntExpressionPrefix, expression, AntExpressionSuffix), expValue.ToString()); + } + + /// + /// Surrounds (prepends and appends) the string value of the supplied + /// to the supplied . + /// + /// + ///

+ /// The return value of this method call is always guaranteed to be non + /// . If every value passed as a parameter to this method is + /// , the string will be returned. + ///

+ ///
+ /// + /// The prefix and suffix that respectively will be prepended and + /// appended to the target . If this value + /// is not a value, it's attendant + /// value will be used. + /// + /// + /// The target that is to be surrounded. If this value is not a + /// value, it's attendant + /// value will be used. + /// + /// The surrounded string. + public static string Surround(object fix, object target) + { + return StringUtils.Surround(fix, target, fix); + } + + /// + /// Surrounds (prepends and appends) the string values of the supplied + /// and to the supplied + /// . + /// + /// + ///

+ /// The return value of this method call is always guaranteed to be non + /// . If every value passed as a parameter to this method is + /// , the string will be returned. + ///

+ ///
+ /// + /// The value that will be prepended to the . If this value + /// is not a value, it's attendant + /// value will be used. + /// + /// + /// The target that is to be surrounded. If this value is not a + /// value, it's attendant + /// value will be used. + /// + /// + /// The value that will be appended to the . If this value + /// is not a value, it's attendant + /// value will be used. + /// + /// The surrounded string. + public static string Surround(object prefix, object target, object suffix) + { + return string.Format( + CultureInfo.InvariantCulture, "{0}{1}{2}", prefix, target, suffix); + } + + /// + /// Converts escaped characters (for example "\t") within a string + /// to their real character. + /// + /// The string to convert. + /// The converted string. + public static string ConvertEscapedCharacters(string inputString) + { + StringBuilder sb = new StringBuilder(inputString.Length); + for (int i = 0; i < inputString.Length; i++) + { + if (inputString[i].Equals('\\')) + { + i++; + if (inputString[i].Equals('t')) + { + sb.Append('\t'); + } + else if (inputString[i].Equals('r')) + { + sb.Append('\r'); + } + else if (inputString[i].Equals('n')) + { + sb.Append('\n'); + } + else if (inputString[i].Equals('\\')) + { + sb.Append('\\'); + } + else + { + sb.Append("\\" + inputString[i]); + } + } + else + { + sb.Append(inputString[i]); + } + } + return sb.ToString(); + } + } } \ No newline at end of file diff --git a/test/Spring/Spring.Core.Tests/Core/TypeResolution/GenericTypeResolverTests.cs b/test/Spring/Spring.Core.Tests/Core/TypeResolution/GenericTypeResolverTests.cs index 5e08da11..b57b50a9 100644 --- a/test/Spring/Spring.Core.Tests/Core/TypeResolution/GenericTypeResolverTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/TypeResolution/GenericTypeResolverTests.cs @@ -48,7 +48,7 @@ namespace Spring.Core.TypeResolution public void ResolveLocalAssemblyGenericType() { Type t = GetTypeResolver().Resolve("Spring.Objects.TestGenericObject< int, string>"); - Assert.AreEqual(typeof(TestGenericObject), t); + Assert.AreEqual(typeof(TestGenericObject), t); } [Test] @@ -74,6 +74,26 @@ namespace Spring.Core.TypeResolution Assert.AreEqual(typeof(System.Collections.Generic.Stack), t); } + [Test] + public void ResolveGenericArrayType() + { + Type t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,]"); + Assert.AreEqual(typeof(int?[,]), t); + t = GetTypeResolver().Resolve("System.Nullable`1[int][,]"); + Assert.AreEqual(typeof(int?[,]), t); + } + + [Test] + public void ResolveGenericArrayTypeWithAssemblyName() + { + Type t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,], mscorlib"); + Assert.AreEqual(typeof(int?[,]), t); + t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,], mscorlib"); + Assert.AreEqual(typeof(int?[,]), t); + t = GetTypeResolver().Resolve("System.Nullable`1[[System.Int32, mscorlib]][,], mscorlib"); + Assert.AreEqual(typeof(int?[,]), t); + } + [Test] [ExpectedException(typeof(TypeLoadException))] public void ResolveAmbiguousGenericTypeWithAssemblyName() @@ -87,6 +107,27 @@ namespace Spring.Core.TypeResolution { Type t = GetTypeResolver().Resolve("Spring.Objects.TestGenericObject>"); } + + [Test] + public void ResolveNestedGenericTypeWithAssemblyName() + { + Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack< Spring.Objects.TestGenericObject >, System"); + Assert.AreEqual(typeof(System.Collections.Generic.Stack>), t); + } + + [Test] + public void ResolveClrNotationStyleGenericTypeWithAssemblyName() + { + Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack`1[ [Spring.Objects.TestGenericObject`2[int, string], Spring.Core.Tests] ], System"); + Assert.AreEqual(typeof(System.Collections.Generic.Stack>), t); + } + + [Test] + public void ResolveNestedQuotedGenericTypeWithAssemblyName() + { + Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack< [Spring.Objects.TestGenericObject, Spring.Core.Tests] >, System"); + Assert.AreEqual(typeof(System.Collections.Generic.Stack>), t); + } } } diff --git a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs index 4878e0f8..7bc4343b 100644 --- a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs +++ b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs @@ -703,12 +703,33 @@ namespace Spring.Expressions /// Tests type node ///
[Test] - [Ignore("does not work yet due to parser expecting ID production within T(ID)")] +// [Ignore("does not work yet due to parser expecting ID production within T(ID)")] public void TestTypeNodeWithAssemblyQualifiedName() { Assert.AreEqual(typeof(ExpressionEvaluator), ExpressionEvaluator.GetValue(null, string.Format("T({0})", typeof(ExpressionEvaluator).AssemblyQualifiedName))); } +#if NET_2_0 + /// + /// Tests type node + /// + [Test] + public void TestTypeNodeWithGenericAssemblyQualifiedName() + { +// Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[System.Int32], mscorlib)")); +// Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[System.Int32, mscorlib]], mscorlib)")); + Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[int]], mscorlib)")); + } + + /// + /// Tests type node + /// + [Test] + public void TestTypeNodeWithGenericAssemblyQualifiedArrayName() + { + Assert.AreEqual(typeof(int?[,]), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[System.Int32, mscorlib]][,], mscorlib)")); + } +#endif /// /// Tests constructor node /// @@ -1519,6 +1540,10 @@ namespace Spring.Expressions Assert.AreEqual(typeof(TestObject), ExpressionEvaluator.GetValue(null, "@(myContext:goran)").GetType()); + + // string literals allowed for contextname + Assert.AreEqual(typeof(TestObject), + ExpressionEvaluator.GetValue(null, "@('myContext':goran)").GetType()); } /// @@ -1560,6 +1585,8 @@ namespace Spring.Expressions ctx.Name = "my.Context"; ContextRegistry.RegisterContext(ctx); + Assert.AreEqual(typeof(TestObject), + ExpressionEvaluator.GetValue(null, "@(my.Context:goran)").GetType()); Assert.AreEqual(typeof(TestObject), ExpressionEvaluator.GetValue(null, "@(my\\.Context:goran)").GetType()); } diff --git a/test/Spring/Spring.Core.Tests/Objects/TestGenericObject.cs b/test/Spring/Spring.Core.Tests/Objects/TestGenericObject.cs index a4b4bdc6..a9ff77f4 100644 --- a/test/Spring/Spring.Core.Tests/Objects/TestGenericObject.cs +++ b/test/Spring/Spring.Core.Tests/Objects/TestGenericObject.cs @@ -1,8 +1,7 @@ -#if NET_2_0 #region License /* - * Copyright 2002-2004 the original author or authors. + * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +18,8 @@ #endregion +#if NET_2_0 + #region Imports using System; diff --git a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs index 35cb64da..140311b9 100644 --- a/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Util/StringUtilsTests.cs @@ -58,6 +58,31 @@ namespace Spring.Util Assert.IsTrue(ArrayUtils.AreEqual(new string[] {"one"}, res = StringUtils.Split("one", delim, true, true)), "Received '" + String.Join(",", res) + "'"); } + [Test] + public void SplitWithQuotedStrings() + { + string[] expectedParts = new string[] { "a", "[test,<,>>[]]]", "asdf<,<,>,>aa" }; + string testString = string.Join(",", expectedParts); + string[] result = StringUtils.Split(testString, ",", false, false, "[]<>"); + Assert.AreEqual( expectedParts, result ); + } + + [Test] + public void SplitAddsEmptyStrings() + { + string testString = ","; + string[] result = StringUtils.Split(testString, ",", true, false, null); + Assert.AreEqual( new string[] { "", "" }, result ); + } + + [Test] + public void SplitAcceptsWhitespaceDelimiters() + { + string testString = "a\nb\tc d"; + string[] result = StringUtils.Split(testString, "\n\t ", true, false, null); + Assert.AreEqual( new string[] { "a", "b", "c", "d" }, result ); + } + [Test] public void HasLengthTests() {