language-csharp-0.0.1: C# source code manipulation

Safe HaskellSafe
LanguageHaskell2010

Language.CSharp.Syntax

Description

This module contains the abstract syntax tree of C#.

Synopsis

Documentation

data CompilationUnit Source #

A compilation unit is the top level definition of a C# program.

data Using Source #

A using declaration appears within a compilation unit to indicate which namespace to include.

Constructors

Using Name Bool 

Instances

data Declaration Source #

A declaration appears within a compilation unit introducing a namespace, or a type declaration.

Constructors

NamespaceDeclaration [GlobalAttributeSection] Name [Declaration]

A namespace declaration.

TypeDeclaration TypeDeclaration

A type declaration.

data TypeDeclaration Source #

A type declaration appears withing a compilation unit, a namespace, or another type declaration. A type declaration introduces a new type which can be either a class, struct, enum, interface or delegate.

Constructors

ClassTypeDeclaration [AttributeSection] [Modifier] Identifier [TypeParameter] [TypeName] [TypeParameterConstraintClause] ClassBody

A class declaration containing its attributes, modifiers, identifier, type parameters, the types it inherits from, the type parameter constaints and its body.

StructTypeDeclaration [AttributeSection] [Modifier] Identifier [TypeParameter] [TypeName] [TypeParameterConstraintClause] StructBody

A struct declaration containing its attributes, modifiers, identifier, type parameters, the types it inherits from, the type parameter constraints and its body.

EnumTypeDeclaration [AttributeSection] [Modifier] Identifier (Maybe IntegralType) EnumBody

An enum declaration containing its attributes, modifiers, identifier, the type it inherits from and its body.

InterfaceTypeDeclaration [AttributeSection] [Modifier] Identifier [VariantTypeParameter] [TypeName] [TypeParameterConstraintClause] InterfaceBody

An interface declaration containing its attributes, modifiers, identifier, the type parameters, the types it inherits from, the type parameter constraints and its body.

DelegateTypeDeclaration [AttributeSection] [Modifier] (Maybe Type) Identifier [VariantTypeParameter] FormalParams [TypeParameterConstraintClause]

A delegate declaration containing its attributes, modifiers, return type, identifier, type parameters, formal parameters and type parameter constraints.

newtype ClassBody Source #

A class body appears within a class type declaration.

newtype StructBody Source #

A struct body appears within a struct type declaration.

newtype EnumBody Source #

An enum body appears within an enum type declaration.

data EnumMemberDeclaration Source #

An enum member declaration appears within an enum body.

Constructors

EnumMemberDeclaration Identifier (Maybe Expression)

An enum member declaration containing the identifier and its value.

newtype InterfaceBody Source #

An interface body appears within an interface type declaration.

data InterfaceMemberDeclaration Source #

An interface member declaration appears within an interface body.

Constructors

InterfaceMethodMemberDeclaration [AttributeSection] [Modifier] (Maybe Type) Identifier [TypeParameter] FormalParams [TypeParameterConstraintClause]

A method declaration containing its attributes, modifiers, return type identifier, type parameters, formal parameters and type parameter constraints.

InterfacePropertyMemberDeclaration [AttributeSection] [Modifier] Type Identifier (Maybe InterfaceAccessor) (Maybe InterfaceAccessor)

A property declaration containing its attributes, modifiers, type identifier and accessor(s). At least one accessor is defined and they can appear in any order.

InterfaceEventMemberDeclaration [AttributeSection] [Modifier] Type Identifier

An event declaration containing its attributes, modifiers, type and identifier.

InterfaceIndexerMemberDeclaration [AttributeSection] [Modifier] Type FormalParams (Maybe InterfaceAccessor) (Maybe InterfaceAccessor)

An indexer declaration containing its attributes, modifiers, type, formal parameters and accessor(s). At least one accessor is defined and they can appear in any order.

data MemberDeclaration Source #

A member declaration appears within a class- or struct body.

Constructors

FieldMemberDeclaration [AttributeSection] [Modifier] Type [VariableDeclarator]

A field declaration containing its attributes, modifiers, type and declarator(s).

MethodMemberDeclaration [AttributeSection] [Modifier] (Maybe Type) Name [TypeParameter] FormalParams [TypeParameterConstraintClause] MethodBody

A method declaration containing its attributes, modifiers, return type name, type parameters, formal parameters, type parameter constraints and body.

PropertyMemberDeclaration [AttributeSection] [Modifier] Type Name PropertyBody

A property declaration containing its attributes, modifiers, type, name and body.

EventVariableMemberDeclaration [AttributeSection] [Modifier] Type [VariableDeclarator]

An event declaration containing its attributes, modifiers, type and declarator(s).

EventAccessorMemberDeclaration [AttributeSection] [Modifier] Type Name EventAccessor EventAccessor

