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

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

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

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

File diff suppressed because it is too large Load Diff

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

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

Loading…
Cancel
Save