Browse Source

Fixed VB parser bug: Using statement can have multiple variable declaration expressions. (forum-8651)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1478 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
79f22303b6
  1. 23
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  2. 25
      src/Libraries/NRefactory/Project/Src/Parser/AST/TypeReference.cs
  3. 344
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  4. 26
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  5. 10
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  6. 10
      src/Libraries/NRefactory/Test/Parser/Statements/UsingStatementTests.cs

23
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -507,18 +507,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{ {
outputFormatter.PrintIdentifier(variableDeclaration.Name); outputFormatter.PrintIdentifier(variableDeclaration.Name);
if (variableDeclaration.TypeReference.IsNull) { TypeReference varType = currentVariableType;
if (currentVariableType != null && !currentVariableType.IsNull) { if (varType != null && varType.IsNull)
outputFormatter.Space(); varType = null;
outputFormatter.PrintToken(Tokens.As); if (varType == null && !variableDeclaration.TypeReference.IsNull)
outputFormatter.Space(); varType = variableDeclaration.TypeReference;
nodeTracker.TrackedVisit(currentVariableType, data);
} if (varType != null) {
} else {
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.As); outputFormatter.PrintToken(Tokens.As);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(variableDeclaration.TypeReference, data); ObjectCreateExpression init = variableDeclaration.Initializer as ObjectCreateExpression;
if (init != null && TypeReference.AreEqualReferences(init.CreateType, varType)) {
nodeTracker.TrackedVisit(variableDeclaration.Initializer, data);
return null;
} else {
nodeTracker.TrackedVisit(varType, data);
}
} }
if (!variableDeclaration.Initializer.IsNull) { if (!variableDeclaration.Initializer.IsNull) {

25
src/Libraries/NRefactory/Project/Src/Parser/AST/TypeReference.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Parser.AST
string systemType = ""; string systemType = "";
int pointerNestingLevel = 0; int pointerNestingLevel = 0;
int[] rankSpecifier = null; int[] rankSpecifier = null;
List<TypeReference> genericTypes = new List<TypeReference>(1); List<TypeReference> genericTypes = new List<TypeReference>();
bool isGlobal = false; bool isGlobal = false;
static Dictionary<string, string> types = new Dictionary<string, string>(); static Dictionary<string, string> types = new Dictionary<string, string>();
@ -294,6 +294,29 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
return b.ToString(); return b.ToString();
} }
public static bool AreEqualReferences(TypeReference a, TypeReference b)
{
if (a == b) return true;
if (a == null || b == null) return false;
if (a is InnerClassTypeReference) a = ((InnerClassTypeReference)a).CombineToNormalTypeReference();
if (b is InnerClassTypeReference) b = ((InnerClassTypeReference)b).CombineToNormalTypeReference();
if (a.systemType != b.systemType) return false;
if (a.pointerNestingLevel != b.pointerNestingLevel) return false;
if (a.IsArrayType != b.IsArrayType) return false;
if (a.IsArrayType) {
if (a.rankSpecifier.Length != b.rankSpecifier.Length) return false;
for (int i = 0; i < a.rankSpecifier.Length; i++) {
if (a.rankSpecifier[i] != b.rankSpecifier[i]) return false;
}
}
if (a.genericTypes.Count != b.genericTypes.Count) return false;
for (int i = 0; i < a.genericTypes.Count; i++) {
if (!AreEqualReferences(a.genericTypes[i], b.genericTypes[i]))
return false;
}
return true;
}
} }
public class NullTypeReference : TypeReference public class NullTypeReference : TypeReference

344
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