An event declaration containing its attributes, modifiers, type, name and accessors. The accessors can appear in any order.

IndexerMemberDeclaration [AttributeSection] [Modifier] IndexerDeclarator IndexerBody

An indexer declaration containing its attributes, modifiers, declarator and body.

OperatorMemberDeclaration [AttributeSection] [Modifier] OperatorDeclarator OperatorBody

An operator declaration containing its attributes, modifiers, declarator and body.

ConstructorMemberDeclaration [AttributeSection] [Modifier] Identifier FormalParams (Maybe ConstructorInitializer) ConstructorBody

A constructor declaration containing its attributes, identifier, formal parameters, the base/this constructor call and body.

DestructorMemberDeclaration [AttributeSection] [Modifier] Identifier DestructorBody

A destructor declaration containing its attributes, modifiers, identifier and body.

TypeMemberDeclaration TypeDeclaration

A nested type declaration.

data InterfaceAccessor Source #

A property accessor appears within an property declaration of an interface declaration.

data EventAccessor Source #

An event acessor appears within an event declaration.

Constructors

AddEventAccessor [AttributeSection] [Statement]

An add event accessor containing its attributes and statements.

RemoveEventAccessor [AttributeSection] [Statement]

A remove event accessor containing its attributes and statements.

data Argument Source #

An argument appears within any kind of method invocation.

Constructors

Argument (Maybe Identifier) Expression

An argument containing its identifier and expression.

RefArgument (Maybe Identifier) Expression

A ref argument containing its identifier and expression.

OutArgument (Maybe Identifier) Expression

An out argument containing its identifier and expression.

data OperatorDeclarator Source #

An operator declarator appears within a operator declaration.

Constructors

UnaryOperatorDeclarator Type OverloadableUnaryOperator Type Identifier

An unary operator declaration containing its return type, operator, and formal parameter type and identifier.

BinaryOperatorDeclarator Type BinaryOperator Type Identifier Type Identifier

A binary operator declaration containing its return type, operator, first formal parameter type and identifier, and second formal parameter type and identifier.

ImplicitConversionOperatorDeclarator Type Type Identifier

An implicit conversion declarator containing its return type, and formal parameter type and identifier.

ExplicitConversionOperatorDeclarator Type Type Identifier

An explicit conversion declarator containing its return type, and formal parameter type and identifier.

data OperatorBody Source #

An operator body appears within a operator declaration.

Constructors

OperatorStatementBody [Statement]

An operator body containing its statements.

OperatorExpressionBody Expression

An operator body containing its expression.

OperatorNoBody

An operator body without an implementation.

newtype ConstructorBody Source #

A constructor body appears within a constructor declaration.

newtype DestructorBody Source #

A destructor body appears within a destructor declaration.

data IndexerBody Source #

A indexer body appears within an indexer declaration.

Constructors

IndexerAccessor (Maybe AccessorDeclaration) (Maybe AccessorDeclaration)

An indexer body containing its accessor(s). At least one accessor is defined and they can appear in any order.

IndexerLambda Expression

An indexer body containing its expression.

data IndexerDeclarator Source #

An indexer declarator appears within an indexer declaration.

Constructors

IndexerDeclaratorThis Type FormalParams

An indexer declarator containing its return type and formal parameters.

IndexerDeclaratorInterface Type Type FormalParams

An indexer declarator containing its return type, interface type and formal parameters.

data PropertyBody Source #

A property body appears within a property declaration.

Constructors

PropertyBody (Maybe AccessorDeclaration) (Maybe AccessorDeclaration) (Maybe VariableInitializer)

A property body containing its accessor(s) and variable initializer. At least one accessor is defined an they can appear in any order.

PropertyLambda Expression

A propety body containing its expression.

data AccessorDeclaration Source #

An accessor declaration appears within a property body.

Constructors

GetAccessorDeclaration [AttributeSection] [Modifier] (Maybe [Statement])

A get propety declaration containing its attributes, modifiers and body.

SetAccessorDeclaration [AttributeSection] [Modifier] (Maybe [Statement])

A set propety declaration containing its attributes, modifiers and body.

data MethodBody Source #

A method body appears within a method declaration.

Constructors

MethodStatementBody [Statement]

An method body containing its statements.

MethodExpressionBody Expression

An method body containing its expression.

MethodNoBody

An method body without an implementation.

data FormalParams Source #

A formal parameters containing the formal parameters and a params array.

data FormalParam Source #

A formal parameter containing its modifier ty identifier and default value.

data ParamArray Source #

A formal params array containing its array type and identifier.

data Statement Source #

A statement.

Constructors

Labeled Identifier Statement

A labeled statement containing its label and statement.

Declaration LocalVarDeclaration

A declaration containing its variable declaration.

Block [Statement]

A block statement.

Empty

An empty statement.

ExpressionStatement Expression

An expression statement.

