Browse Source

fixed AttributeSectionTests

pull/2/head
Siegfried Pammer 16 years ago
parent
commit
c35500dd23
  1. 6
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  2. 6
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  3. 895
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  4. 23
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

6
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

@ -459,7 +459,7 @@ positional, named); @@ -459,7 +459,7 @@ positional, named);
List<Expression> positional, List<NamedArgumentExpression> named) {
#line 275 "cs.ATG"
string name = null; bool isNamed = false; Expression expr;
string name = null; bool isNamed = false; Expression expr; Location startLocation = la.Location;
if (
#line 278 "cs.ATG"
IsAssignment()) {
@ -488,12 +488,12 @@ out expr); @@ -488,12 +488,12 @@ out expr);
#line 289 "cs.ATG"
if (expr != null) {
if (isNamed) {
named.Add(new NamedArgumentExpression(name, expr));
named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation });
} else {
if (named.Count > 0)
Error("positional argument after named argument is not allowed");
if (name != null)
expr = new NamedArgumentExpression(name, expr);
expr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
positional.Add(expr);
}
}

6
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -272,7 +272,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na @@ -272,7 +272,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
.
AttributeArgument<List<Expression> positional, List<NamedArgumentExpression> named>
(. string name = null; bool isNamed = false; Expression expr; .)
(. string name = null; bool isNamed = false; Expression expr; Location startLocation = la.Location; .)
=
(
IF (IsAssignment()) (. isNamed = true; .)
@ -288,12 +288,12 @@ AttributeArgument<List<Expression> positional, List<NamedArgumentExpression> nam @@ -288,12 +288,12 @@ AttributeArgument<List<Expression> positional, List<NamedArgumentExpression> nam
(.
if (expr != null) {
if (isNamed) {
named.Add(new NamedArgumentExpression(name, expr));
named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation });
} else {
if (named.Count > 0)
Error("positional argument after named argument is not allowed");
if (name != null)
expr = new NamedArgumentExpression(name, expr);
expr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
positional.Add(expr);
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -2649,10 +2649,11 @@ Argument<out Expression argumentexpr> @@ -2649,10 +2649,11 @@ Argument<out Expression argumentexpr>
Expression expr;
argumentexpr = null;
string name;
Location startLocation = la.Location;
.) =
IF(IsNamedAssign()) Identifier (. name = t.val; .) ":=" Expr<out expr>
(.
argumentexpr = new NamedArgumentExpression(name, expr);
argumentexpr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
.)
|
Expr<out argumentexpr>
@ -2810,15 +2811,17 @@ GlobalAttributeSection = @@ -2810,15 +2811,17 @@ GlobalAttributeSection =
/* Spec, 5. */
Attribute<out ASTAttribute attribute>
(. string name;
(.
string name;
List<Expression> positional = new List<Expression>();
List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
Location startLocation = la.Location;
.) =
[ "Global" "." ]
Qualident<out name>
[ AttributeArguments<positional, named> ]
(.
attribute = new ASTAttribute(name, positional, named);
attribute = new ASTAttribute(name, positional, named) { StartLocation = startLocation, EndLocation = t.EndLocation };
.)
.
@ -2832,6 +2835,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na @@ -2832,6 +2835,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
"("
[
IF (IsNotClosingParenthesis()) (
(. Location startLocation = la.Location; .)
[
IF (IsNamedAssign()) (. nameFound = true; .)
IdentifierOrKeyword<out name>
@ -2840,7 +2844,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na @@ -2840,7 +2844,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
(.
if (expr != null) {
if (string.IsNullOrEmpty(name)) { positional.Add(expr); }
else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; }
else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
}
.)
{
@ -2851,7 +2855,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na @@ -2851,7 +2855,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
( ":=" | "=" )
| (. if (nameFound) Error("no positional argument after named argument"); .)
) Expr<out expr> (. if (expr != null) { if(name == "") positional.Add(expr);
else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; }
else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
}
.)
}
@ -2863,11 +2867,12 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na @@ -2863,11 +2867,12 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
/* Spec, 5. */
AttributeSection<out AttributeSection section>
(.
string attributeTarget = "";List<ASTAttribute> attributes = new List<ASTAttribute>();
string attributeTarget = "";
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
Location startLocation = la.Location;
.) =
"<" (. Location startPos = t.Location; .)
"<"
[ IF (IsLocalAttrTarget())
( "Event" (. attributeTarget = "event";.)
| "Return" (. attributeTarget = "return";.)
@ -2891,7 +2896,7 @@ AttributeSection<out AttributeSection section> @@ -2891,7 +2896,7 @@ AttributeSection<out AttributeSection section>
section = new AttributeSection {
AttributeTarget = attributeTarget,
Attributes = attributes,
StartLocation = startPos,
StartLocation = startLocation,
EndLocation = t.EndLocation
};
.)

Loading…
Cancel
Save