@ -564,30 +564,30 @@ out aliasedType);
} }
void Qualident( void Qualident(
#line 2906 "VBNET.ATG" #line 2896 "VBNET.ATG"
out string qualident) { out string qualident) {
#line 2908 "VBNET.ATG" #line 2898 "VBNET.ATG"
string name; string name;
qualidentBuilder.Length = 0; qualidentBuilder.Length = 0;
Identifier(); Identifier();
#line 2912 "VBNET.ATG" #line 2902 "VBNET.ATG"
qualidentBuilder.Append(t.val); qualidentBuilder.Append(t.val);
while ( while (
#line 2913 "VBNET.ATG" #line 2903 "VBNET.ATG"
DotAndIdentOrKw()) { DotAndIdentOrKw()) {
Expect(10); Expect(10);
IdentifierOrKeyword( IdentifierOrKeyword(
#line 2913 "VBNET.ATG" #line 2903 "VBNET.ATG"
out name); out name);
#line 2913 "VBNET.ATG" #line 2903 "VBNET.ATG"
qualidentBuilder.Append('.'); qualidentBuilder.Append(name); qualidentBuilder.Append('.'); qualidentBuilder.Append(name);
} }
#line 2915 "VBNET.ATG" #line 2905 "VBNET.ATG"
qualident = qualidentBuilder.ToString(); qualident = qualidentBuilder.ToString();
} }
@ -691,69 +691,69 @@ out attribute);
} }
void TypeModifier( void TypeModifier(
#line 2967 "VBNET.ATG" #line 2957 "VBNET.ATG"
Modifiers m) { Modifiers m) {
switch (la.kind) { switch (la.kind) {
case 148: { case 148: {
lexer.NextToken(); lexer.NextToken();
#line 2968 "VBNET.ATG" #line 2958 "VBNET.ATG"
m.Add(Modifier.Public, t.Location); m.Add(Modifier.Public, t.Location);
break; break;
} }
case 147: { case 147: {
lexer.NextToken(); lexer.NextToken();
#line 2969 "VBNET.ATG" #line 2959 "VBNET.ATG"
m.Add(Modifier.Protected, t.Location); m.Add(Modifier.Protected, t.Location);
break; break;
} }
case 99: { case 99: {
lexer.NextToken(); lexer.NextToken();
#line 2970 "VBNET.ATG" #line 2960 "VBNET.ATG"
m.Add(Modifier.Internal, t.Location); m.Add(Modifier.Internal, t.Location);
break; break;
} }
case 145: { case 145: {
lexer.NextToken(); lexer.NextToken();
#line 2971 "VBNET.ATG" #line 2961 "VBNET.ATG"
m.Add(Modifier.Private, t.Location); m.Add(Modifier.Private, t.Location);
break; break;
} }
case 158: { case 158: {
lexer.NextToken(); lexer.NextToken();
#line 2972 "VBNET.ATG" #line 2962 "VBNET.ATG"
m.Add(Modifier.Static, t.Location); m.Add(Modifier.Static, t.Location);
break; break;
} }
case 157: { case 157: {
lexer.NextToken(); lexer.NextToken();
#line 2973 "VBNET.ATG" #line 2963 "VBNET.ATG"
m.Add(Modifier.New, t.Location); m.Add(Modifier.New, t.Location);
break; break;
} }
case 122: { case 122: {
lexer.NextToken(); lexer.NextToken();
#line 2974 "VBNET.ATG" #line 2964 "VBNET.ATG"
m.Add(Modifier.Abstract, t.Location); m.Add(Modifier.Abstract, t.Location);
break; break;
} }
case 131: { case 131: {
lexer.NextToken(); lexer.NextToken();
#line 2975 "VBNET.ATG" #line 2965 "VBNET.ATG"
m.Add(Modifier.Sealed, t.Location); m.Add(Modifier.Sealed, t.Location);
break; break;
} }
case 203: { case 203: {
lexer.NextToken(); lexer.NextToken();
#line 2976 "VBNET.ATG" #line 2966 "VBNET.ATG"
m.Add(Modifier.Partial, t.Location); m.Add(Modifier.Partial, t.Location);
break; break;
} }
@ -1487,132 +1487,132 @@ out p);
} }
void MemberModifier( void MemberModifier(
#line 2979 "VBNET.ATG" #line 2969 "VBNET.ATG"
Modifiers m) { Modifiers m) {
switch (la.kind) { switch (la.kind) {
case 122: { case 122: {
lexer.NextToken(); lexer.NextToken();
#line 2980 "VBNET.ATG" #line 2970 "VBNET.ATG"
m.Add(Modifier.Abstract, t.Location); m.Add(Modifier.Abstract, t.Location);
break; break;
} }
case 79: { case 79: {
lexer.NextToken(); lexer.NextToken();
#line 2981 "VBNET.ATG" #line 2971 "VBNET.ATG"
m.Add(Modifier.Default, t.Location); m.Add(Modifier.Default, t.Location);
break; break;
} }
case 99: { case 99: {
lexer.NextToken(); lexer.NextToken();
#line 2982 "VBNET.ATG" #line 2972 "VBNET.ATG"
m.Add(Modifier.Internal, t.Location); m.Add(Modifier.Internal, t.Location);
break; break;
} }
case 157: { case 157: {
lexer.NextToken(); lexer.NextToken();
#line 2983 "VBNET.ATG" #line 2973 "VBNET.ATG"
m.Add(Modifier.New, t.Location); m.Add(Modifier.New, t.Location);
break; break;
} }
case 142: { case 142: {
lexer.NextToken(); lexer.NextToken();
#line 2984 "VBNET.ATG" #line 2974 "VBNET.ATG"
m.Add(Modifier.Override, t.Location); m.Add(Modifier.Override, t.Location);
break; break;
} }
case 123: { case 123: {
lexer.NextToken(); lexer.NextToken();
#line 2985 "VBNET.ATG" #line 2975 "VBNET.ATG"
m.Add(Modifier.Abstract, t.Location); m.Add(Modifier.Abstract, t.Location);
break; break;
} }
case 145: { case 145: {
lexer.NextToken(); lexer.NextToken();
#line 2986 "VBNET.ATG" #line 2976 "VBNET.ATG"
m.Add(Modifier.Private, t.Location); m.Add(Modifier.Private, t.Location);
break; break;
} }
case 147: { case 147: {
lexer.NextToken(); lexer.NextToken();
#line 2987 "VBNET.ATG" #line 2977 "VBNET.ATG"
m.Add(Modifier.Protected, t.Location); m.Add(Modifier.Protected, t.Location);
break; break;
} }
case 148: { case 148: {
lexer.NextToken(); lexer.NextToken();
#line 2988 "VBNET.ATG" #line 2978 "VBNET.ATG"
m.Add(Modifier.Public, t.Location); m.Add(Modifier.Public, t.Location);
break; break;
} }
case 131: { case 131: {
lexer.NextToken(); lexer.NextToken();
#line 2989 "VBNET.ATG" #line 2979 "VBNET.ATG"
m.Add(Modifier.Sealed, t.Location); m.Add(Modifier.Sealed, t.Location);
break; break;
} }
case 132: { case 132: {
lexer.NextToken(); lexer.NextToken();
#line 2990 "VBNET.ATG" #line 2980 "VBNET.ATG"
m.Add(Modifier.Sealed, t.Location); m.Add(Modifier.Sealed, t.Location);
break; break;
} }
case 158: { case 158: {
lexer.NextToken(); lexer.NextToken();
#line 2991 "VBNET.ATG" #line 2981 "VBNET.ATG"
m.Add(Modifier.Static, t.Location); m.Add(Modifier.Static, t.Location);
break; break;
} }
case 141: { case 141: {
lexer.NextToken(); lexer.NextToken();
#line 2992 "VBNET.ATG" #line 2982 "VBNET.ATG"
m.Add(Modifier.Virtual, t.Location); m.Add(Modifier.Virtual, t.Location);
break; break;
} }
case 140: { case 140: {
lexer.NextToken(); lexer.NextToken();
#line 2993 "VBNET.ATG" #line 2983 "VBNET.ATG"
m.Add(Modifier.Overloads, t.Location); m.Add(Modifier.Overloads, t.Location);
break; break;
} }
case 150: { case 150: {
lexer.NextToken(); lexer.NextToken();
#line 2994 "VBNET.ATG" #line 2984 "VBNET.ATG"
m.Add(Modifier.ReadOnly, t.Location); m.Add(Modifier.ReadOnly, t.Location);
break; break;
} }
case 184: { case 184: {
lexer.NextToken(); lexer.NextToken();
#line 2995 "VBNET.ATG" #line 2985 "VBNET.ATG"
m.Add(Modifier.WriteOnly, t.Location); m.Add(Modifier.WriteOnly, t.Location);
break; break;
} }
case 183: { case 183: {
lexer.NextToken(); lexer.NextToken();
#line 2996 "VBNET.ATG" #line 2986 "VBNET.ATG"
m.Add(Modifier.WithEvents, t.Location); m.Add(Modifier.WithEvents, t.Location);
break; break;
} }
case 81: { case 81: {
lexer.NextToken(); lexer.NextToken();
#line 2997 "VBNET.ATG" #line 2987 "VBNET.ATG"
m.Add(Modifier.Dim, t.Location); m.Add(Modifier.Dim, t.Location);
break; break;
} }
@ -3830,114 +3830,114 @@ ref pexpr);
} }
void PrimitiveTypeName( void PrimitiveTypeName(
#line 2941 "VBNET.ATG" #line 2931 "VBNET.ATG"
out string type) { out string type) {
#line 2942 "VBNET.ATG" #line 2932 "VBNET.ATG"
type = String.Empty; type = String.Empty;
switch (la.kind) { switch (la.kind) {
case 52: { case 52: {
lexer.NextToken(); lexer.NextToken();
#line 2943 "VBNET.ATG" #line 2933 "VBNET.ATG"
type = "Boolean"; type = "Boolean";
break; break;
} }
case 76: { case 76: {
lexer.NextToken(); lexer.NextToken();
#line 2944 "VBNET.ATG" #line 2934 "VBNET.ATG"
type = "Date"; type = "Date";
break; break;
} }
case 65: { case 65: {
lexer.NextToken(); lexer.NextToken();
#line 2945 "VBNET.ATG" #line 2935 "VBNET.ATG"
type = "Char"; type = "Char";
break; break;
} }
case 165: { case 165: {
lexer.NextToken(); lexer.NextToken();
#line 2946 "VBNET.ATG" #line 2936 "VBNET.ATG"
type = "String"; type = "String";
break; break;
} }
case 77: { case 77: {
lexer.NextToken(); lexer.NextToken();
#line 2947 "VBNET.ATG" #line 2937 "VBNET.ATG"
type = "Decimal"; type = "Decimal";
break; break;
} }
case 54: { case 54: {
lexer.NextToken(); lexer.NextToken();
#line 2948 "VBNET.ATG" #line 2938 "VBNET.ATG"
type = "Byte"; type = "Byte";
break; break;
} }
case 159: { case 159: {
lexer.NextToken(); lexer.NextToken();
#line 2949 "VBNET.ATG" #line 2939 "VBNET.ATG"
type = "Short"; type = "Short";
break; break;
} }
case 111: { case 111: {
lexer.NextToken(); lexer.NextToken();
#line 2950 "VBNET.ATG" #line 2940 "VBNET.ATG"
type = "Integer"; type = "Integer";
break; break;
} }
case 117: { case 117: {
lexer.NextToken(); lexer.NextToken();
#line 2951 "VBNET.ATG" #line 2941 "VBNET.ATG"
type = "Long"; type = "Long";
break; break;
} }
case 160: { case 160: {
lexer.NextToken(); lexer.NextToken();
#line 2952 "VBNET.ATG" #line 2942 "VBNET.ATG"
type = "Single"; type = "Single";
break; break;
} }
case 84: { case 84: {
lexer.NextToken(); lexer.NextToken();
#line 2953 "VBNET.ATG" #line 2943 "VBNET.ATG"
type = "Double"; type = "Double";
break; break;
} }
case 191: { case 191: {
lexer.NextToken(); lexer.NextToken();
#line 2954 "VBNET.ATG" #line 2944 "VBNET.ATG"
type = "UInteger"; type = "UInteger";
break; break;
} }
case 192: { case 192: {
lexer.NextToken(); lexer.NextToken();
#line 2955 "VBNET.ATG" #line 2945 "VBNET.ATG"
type = "ULong"; type = "ULong";
break; break;
} }
case 193: { case 193: {
lexer.NextToken(); lexer.NextToken();
#line 2956 "VBNET.ATG" #line 2946 "VBNET.ATG"
type = "UShort"; type = "UShort";
break; break;
} }
case 190: { case 190: {
lexer.NextToken(); lexer.NextToken();
#line 2957 "VBNET.ATG" #line 2947 "VBNET.ATG"
type = "SByte"; type = "SByte";
break; break;
} }
@ -3946,10 +3946,10 @@ out string type) {
} }
void IdentifierOrKeyword( void IdentifierOrKeyword(
#line 2934 "VBNET.ATG" #line 2924 "VBNET.ATG"
out string name) { out string name) {
#line 2936 "VBNET.ATG" #line 2926 "VBNET.ATG"
lexer.NextToken(); name = t.val; lexer.NextToken(); name = t.val;
} }
@ -4856,27 +4856,27 @@ out expr);
} }
void ParameterModifier( void ParameterModifier(
#line 2960 "VBNET.ATG" #line 2950 "VBNET.ATG"
ParamModifiers m) { ParamModifiers m) {
if (la.kind == 55) { if (la.kind == 55) {
lexer.NextToken(); lexer.NextToken();
#line 2961 "VBNET.ATG" #line 2951 "VBNET.ATG"
m.Add(ParamModifier.In); m.Add(ParamModifier.In);
} else if (la.kind == 53) { } else if (la.kind == 53) {
lexer.NextToken(); lexer.NextToken();
#line 2962 "VBNET.ATG" #line 2952 "VBNET.ATG"
m.Add(ParamModifier.Ref); m.Add(ParamModifier.Ref);
} else if (la.kind == 137) { } else if (la.kind == 137) {
lexer.NextToken(); lexer.NextToken();
#line 2963 "VBNET.ATG" #line 2953 "VBNET.ATG"
m.Add(ParamModifier.Optional); m.Add(ParamModifier.Optional);
} else if (la.kind == 143) { } else if (la.kind == 143) {
lexer.NextToken(); lexer.NextToken();
#line 2964 "VBNET.ATG" #line 2954 "VBNET.ATG"
m.Add(ParamModifier.Params); m.Add(ParamModifier.Params);
} else SynErr(249); } else SynErr(249);
} }
@ -4927,21 +4927,21 @@ out stmt);
} }
void LabelName( void LabelName(
#line 2760 "VBNET.ATG" #line 2750 "VBNET.ATG"
out string name) { out string name) {
#line 2762 "VBNET.ATG" #line 2752 "VBNET.ATG"
name = String.Empty; name = String.Empty;
if (StartOf(12)) { if (StartOf(12)) {
Identifier(); Identifier();
#line 2764 "VBNET.ATG" #line 2754 "VBNET.ATG"
name = t.val; name = t.val;
} else if (la.kind == 5) { } else if (la.kind == 5) {
lexer.NextToken(); lexer.NextToken();
#line 2765 "VBNET.ATG" #line 2755 "VBNET.ATG"
name = t.val; name = t.val;
} else SynErr(251); } else SynErr(251);
} }
@ -5645,59 +5645,32 @@ out expr);
} }
case 188: { case 188: {
lexer.NextToken(); lexer.NextToken();
Identifier();
#line 2668 "VBNET.ATG" #line 2668 "VBNET.ATG"
string resourcename = t.val, typeName; LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifier.None);
Statement resourceAquisition = null, block = null;
Expect(48);
if (la.kind == 127) {
lexer.NextToken();
Qualident(
#line 2671 "VBNET.ATG"
out typeName);
#line 2669 "VBNET.ATG"
Statement block;
VariableDeclarator(
#line 2670 "VBNET.ATG"
resourceAquisition.Variables);
while (la.kind == 12) {
lexer.NextToken();
VariableDeclarator(
#line 2672 "VBNET.ATG" #line 2672 "VBNET.ATG"
List<Expression> initializer = null; resourceAquisition.Variables);
if (la.kind == 24) { }
lexer.NextToken();
if (StartOf(20)) {
ArgumentList(
#line 2673 "VBNET.ATG"
out initializer);
}
Expect(25);
}
#line 2675 "VBNET.ATG"
resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, new ArrayInitializerExpression(initializer), new TypeReference(typeName)));
} else if (StartOf(12)) {
Qualident(
#line 2678 "VBNET.ATG"
out typeName);
Expect(11);
Expr(
#line 2678 "VBNET.ATG"
out expr);
#line 2680 "VBNET.ATG"
resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, expr, new TypeReference(typeName)));
} else SynErr(257);
Block( Block(
#line 2683 "VBNET.ATG" #line 2674 "VBNET.ATG"
out block); out block);
Expect(88); Expect(88);
Expect(188); Expect(188);
#line 2685 "VBNET.ATG" #line 2676 "VBNET.ATG"
statement = new UsingStatement(resourceAquisition, block); statement = new UsingStatement(resourceAquisition, block);
break; break;
} }
default: SynErr(258); break; default: SynErr(257); break;
} }
} }
@ -5757,122 +5730,122 @@ localVariableDeclaration.Variables);
} }
void TryStatement( void TryStatement(
#line 2872 "VBNET.ATG" #line 2862 "VBNET.ATG"
out Statement tryStatement) { out Statement tryStatement) {
#line 2874 "VBNET.ATG" #line 2864 "VBNET.ATG"
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null; Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
Expect(174); Expect(174);
EndOfStmt(); EndOfStmt();
Block( Block(
#line 2877 "VBNET.ATG" #line 2867 "VBNET.ATG"
out blockStmt); out blockStmt);
if (la.kind == 58 || la.kind == 88 || la.kind == 97) { if (la.kind == 58 || la.kind == 88 || la.kind == 97) {
CatchClauses( CatchClauses(
#line 2878 "VBNET.ATG" #line 2868 "VBNET.ATG"
out catchClauses); out catchClauses);
} }
if (la.kind == 97) { if (la.kind == 97) {
lexer.NextToken(); lexer.NextToken();
EndOfStmt(); EndOfStmt();
Block( Block(
#line 2879 "VBNET.ATG" #line 2869 "VBNET.ATG"
out finallyStmt); out finallyStmt);
} }
Expect(88); Expect(88);
Expect(174); Expect(174);
#line 2882 "VBNET.ATG" #line 2872 "VBNET.ATG"
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
} }
void WithStatement( void WithStatement(
#line 2850 "VBNET.ATG" #line 2840 "VBNET.ATG"
out Statement withStatement) { out Statement withStatement) {
#line 2852 "VBNET.ATG" #line 2842 "VBNET.ATG"
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;
Expect(182); Expect(182);
#line 2855 "VBNET.ATG" #line 2845 "VBNET.ATG"
Point start = t.Location; Point start = t.Location;
Expr( Expr(
#line 2856 "VBNET.ATG" #line 2846 "VBNET.ATG"
out expr); out expr);
EndOfStmt(); EndOfStmt();
#line 2858 "VBNET.ATG" #line 2848 "VBNET.ATG"
withStatement = new WithStatement(expr); withStatement = new WithStatement(expr);
withStatement.StartLocation = start; withStatement.StartLocation = start;
withStatements.Push(withStatement); withStatements.Push(withStatement);
Block( Block(
#line 2862 "VBNET.ATG" #line 2852 "VBNET.ATG"
out blockStmt); out blockStmt);
#line 2864 "VBNET.ATG" #line 2854 "VBNET.ATG"
((WithStatement)withStatement).Body = (BlockStatement)blockStmt; ((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
withStatements.Pop(); withStatements.Pop();
Expect(88); Expect(88);
Expect(182); Expect(182);
#line 2868 "VBNET.ATG" #line 2858 "VBNET.ATG"
withStatement.EndLocation = t.Location; withStatement.EndLocation = t.Location;
} }
void WhileOrUntil( void WhileOrUntil(
#line 2843 "VBNET.ATG" #line 2833 "VBNET.ATG"
out ConditionType conditionType) { out ConditionType conditionType) {
#line 2844 "VBNET.ATG" #line 2834 "VBNET.ATG"
conditionType = ConditionType.None; conditionType = ConditionType.None;
if (la.kind == 181) { if (la.kind == 181) {
lexer.NextToken(); lexer.NextToken();
#line 2845 "VBNET.ATG" #line 2835 "VBNET.ATG"
conditionType = ConditionType.While; conditionType = ConditionType.While;
} else if (la.kind == 177) { } else if (la.kind == 177) {
lexer.NextToken(); lexer.NextToken();
#line 2846 "VBNET.ATG" #line 2836 "VBNET.ATG"
conditionType = ConditionType.Until; conditionType = ConditionType.Until;
} else SynErr(259); } else SynErr(258);
} }
void LoopControlVariable( void LoopControlVariable(
#line 2690 "VBNET.ATG" #line 2680 "VBNET.ATG"
out TypeReference type, out string name) { out TypeReference type, out string name) {
#line 2691 "VBNET.ATG" #line 2681 "VBNET.ATG"
ArrayList arrayModifiers = null; ArrayList arrayModifiers = null;
type = null; type = null;
Qualident( Qualident(
#line 2695 "VBNET.ATG" #line 2685 "VBNET.ATG"
out name); out name);
if ( if (
#line 2696 "VBNET.ATG" #line 2686 "VBNET.ATG"
IsDims()) { IsDims()) {
ArrayTypeModifiers( ArrayTypeModifiers(
#line 2696 "VBNET.ATG" #line 2686 "VBNET.ATG"
out arrayModifiers); out arrayModifiers);
} }
if (la.kind == 48) { if (la.kind == 48) {
lexer.NextToken(); lexer.NextToken();
TypeName( TypeName(
#line 2697 "VBNET.ATG" #line 2687 "VBNET.ATG"
out type); out type);
#line 2697 "VBNET.ATG" #line 2687 "VBNET.ATG"
if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); }
} }
#line 2699 "VBNET.ATG" #line 2689 "VBNET.ATG"
if (type != null) { if (type != null) {
if(type.RankSpecifier != null && arrayModifiers != null) { if(type.RankSpecifier != null && arrayModifiers != null) {
Error("array rank only allowed one time"); Error("array rank only allowed one time");
@ -5884,48 +5857,48 @@ out type);
} }
void CaseClauses( void CaseClauses(
#line 2803 "VBNET.ATG" #line 2793 "VBNET.ATG"
out List<CaseLabel> caseClauses) { out List<CaseLabel> caseClauses) {
#line 2805 "VBNET.ATG" #line 2795 "VBNET.ATG"
caseClauses = new List<CaseLabel>(); caseClauses = new List<CaseLabel>();
CaseLabel caseClause = null; CaseLabel caseClause = null;
CaseClause( CaseClause(
#line 2808 "VBNET.ATG" #line 2798 "VBNET.ATG"
out caseClause); out caseClause);
#line 2808 "VBNET.ATG" #line 2798 "VBNET.ATG"
if (caseClause != null) { caseClauses.Add(caseClause); } if (caseClause != null) { caseClauses.Add(caseClause); }
while (la.kind == 12) { while (la.kind == 12) {
lexer.NextToken(); lexer.NextToken();
CaseClause( CaseClause(
#line 2809 "VBNET.ATG" #line 2799 "VBNET.ATG"
out caseClause); out caseClause);
#line 2809 "VBNET.ATG" #line 2799 "VBNET.ATG"
if (caseClause != null) { caseClauses.Add(caseClause); } if (caseClause != null) { caseClauses.Add(caseClause); }
} }
} }
void OnErrorStatement( void OnErrorStatement(
#line 2710 "VBNET.ATG" #line 2700 "VBNET.ATG"
out OnErrorStatement stmt) { out OnErrorStatement stmt) {
#line 2712 "VBNET.ATG" #line 2702 "VBNET.ATG"
stmt = null; stmt = null;
GotoStatement goToStatement = null; GotoStatement goToStatement = null;
Expect(135); Expect(135);
Expect(92); Expect(92);
if ( if (
#line 2718 "VBNET.ATG" #line 2708 "VBNET.ATG"
IsNegativeLabelName()) { IsNegativeLabelName()) {
Expect(104); Expect(104);
Expect(15); Expect(15);
Expect(5); Expect(5);
#line 2720 "VBNET.ATG" #line 2710 "VBNET.ATG"
long intLabel = Int64.Parse(t.val); long intLabel = Int64.Parse(t.val);
if(intLabel != 1) { if(intLabel != 1) {
Error("invalid label in on error statement."); Error("invalid label in on error statement.");
@ -5934,10 +5907,10 @@ IsNegativeLabelName()) {
} else if (la.kind == 104) { } else if (la.kind == 104) {
GotoStatement( GotoStatement(
#line 2726 "VBNET.ATG" #line 2716 "VBNET.ATG"
out goToStatement); out goToStatement);
#line 2728 "VBNET.ATG" #line 2718 "VBNET.ATG"
string val = goToStatement.Label; string val = goToStatement.Label;
// if value is numeric, make sure that is 0 // if value is numeric, make sure that is 0
@ -5954,63 +5927,63 @@ out goToStatement);
lexer.NextToken(); lexer.NextToken();
Expect(128); Expect(128);
#line 2742 "VBNET.ATG" #line 2732 "VBNET.ATG"
stmt = new OnErrorStatement(new ResumeStatement(true)); stmt = new OnErrorStatement(new ResumeStatement(true));
} else SynErr(260); } else SynErr(259);
} }
void GotoStatement( void GotoStatement(
#line 2748 "VBNET.ATG" #line 2738 "VBNET.ATG"
out ICSharpCode.NRefactory.Parser.AST.GotoStatement goToStatement) { out ICSharpCode.NRefactory.Parser.AST.GotoStatement goToStatement) {
#line 2750 "VBNET.ATG" #line 2740 "VBNET.ATG"
string label = String.Empty; string label = String.Empty;
Expect(104); Expect(104);
LabelName( LabelName(
#line 2753 "VBNET.ATG" #line 2743 "VBNET.ATG"
out label); out label);
#line 2755 "VBNET.ATG" #line 2745 "VBNET.ATG"
goToStatement = new ICSharpCode.NRefactory.Parser.AST.GotoStatement(label); goToStatement = new ICSharpCode.NRefactory.Parser.AST.GotoStatement(label);
} }
void ResumeStatement( void ResumeStatement(
#line 2792 "VBNET.ATG" #line 2782 "VBNET.ATG"
out ResumeStatement resumeStatement) { out ResumeStatement resumeStatement) {
#line 2794 "VBNET.ATG" #line 2784 "VBNET.ATG"
resumeStatement = null; resumeStatement = null;
string label = String.Empty; string label = String.Empty;
if ( if (
#line 2797 "VBNET.ATG" #line 2787 "VBNET.ATG"
IsResumeNext()) { IsResumeNext()) {
Expect(153); Expect(153);
Expect(128); Expect(128);
#line 2798 "VBNET.ATG" #line 2788 "VBNET.ATG"
resumeStatement = new ResumeStatement(true); resumeStatement = new ResumeStatement(true);
} else if (la.kind == 153) { } else if (la.kind == 153) {
lexer.NextToken(); lexer.NextToken();
if (StartOf(29)) { if (StartOf(29)) {
LabelName( LabelName(
#line 2799 "VBNET.ATG" #line 2789 "VBNET.ATG"
out label); out label);
} }
#line 2799 "VBNET.ATG" #line 2789 "VBNET.ATG"
resumeStatement = new ResumeStatement(label); resumeStatement = new ResumeStatement(label);
} else SynErr(261); } else SynErr(260);
} }
void CaseClause( void CaseClause(
#line 2813 "VBNET.ATG" #line 2803 "VBNET.ATG"
out CaseLabel caseClause) { out CaseLabel caseClause) {
#line 2815 "VBNET.ATG" #line 2805 "VBNET.ATG"
Expression expr = null; Expression expr = null;
Expression sexpr = null; Expression sexpr = null;
BinaryOperatorType op = BinaryOperatorType.None; BinaryOperatorType op = BinaryOperatorType.None;
@ -6019,7 +5992,7 @@ out CaseLabel caseClause) {
if (la.kind == 86) { if (la.kind == 86) {
lexer.NextToken(); lexer.NextToken();
#line 2821 "VBNET.ATG" #line 2811 "VBNET.ATG"
caseClause = new CaseLabel(); caseClause = new CaseLabel();
} else if (StartOf(30)) { } else if (StartOf(30)) {
if (la.kind == 113) { if (la.kind == 113) {
@ -6029,76 +6002,76 @@ out CaseLabel caseClause) {
case 27: { case 27: {
lexer.NextToken(); lexer.NextToken();
#line 2825 "VBNET.ATG" #line 2815 "VBNET.ATG"
op = BinaryOperatorType.LessThan; op = BinaryOperatorType.LessThan;
break; break;
} }
case 26: { case 26: {
lexer.NextToken(); lexer.NextToken();
#line 2826 "VBNET.ATG" #line 2816 "VBNET.ATG"
op = BinaryOperatorType.GreaterThan; op = BinaryOperatorType.GreaterThan;
break; break;
} }
case 30: { case 30: {
lexer.NextToken(); lexer.NextToken();
#line 2827 "VBNET.ATG" #line 2817 "VBNET.ATG"
op = BinaryOperatorType.LessThanOrEqual; op = BinaryOperatorType.LessThanOrEqual;
break; break;
} }
case 29: { case 29: {
lexer.NextToken(); lexer.NextToken();
#line 2828 "VBNET.ATG" #line 2818 "VBNET.ATG"
op = BinaryOperatorType.GreaterThanOrEqual; op = BinaryOperatorType.GreaterThanOrEqual;
break; break;
} }
case 11: { case 11: {
lexer.NextToken(); lexer.NextToken();
#line 2829 "VBNET.ATG" #line 2819 "VBNET.ATG"
op = BinaryOperatorType.Equality; op = BinaryOperatorType.Equality;
break; break;
} }
case 28: { case 28: {
lexer.NextToken(); lexer.NextToken();
#line 2830 "VBNET.ATG" #line 2820 "VBNET.ATG"
op = BinaryOperatorType.InEquality; op = BinaryOperatorType.InEquality;
break; break;
} }
default: SynErr(262); break; default: SynErr(261); break;
} }
Expr( Expr(
#line 2832 "VBNET.ATG" #line 2822 "VBNET.ATG"
out expr); out expr);
#line 2834 "VBNET.ATG" #line 2824 "VBNET.ATG"
caseClause = new CaseLabel(op, expr); caseClause = new CaseLabel(op, expr);
} else if (StartOf(21)) { } else if (StartOf(21)) {
Expr( Expr(
#line 2836 "VBNET.ATG" #line 2826 "VBNET.ATG"
out expr); out expr);
if (la.kind == 172) { if (la.kind == 172) {
lexer.NextToken(); lexer.NextToken();
Expr( Expr(
#line 2836 "VBNET.ATG" #line 2826 "VBNET.ATG"
out sexpr); out sexpr);
} }
#line 2838 "VBNET.ATG" #line 2828 "VBNET.ATG"
caseClause = new CaseLabel(expr, sexpr); caseClause = new CaseLabel(expr, sexpr);
} else SynErr(263); } else SynErr(262);
} }
void CatchClauses( void CatchClauses(
#line 2887 "VBNET.ATG" #line 2877 "VBNET.ATG"
out List<CatchClause> catchClauses) { out List<CatchClause> catchClauses) {
#line 2889 "VBNET.ATG" #line 2879 "VBNET.ATG"
catchClauses = new List<CatchClause>(); catchClauses = new List<CatchClause>();
TypeReference type = null; TypeReference type = null;
Statement blockStmt = null; Statement blockStmt = null;
@ -6110,27 +6083,27 @@ out List<CatchClause> catchClauses) {
if (StartOf(12)) { if (StartOf(12)) {
Identifier(); Identifier();
#line 2897 "VBNET.ATG" #line 2887 "VBNET.ATG"
name = t.val; name = t.val;
if (la.kind == 48) { if (la.kind == 48) {
lexer.NextToken(); lexer.NextToken();
TypeName( TypeName(
#line 2897 "VBNET.ATG" #line 2887 "VBNET.ATG"
out type); out type);
} }
} }
if (la.kind == 180) { if (la.kind == 180) {
lexer.NextToken(); lexer.NextToken();
Expr( Expr(
#line 2898 "VBNET.ATG" #line 2888 "VBNET.ATG"
out expr); out expr);
} }
EndOfStmt(); EndOfStmt();
Block( Block(
#line 2900 "VBNET.ATG" #line 2890 "VBNET.ATG"
out blockStmt); out blockStmt);
#line 2901 "VBNET.ATG" #line 2891 "VBNET.ATG"
catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); catchClauses.Add(new CatchClause(type, name, blockStmt, expr));
} }
} }
@ -6442,12 +6415,11 @@ out blockStmt);
case 255: s = "invalid EmbeddedStatement"; break; case 255: s = "invalid EmbeddedStatement"; break;
case 256: s = "invalid EmbeddedStatement"; break; case 256: s = "invalid EmbeddedStatement"; break;
case 257: s = "invalid EmbeddedStatement"; break; case 257: s = "invalid EmbeddedStatement"; break;
case 258: s = "invalid EmbeddedStatement"; break; case 258: s = "invalid WhileOrUntil"; break;
case 259: s = "invalid WhileOrUntil"; break; case 259: s = "invalid OnErrorStatement"; break;
case 260: s = "invalid OnErrorStatement"; break; case 260: s = "invalid ResumeStatement"; break;
case 261: s = "invalid ResumeStatement"; break; case 261: s = "invalid CaseClause"; break;
case 262: s = "invalid CaseClause"; break; case 262: s = "invalid CaseClause"; break;
case 263: s = "invalid CaseClause"; break;
default: s = "error " + errorNumber; break; default: s = "error " + errorNumber; break;
} }
@ -6479,7 +6451,7 @@ out blockStmt);
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, T,T,T,x, x,T,T,T, T,x,T,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, T,T,T,x, x,T,T,T, T,x,T,x, x,x,x,x, x,T,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x},
{x,T,T,T, T,T,T,T, T,T,T,x, x,T,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,T, x,T,T,T, T,x,T,x, T,x,x,T, T,T,T,T, T,T,T,x, T,T,T,T, T,T,T,T, T,T,x,x, x,T,T,T, T,x,x,x, x,x,x,T, T,x,T,x, T,x,T,x, x,x,T,x, T,x,T,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,T,T, x,x,x,T, T,T,x,T, x,T,x,x, T,T,x,T, x,T,T,T, T,T,x,x, x,T,T,x, x,x,T,x, T,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x}, {x,T,T,T, T,T,T,T, T,T,T,x, x,T,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,T, x,T,T,T, T,x,T,x, T,x,x,T, T,T,T,T, T,T,T,x, T,T,T,T, T,T,T,T, T,T,x,x, x,T,T,T, T,x,x,x, x,x,x,T, T,x,T,x, T,x,T,x, x,x,T,x, T,x,T,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,T,T, x,x,x,T, T,T,x,T, x,T,x,x, T,T,x,T, x,T,T,T, T,T,x,x, x,T,T,x, x,x,T,x, T,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x},
{x,T,x,x, x,x,x,x, x,x,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,T,T,T, T,T,T,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,T, T,T,T,T, T,x,T,x, T,x,x,T, T,T,T,T, T,T,T,x, T,T,T,T, T,T,T,T, T,T,x,x, x,T,T,T, T,x,x,x, T,x,x,T, T,x,T,x, T,x,T,x, x,x,T,x, T,x,T,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,x,T,x, x,x,x,T, x,x,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,T,T, x,x,x,T, T,T,x,T, x,T,x,x, T,T,x,T, x,T,T,T, T,T,x,x, x,T,T,x, x,x,T,x, T,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x},
{x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x}, {x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,x,x, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x},
{x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x}, {x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x},
{x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x}, {x,x,T,T, T,T,T,T, T,T,T,x, x,x,T,T, T,x,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,T,T,T, T,x,T,x, x,x,x,T, T,T,T,T, T,T,T,x, T,T,T,x, T,T,T,T, T,T,x,x, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,T,x,T, x,x,x,x, T,T,x,T, x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,T,x,x, x,T,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x},