IfThenElse Expression Statement (Maybe Statement)

An if then else statement containing its guard, true body and false body.

Switch Expression [SwitchBlock]

A switch statement containing its guard and switch blocks.

While Expression Statement

A while statement containing its guard and body.

Do Statement Expression

A do while statement containing its body and guard.

For (Maybe ForInitializer) (Maybe Expression) (Maybe [Expression]) Statement

A for statement containing its initializer, guard, increment expression and body.

ForEach LocalVarType Identifier Expression Statement

A foreach statement containing its variable type name and expression, and body.

Break

A break statement.

Continue

A continue statement.

Goto GotoTarget

A goto statement.

Return (Maybe Expression)

A return statement.

Throw (Maybe Expression)

A throw statement.

Try [Statement] [Catch] [Statement]

A try catch finally statement containing the try body, catches and finally body.

CheckedStatement [Statement]

A checked statement.

UncheckedStatement [Statement]

An unchecked statement.

Lock Expression Statement

A lock statement containing its locking object and body.

UsingStatement ResourceAcquisition Statement

An using statement containing its resource and body.

Yield (Maybe Expression)

A yield statement containing its return expression.

data LocalVarDeclaration Source #

A local variable declaration appears within a local declaration or for initializer.

Constructors

LocalVarDeclaration LocalVarType [VariableDeclarator]

A local variable declaration containing its type and declarators.

data GotoTarget Source #

A goto target appears within a goto statement.

data SwitchBlock Source #

A switch block appears within a switch statement.

Constructors

LabeledBlock Expression [Statement]

A labeled block containing its label and body.

DefaultBlock [Statement]

A default block containing its body.

data ResourceAcquisition Source #

A resource acquisition appears within an using statement.

Constructors

ResourceAcquisitionVariable [VariableDeclarator]

A resource acquisition containing its variable declarators.

ResourceAcquisitionExpression Expression

A resource acquisition containing its expression.

data VariableInitializer Source #

A variable initializer.

Constructors

VariableInitializerExpression Expression

A variable initializer containing its expression.

VariableInitializerArray ArrayInitializer

A variable initializer containing its array initializer.

newtype ArrayInitializer Source #

An array initializer containing its variable initializers.

data ForInitializer Source #

A for initializer appears within a for statement.

Constructors

ForInitializerDeclaration LocalVarDeclaration

A for initializer containing its variable declaration.

ForInitializerExpressions [Expression]

A for initializer containing its expressions.

data Catch Source #

A catch block appears within a try statement.

Constructors

Catch (Maybe ExceptionSpecifier) (Maybe Expression) [Statement]

A catch block containing its exception specifier, exception filter and body.

Instances

data Expression Source #

An expression.

Constructors

Literal Literal

A literal.

SimpleName Identifier [TypeArgument]

A named value containing its identifer and type arguments.

Parenthesized Expression

A parenthesized expression.

Assign Expression AssignmentOperator Expression

An assignment containing its left-hand side, operator and right-hand side..

MemberAccess MemberAccess

An member access.

Invocation Expression [Argument]

An method invocation containing its method and arguments.

ElementAccess Expression [Expression]

An element access containing its array and indices.

This

A this access expression.

Base

A base access expression.

ObjectCreationExpression Type [Argument] (Maybe ObjectCreationInitializer)

An object creation containing its type, arguments and initializer. e.g. new Object(a, b).

ObjectCreationTypeInitializer Type ObjectCreationInitializer

An object creation containing its type and initializer. e.g. new Object { A = a, B = b }.

ArrayCreationExpression Type [Expression] [RankSpecifier] (Maybe ArrayCreationInitializer)

An array creation containing its type, rank specifiers and initialier.

ArrayCreationTypeInitializer Type ArrayCreationInitializer

An array creation containing its type and intializer.

ArrayCreationRankInitializer RankSpecifier ArrayCreationInitializer

An array creation containing its rank specifier and initializer.

Sizeof Type

A sizeof expression.

Typeof TypeOfExpression

A typeof expression.

Checked Expression

A checked expression.

Unchecked Expression

An unchecked expression.

Default Type

A default expression.

BinaryOperator BinaryOperator Expression Expression

A binary operator containing its operator, left expression and right expression.

Conditional Expression Expression Expression

A conditional expression containing its guard, first expression and second expression,

Nameof NameofEntity

A nameof expression.

Delegate (Maybe AnonymousFunctionSignature) [Statement]

A delegate expression containing its signature and body.

Lambda AnonymousFunctionSignature AnonymousFunctionBody

A lambda expression containing its signature and body.

UnaryPlus Expression

An unary + expression.

UnaryMinus Expression

An unary - expression.

UnaryNot Expression

An unary ! expression.

UnaryBitwiseNot Expression

An unary ~ expression.

UnaryPreIncrement Expression

