Browse Source

Updated AST & provided c# parser implementation.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
a25ede2add
  1. 10
      ICSharpCode.NRefactory/CSharp/Dom/AbtractDomVisitor.cs
  2. 72
      ICSharpCode.NRefactory/CSharp/Dom/ComposedType.cs
  3. 59
      ICSharpCode.NRefactory/CSharp/Dom/Expressions/DirectionExpression.cs
  4. 4
      ICSharpCode.NRefactory/CSharp/Dom/IDomVisitor.cs
  5. 1163
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  6. 2
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

10
ICSharpCode.NRefactory/CSharp/Dom/AbtractDomVisitor.cs

@ -477,5 +477,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -477,5 +477,15 @@ namespace ICSharpCode.NRefactory.CSharp
{
return VisitChildren (argListExpression, data);
}
public virtual S VisitComposedType (ComposedType composedType, T data)
{
return VisitChildren (composedType, data);
}
public virtual S VisitDirectionExpression (DirectionExpression directionExpression, T data)
{
return VisitChildren (directionExpression, data);
}
}
}

72
ICSharpCode.NRefactory/CSharp/Dom/ComposedType.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
//
// ComposedType.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.NRefactory.CSharp
{
public class ComposedType : AbstractNode
{
public const int NullableRole = 100;
public const int PointerRole = 101;
public const int ArraySpecRole = 102;
public INode BaseType {
get {
return GetChildByRole (Roles.ReturnType);
}
}
public IEnumerable<ArraySpecifier> Compositions {
get { return GetChildrenByRole (ArraySpecRole).Cast<ArraySpecifier> () ?? new ArraySpecifier[0]; }
}
public override S AcceptVisitor<T, S> (IDomVisitor<T, S> visitor, T data)
{
return visitor.VisitComposedType (this, data);
}
public class ArraySpecifier : AbstractNode
{
public CSharpTokenNode LBracket {
get { return (CSharpTokenNode)GetChildByRole (Roles.LBracket); }
}
public CSharpTokenNode RBracket {
get { return (CSharpTokenNode)GetChildByRole (Roles.RBracket); }
}
public override S AcceptVisitor<T, S> (IDomVisitor<T, S> visitor, T data)
{
return default (S);
}
}
}
}

59
ICSharpCode.NRefactory/CSharp/Dom/Expressions/DirectionExpression.cs

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
//
// DirectionExpression.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace ICSharpCode.NRefactory.CSharp
{
public enum FieldDirection
{
None,
Out,
Ref
}
public class DirectionExpression : AbstractNode
{
public FieldDirection FieldDirection {
get;
set;
}
public CSharpTokenNode Keyword {
get { return (CSharpTokenNode)GetChildByRole (Roles.Keyword); }
}
public INode Expression {
get { return GetChildByRole (Roles.Expression); }
}
public override S AcceptVisitor<T, S> (IDomVisitor<T, S> visitor, T data)
{
return visitor.VisitDirectionExpression (this, data);
}
}
}

4
ICSharpCode.NRefactory/CSharp/Dom/IDomVisitor.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
public interface IDomVisitor<T, S>
{
S VisitCompilationUnit (CompilationUnit unit, T data);
S VisitCompilationUnit (CompilationUnit unit, T data);
#region General scope
S VisitAttribute (Attribute attribute, T data);
@ -46,6 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -46,6 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifier (Identifier identifier, T data);
S VisitParameterDeclarationExpression (ParameterDeclarationExpression parameterDeclarationExpression, T data);
S VisitConstraint (Constraint constraint, T data);
S VisitComposedType (ComposedType composedType, T data);
#endregion
#region Type members
@ -105,6 +106,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -105,6 +106,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitIdentifierExpression (IdentifierExpression identifierExpression, T data);
S VisitIndexerExpression (IndexerExpression indexerExpression, T data);
S VisitInvocationExpression (InvocationExpression invocationExpression, T data);
S VisitDirectionExpression (DirectionExpression directionExpression, T data);
S VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data);
S VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data);
S VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data);

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

File diff suppressed because it is too large Load Diff

2
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -288,6 +288,8 @@ @@ -288,6 +288,8 @@
<Compile Include="Utils\CacheManager.cs" />
<Compile Include="Utils\CSharpPrimitiveCast.cs" />
<Compile Include="Utils\TreeTraversal.cs" />
<Compile Include="CSharp\Dom\ComposedType.cs" />
<Compile Include="CSharp\Dom\Expressions\DirectionExpression.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="CSharp\" />

Loading…
Cancel
Save