26
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -2664,27 +2664,17 @@ EmbeddedStatement<out Statement statement>
statement = new StatementExpression(expr); statement = new StatementExpression(expr);
.) .)
| "Call" SimpleExpr<out expr> (. statement = new StatementExpression(expr); .) | "Call" SimpleExpr<out expr> (. statement = new StatementExpression(expr); .)
| "Using" Identifier (. | "Using"
string resourcename = t.val, typeName; (. LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifier.None); .)
Statement resourceAquisition = null, block = null; (. Statement block; .)
.) "As" ( VariableDeclarator<resourceAquisition.Variables>
"New" Qualident<out typeName> { ","
(. List<Expression> initializer = null; .) VariableDeclarator<resourceAquisition.Variables>
["(" [ ArgumentList<out initializer> ] ")" ] }
(.
resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, new ArrayInitializerExpression(initializer), new TypeReference(typeName)));
.) |
Qualident<out typeName> "=" Expr<out expr>
(.
resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, expr, new TypeReference(typeName)));
.) )
Block<out block> Block<out block>
"End" "Using" "End" "Using"
(. statement = new UsingStatement(resourceAquisition, block); .) (. statement = new UsingStatement(resourceAquisition, block); .)
.
.
/* 10.9.2 */ /* 10.9.2 */
LoopControlVariable<out TypeReference type, out string name> LoopControlVariable<out TypeReference type, out string name>

