Skip to content

Instantly share code, notes, and snippets.

@DavyLandman
Created February 11, 2011 21:45
Show Gist options
  • Save DavyLandman/823100 to your computer and use it in GitHub Desktop.
Save DavyLandman/823100 to your computer and use it in GitHub Desktop.
I love it when a plan comes together. :) using rascal-dotnet to generate 90% of the source for rascal-csharp
data AstNode =
usingAliasDeclaration(AstType import, str alias, NodeType nodeType)
| typeParameterDeclaration(str identifier, VarianceModifier variance, NodeType nodeType)
| arraySpecifier(int dimensions, NodeType nodeType)
| caseLabel(Expression expression, NodeType nodeType)
| comment(str content, NodeType nodeType, bool startsLine, CommentType commentType)
| namespaceDeclaration(str fullName, str name, list[AstNode] members, list[Identifier] identifiers, NodeType nodeType)
| cSharpModifierToken(ICollection allModifiers, Modifiers modifier, NodeType nodeType)
| parameterDeclaration(str name, Expression defaultExpression, ParameterModifier parameterModifier, AstType type, list[AttributeSection] attributes, NodeType nodeType)
| constructorInitializer(ConstructorInitializerType constructorInitializerType, list[AstNode] arguments, NodeType nodeType)
| variableInitializer(str name, Expression initializer, NodeType nodeType)
| identifier(str name, NodeType nodeType)
| attributeSection(AttributeTarget attributeTarget, list[Attribute] attributes, NodeType nodeType)
| compilationUnit(NodeType nodeType)
| constraint(list[AstType] baseTypes, str typeParameter, NodeType nodeType)
| attribute(AstType type, list[Expression] arguments, NodeType nodeType)
| usingDeclaration(str namespace, AstType import, NodeType nodeType)
| cSharpTokenNode(NodeType nodeType)
| switchSection(list[CaseLabel] caseLabels, list[Statement] statements, NodeType nodeType)
| catchClause(BlockStatement body, AstType type, str variableName, NodeType nodeType)
| statement(Statement node)
| astType(AstType node)
| attributedNode(AttributedNode node)
| expression(Expression node)
;
data Statement =
returnStatement(Expression expression, NodeType nodeType)
| whileStatement(Expression condition, Statement embeddedStatement, WhilePosition whilePosition, NodeType nodeType)
| switchStatement(Expression expression, list[SwitchSection] switchSections, NodeType nodeType)
| labelStatement(NodeType nodeType, str label)
| fixedStatement(Statement embeddedStatement, AstType type, NodeType nodeType, list[VariableInitializer] variables)
| ifElseStatement(Statement falseStatement, Expression condition, Statement trueStatement, NodeType nodeType)
| expressionStatement(Expression expression, NodeType nodeType)
| variableDeclarationStatement(AstType type, Modifiers modifiers, NodeType nodeType, list[VariableInitializer] variables)
| breakStatement(NodeType nodeType)
| tryCatchStatement(BlockStatement finallyBlock, list[CatchClause] catchClauses, BlockStatement tryBlock, NodeType nodeType)
| gotoStatement(Expression labelExpression, GotoType gotoType, NodeType nodeType, str label)
| usingStatement(Statement embeddedStatement, NodeType nodeType, AstNode resourceAcquisition)
| unsafeStatement(BlockStatement body, NodeType nodeType)
| throwStatement(Expression expression, NodeType nodeType)
| checkedStatement(BlockStatement body, NodeType nodeType)
| continueStatement(NodeType nodeType)
| forStatement(Expression condition, list[Statement] initializers, Statement embeddedStatement, list[Statement] iterators, NodeType nodeType)
| foreachStatement(Expression inExpression, AstType variableType, Statement embeddedStatement, str variableName, NodeType nodeType)
| lockStatement(Expression expression, Statement embeddedStatement, NodeType nodeType)
| yieldStatement(Expression expression, NodeType nodeType)
| emptyStatement(NodeType nodeType)
| blockStatement(list[Statement] statements, NodeType nodeType)
| uncheckedStatement(BlockStatement body, NodeType nodeType)
;
data AstType =
composedType(int pointerRank, bool hasNullableSpecifier, AstType baseType, list[ArraySpecifier] arraySpecifiers, NodeType nodeType)
| simpleType(str identifier, list[AstType] typeArguments, NodeType nodeType)
| memberType(AstType target, list[AstType] typeArguments, NodeType nodeType, str memberName, bool isDoubleColon)
| primitiveType(str keyword, NodeType nodeType)
;
data AttributedNode =
enumMemberDeclaration(str name, Modifiers modifiers, Expression initializer, NodeType nodeType, list[AttributeSection] attributes)
| indexerDeclaration(str name, list[ParameterDeclaration] parameters, Accessor setter, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType, Accessor getter)
| methodDeclaration(str name, list[TypeParameterDeclaration] typeParameters, list[Constraint] constraints, BlockStatement body, list[ParameterDeclaration] parameters, AstType returnType, Modifiers modifiers, bool isExtensionMethod, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType)
| accessor(BlockStatement body, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes)
| operatorDeclaration(str name, BlockStatement body, list[ParameterDeclaration] parameters, OperatorType operatorType, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType)
| propertyDeclaration(str name, Accessor setter, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType, Accessor getter)
| delegateDeclaration(str name, list[TypeParameterDeclaration] typeParameters, list[Constraint] constraints, list[ParameterDeclaration] parameters, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes)
| customEventDeclaration(str name, AstType returnType, Modifiers modifiers, Accessor addAccessor, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType, Accessor removeAccessor)
| destructorDeclaration(BlockStatement body, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes)
| eventDeclaration(str name, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType, list[VariableInitializer] variables)
| constructorDeclaration(BlockStatement body, ConstructorInitializer initializer, list[ParameterDeclaration] parameters, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes)
| typeDeclaration(list[AstType] baseTypes, str name, list[TypeParameterDeclaration] typeParameters, list[Constraint] constraints, Modifiers modifiers, ClassType classType, NodeType nodeType, list[AttributeSection] attributes, list[AttributedNode] members)
| fieldDeclaration(str name, AstType returnType, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes, AstType privateImplementationType, list[VariableInitializer] variables)
;
data Expression =
lambdaExpression(AstNode body, list[ParameterDeclaration] parameters, NodeType nodeType)
| conditionalExpression(Expression condition, Expression falseExpression, Expression trueExpression, NodeType nodeType)
| binaryOperatorExpression(Expression right, BinaryOperatorType operator, Expression left, NodeType nodeType)
| directionExpression(FieldDirection fieldDirection, Expression expression, NodeType nodeType)
| castExpression(Expression expression, AstType castTo, NodeType nodeType)
| indexerExpression(list[Expression] arguments, NodeType nodeType, Expression target)
| parenthesizedExpression(Expression expression, NodeType nodeType)
| baseReferenceExpression(NodeType nodeType)
| sizeOfExpression(AstType type, NodeType nodeType)
| arrayCreateExpression(list[ArraySpecifier] additionalArraySpecifiers, ArrayInitializerExpression initializer, AstType type, list[Expression] arguments, NodeType nodeType)
| unaryOperatorExpression(UnaryOperatorType operator, Expression expression, NodeType nodeType)
| asExpression(Expression expression, AstType type, NodeType nodeType)
| typeOfExpression(AstType type, NodeType nodeType)
| defaultValueExpression(AstType type, NodeType nodeType)
| uncheckedExpression(Expression expression, NodeType nodeType)
| anonymousMethodExpression(bool hasParameterList, BlockStatement body, list[ParameterDeclaration] parameters, NodeType nodeType)
| isExpression(Expression expression, AstType type, NodeType nodeType)
| identifierExpression(str identifier, list[AstType] typeArguments, NodeType nodeType)
| checkedExpression(Expression expression, NodeType nodeType)
| primitiveExpression(NodeType nodeType, Object value)
| objectCreateExpression(ArrayInitializerExpression initializer, AstType type, list[Expression] arguments, NodeType nodeType)
| namedArgumentExpression(str identifier, Expression expression, NodeType nodeType)
| argListExpression(bool isAccess, list[Expression] arguments, NodeType nodeType)
| memberReferenceExpression(list[AstType] typeArguments, NodeType nodeType, Expression target, str memberName)
| invocationExpression(list[Expression] arguments, NodeType nodeType, Expression target)
| pointerReferenceExpression(list[AstType] typeArguments, NodeType nodeType, Expression target, str memberName)
| stackAllocExpression(Expression countExpression, AstType type, NodeType nodeType)
| thisReferenceExpression(NodeType nodeType)
| assignmentExpression(AssignmentOperatorType operator, Expression right, Expression left, NodeType nodeType)
| arrayInitializerExpression(list[Expression] elements, NodeType nodeType)
;
data OperatorType =
logicalNot()
| onesComplement()
| increment()
| decrement()
| true()
| false()
| addition()
| subtraction()
| unaryPlus()
| unaryNegation()
| multiply()
| division()
| modulus()
| bitwiseAnd()
| bitwiseOr()
| exclusiveOr()
| leftShift()
| rightShift()
| equality()
| inequality()
| greaterThan()
| lessThan()
| greaterThanOrEqual()
| lessThanOrEqual()
| implicit()
| explicit()
;
data BinaryOperatorType =
bitwiseAnd()
| bitwiseOr()
| logicalAnd()
| logicalOr()
| exclusiveOr()
| greaterThan()
| greaterThanOrEqual()
| equality()
| inEquality()
| lessThan()
| lessThanOrEqual()
| add()
| subtract()
| multiply()
| divide()
| modulus()
| shiftLeft()
| shiftRight()
| nullCoalescing()
;
data AttributeTarget =
none()
| assembly()
| module()
| type()
| param()
| field()
| return()
| method()
| unknown()
;
data NodeType =
unknown()
| typeReference()
| typeDeclaration()
| member()
| statement()
| expression()
| token()
;
data ConstructorInitializerType =
base()
| this()
;
data TypeParameterDeclaration =
typeParameterDeclaration(str identifier, VarianceModifier variance, NodeType nodeType)
;
data Identifier =
identifier(str name, NodeType nodeType)
;
data AttributeSection =
attributeSection(AttributeTarget attributeTarget, list[Attribute] attributes, NodeType nodeType)
;
data ArraySpecifier =
arraySpecifier(int dimensions, NodeType nodeType)
;
data CaseLabel =
caseLabel(Expression expression, NodeType nodeType)
;
data BlockStatement =
blockStatement(list[Statement] statements, NodeType nodeType)
;
data CommentType =
singleLine()
| multiLine()
| documentation()
;
data Constraint =
constraint(list[AstType] baseTypes, str typeParameter, NodeType nodeType)
;
data Attribute =
attribute(AstType type, list[Expression] arguments, NodeType nodeType)
;
data AstLocation =
;
data VarianceModifier =
invariant()
| covariant()
| contravariant()
;
data SwitchSection =
switchSection(list[CaseLabel] caseLabels, list[Statement] statements, NodeType nodeType)
;
data ParameterDeclaration =
parameterDeclaration(str name, Expression defaultExpression, ParameterModifier parameterModifier, AstType type, list[AttributeSection] attributes, NodeType nodeType)
;
data AssignmentOperatorType =
assign()
| add()
| subtract()
| multiply()
| divide()
| modulus()
| shiftLeft()
| shiftRight()
| bitwiseAnd()
| bitwiseOr()
| exclusiveOr()
;
data ParameterModifier =
none()
| ref()
| out()
| params()
| this()
;
data CatchClause =
catchClause(BlockStatement body, AstType type, str variableName, NodeType nodeType)
;
data ConstructorInitializer =
constructorInitializer(ConstructorInitializerType constructorInitializerType, list[AstNode] arguments, NodeType nodeType)
;
data UnaryOperatorType =
not()
| bitNot()
| minus()
| plus()
| increment()
| decrement()
| postIncrement()
| postDecrement()
| dereference()
| addressOf()
;
data FieldDirection =
none()
| out()
| ref()
;
data Accessor =
accessor(BlockStatement body, Modifiers modifiers, NodeType nodeType, list[AttributeSection] attributes)
;
data VariableInitializer =
variableInitializer(str name, Expression initializer, NodeType nodeType)
;
data ClassType =
class()
| enum()
| interface()
| struct()
| delegate()
| module()
;
data GotoType =
label()
| case()
| caseDefault()
;
data Modifiers =
none()
| private()
| internal()
| protected()
| public()
| abstract()
| virtual()
| sealed()
| static()
| override()
| readonly()
| const()
| new()
| partial()
| extern()
| volatile()
| unsafe()
| fixed()
| visibilityMask()
;
data ArrayInitializerExpression =
arrayInitializerExpression(list[Expression] elements, NodeType nodeType)
;
data WhilePosition =
begin()
| end()
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment