Browse Source

Fixed method/operator semicolons.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
ea6e15c28d
  1. 17
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 1180
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  3. 8
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

17
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -776,9 +776,12 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null) if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar); newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar);
if (o.Block != null) if (o.Block != null) {
newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body); newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body);
} else {
if (location != null && location.Count >= 5)
newOperator.AddChild (new CSharpTokenNode (Convert (location[4]), 1), MethodDeclaration.Roles.Semicolon);
}
typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole); typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole);
} }
@ -895,9 +898,13 @@ namespace ICSharpCode.NRefactory.CSharp
// } else { // } else {
newMethod.AddChild (bodyBlock, MethodDeclaration.Roles.Body); newMethod.AddChild (bodyBlock, MethodDeclaration.Roles.Body);
// } // }
} else if (location != null && location.Count < 3 && typeStack.Peek ().ClassType != ClassType.Interface) { } else if (location != null) {
// parser error, set end node to max value. if (location.Count < 3) {
newMethod.AddChild (new ErrorNode (), AstNode.Roles.Error); // parser error, set end node to max value.
newMethod.AddChild (new ErrorNode (), AstNode.Roles.Error);
} else {
newMethod.AddChild (new CSharpTokenNode (Convert (location[2]), 1), MethodDeclaration.Roles.Semicolon);
}
} }
typeStack.Peek ().AddChild (newMethod, TypeDeclaration.MemberRole); typeStack.Peek ().AddChild (newMethod, TypeDeclaration.MemberRole);
} }

1180
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

8
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -1266,6 +1266,7 @@ method_declaration
method.Block = (ToplevelBlock) $3; method.Block = (ToplevelBlock) $3;
if (method.Block == null) { if (method.Block == null) {
lbag.AppendToMember (method, savedLocation); // semicolon
method.ParameterInfo.CheckParameters (method); method.ParameterInfo.CheckParameters (method);
if ((method.ModFlags & Modifiers.ASYNC) != 0) { if ((method.ModFlags & Modifiers.ASYNC) != 0) {
@ -1421,7 +1422,7 @@ method_header
method_body method_body
: block : block
| SEMICOLON { $$ = null; } | SEMICOLON { savedLocation = GetLocation ($1); $$ = null; }
; ;
opt_formal_parameter_list opt_formal_parameter_list
@ -2049,6 +2050,9 @@ operator_declaration
current_container.AddOperator (op); current_container.AddOperator (op);
lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl)); lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl));
if ($5 == null) { // Semicolon
lbag.AppendTo (op, savedLocation);
}
} }
current_local_parameters = null; current_local_parameters = null;
@ -2057,7 +2061,7 @@ operator_declaration
operator_body operator_body
: block : block
| SEMICOLON { $$ = null; } | SEMICOLON { savedLocation = GetLocation ($1); $$ = null; }
; ;
operator_type operator_type

Loading…
Cancel
Save