10
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -154,6 +154,14 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
End Select"); End Select");
} }
[Test]
public void UsingStatement()
{
TestStatement(@"Using nf As New Font(), nf2 As New List(Of Font)(), nf3 = Nothing
Bla(nf)
End Using");
}
[Test] [Test]
public void UntypedVariable() public void UntypedVariable()
{ {
@ -224,7 +232,7 @@ End Select");
[Test] [Test]
public void Using() public void Using()
{ {
TestStatement("Using a As A = New A()\na.Work()\nEnd Using"); TestStatement("Using a As New A()\na.Work()\nEnd Using");
} }
[Test] [Test]

10
src/Libraries/NRefactory/Test/Parser/Statements/UsingStatementTests.cs

@ -43,6 +43,16 @@ End Using";
string usingText = @" string usingText = @"
Using nf As Font = New Font() Using nf As Font = New Font()
Bla(nf) Bla(nf)
End Using";
UsingStatement usingStmt = ParseUtilVBNet.ParseStatement<UsingStatement>(usingText);
// TODO : Extend test.
}
[Test]
public void VBNetUsingStatementTest3()
{
string usingText = @"
Using nf As New Font(), nf2 As New List(Of Font)(), nf3 = Nothing
Bla(nf)
End Using"; End Using";
UsingStatement usingStmt = ParseUtilVBNet.ParseStatement<UsingStatement>(usingText); UsingStatement usingStmt = ParseUtilVBNet.ParseStatement<UsingStatement>(usingText);
// TODO : Extend test. // TODO : Extend test.

Loading…
Cancel
Save