An unary ++ expression appearing in front of its expression.

UnaryPreDecrement Expression

An unary -- expression appearing in front of its expression.

UnaryPostIncrement Expression

An unary ++ expression appearing after its expression.

UnaryPostDecrement Expression

An unary -- expression appearing after its expression.

UnaryCast Type Expression

A cast containing its target type and expression.

UnaryAwait Expression

An await expression.

data AnonymousFunctionSignature Source #

An anonymous function signature appears within a delegate- or lambda expression.

Constructors

ExplicitAnonymousFunctionSignature [AnonymousFunctionParameter]

An explicit anonymous function signature containing its formal parameters.

ImplicitAnonymousFunctionSignature [Identifier]

An implicit anonymous function signature containing its formal parameters.

data AnonymousFunctionBody Source #

An anonymous function body appears within a lambda expression.

Constructors

AnonymousFunctionStatementBody [Statement]

A anonymous function body containing its statements.

AnonymousFunctionExpressionBody Expression

A anonymous function body containing its expression.

data NameofEntity Source #

A nameof entity appears within a nameof expression.

Constructors

NameofIdentifier Identifier

A nameof containing its identifier.

NameofThis Identifier

A nameof this containing its identifier.

NameofBase Identifier

A nameof base containing its identifier.

NameofEntity NameofEntity Identifier

A nameof containing its entity and identifier.

NameofPredefinedType SimpleType Identifier

A nameof containing its simple type and identifier.

newtype TypeOfExpression Source #

A typeof expression containing its type where Nothing represents void.

Constructors

TypeofType (Maybe Type) 

data ArrayCreationInitializer Source #

An array creation initializer appears withing an array creation expression.

Constructors

ArrayCreationInitializerExpression [Expression]

An array creation initializer containing its values.

ArrayCreationInitializerInitializers [ArrayCreationInitializer]

An array creation initializer containing its nested initializers.

data ObjectCreationInitializer Source #

An object creation initializer appears within an object creation expression.

Constructors

ObjectInitializer [MemberInitializer]

An object initializer containing its member initializers.

CollectionInitializer ArrayCreationInitializer

A collection initializer containing its initializers.

data InitializerTarget Source #

An initialization target appears within a member initializer.

Constructors

InitializerTargetIdentifier Identifier

An initializer target containing its identifier.

InitializerTargetList [Argument]

An initializer target containing its values.

data InitializerValue Source #

An initialization value appears within a member initializer.

Constructors

InitializerValueExpression Expression

An initializer value containing its value.

InitializerValueInitializer ObjectCreationInitializer

An initializer value containing its nested values.

data MemberAccess Source #

A member access appearing within an member access expression.

Constructors

PrimaryMemberAccess Expression Identifier [TypeArgument]

A member access containing its expression, identifier and type arguments.

PredefinedMemberAccess SimpleType Identifier [TypeArgument]

A member access containing its simple type, identifier and type arguments.

QualifiedMemberAccess Identifier Identifier Identifier

A member access containing its namespace, identifier, and identifier.

newtype TypeParameter Source #

A type parameter containing its identifier.

data Variance Source #

A variance appears within a variant type parameter.

Constructors

VarianceIn 
VarianceOut 

data TypeParameterConstraint Source #

A type parameter constraint appears within a type parameter constraints clause.

Constructors

TypeConstraint Type

A type constraint containing its type.

ClassConstraint

A class constraint.

StructConstraint

A struct constraint.

NewConstraint

A new() constraint.

newtype TypeArgument Source #

A type argument containing its type.

Constructors

TypeArgument Type 

data Type Source #

A type.

Constructors

TypeNamed TypeName

A named type containing its name.

TypeArray ArrayType

An array type containing its array type.

TypeSimple SimpleType

A simple type containing its simple type.

TypeDynamic

A dynamic type.

TypeNullable Type

A nullable type containing its type.

Instances

data ArrayType Source #

An array type containing its base type and rank specifiers.

Constructors

ArrayType Type [RankSpecifier] 

newtype RankSpecifier Source #

A rank specifier containing the number of ranks.

Constructors

RankSpecifier Int 

data TypeName Source #

A type name.

Constructors

TypeName Name [TypeArgument]

A type name containing its name and type arguments.

TypeAlias Identifier Identifier [TypeArgument]

A type alias containing its namespace, identifier and type arguments.

data Attribute Source #

An attribute containing its type name and attribute arguments.

data AttributeArgument Source #

An attribute argument appears within an attribute.

Constructors

AttributeArgumentExpression Expression

An expression attribute argument containing its expression.

AttributeArgumentNamed Identifier Expression

An named attribute argument containing its name and expression.

data Modifier Source #

A modifier specifying properties of declarations on different levels.

newtype Name Source #

A name is a sequence of identifiers chained with periods.

Constructors

Name [Identifier] 

Instances