Grammar
Grammar
NamespaceOrTypeName ;
public static Rule TypeName =
NamespaceOrTypeName ;
public static Rule NamespaceOrTypeName =
Identifier + Opt(TypeArgumentList) |
NamespaceOrTypeName + CharToken('.') + Identifier + Opt(TypeArgumentList) |
QualifiedAliasMember ;
public static Rule Type =
ValueType |
ReferenceType |
TypeParameter ;
public static Rule ValueType =
StructType |
EnumType ;
public static Rule StructType =
TypeName |
SimpleType |
NullableType ;
public static Rule SimpleType =
NumericType |
StringToken("bool") ;
public static Rule NumericType =
IntegralType |
FloatingPointType |
StringToken("decimal") ;
public static Rule IntegralType =
StringToken("sbyte") |
StringToken("byte") |
StringToken("short") |
StringToken("ushort") |
StringToken("int") |
StringToken("uint") |
StringToken("long") |
StringToken("ulong") |
StringToken("char") ;
public static Rule FloatingPointType =
StringToken("float") |
StringToken("double") ;
public static Rule NullableType =
NonNullableValueType + ?
NonNullableValueType:
Type ;
public static Rule EnumType =
TypeName ;
public static Rule ReferenceType =
ClassType |
InterfaceType |
ArrayType |
DelegateType ;
public static Rule ClassType =
TypeName |
StringToken("object") |
Dynamic |
StringToken("string") ;
public static Rule InterfaceType =
TypeName ;
public static Rule ArrayType =
NonArrayType + RankSpecifiers ;
public static Rule NonArrayType =
Type ;
public static Rule RankSpecifiers =
RankSpecifier |
RankSpecifiers + RankSpecifier ;
public static Rule RankSpecifier =
SquareBrackets(Opt(DimSeparators)) ;
public static Rule DimSeparators =
CharToken(',') |
DimSeparators + CharToken(',') ;
public static Rule DelegateType =
TypeName ;
public static Rule TypeArgumentList =
Brackets(TypeArguments) ;
public static Rule TypeArguments =
TypeArgument |
TypeArguments + CharToken(',') + TypeArgument ;
public static Rule TypeArgument =
Type ;
public static Rule TypeParameter =
Identifier |
Variables ;
public static Rule VariableReference =
Expression ;
public static Rule ArgumentList =
Argument |
ArgumentList + CharToken(',') + Argument ;
public static Rule Argument =
Opt(ArgumentName) + ArgumentValue ;
public static Rule ArgumentName =
Identifier :
ArgumentValue:
Expression |
StringToken("ref") + VariableReference |
StringToken("out") + VariableReference ;
public static Rule PrimaryExpression =
PrimaryNoArrayCreationExpression |
ArrayCreationExpression ;
public static Rule PrimaryNoArrayCreationExpression =
Literal |
SimpleName |
ParenthesizedExpression |
MemberAccess |
InvocationExpression |
ElementAccess |
ThisAccess |
BaseAccess |
PostIncrementExpression |
PostDecrementExpression |
ObjectCreationExpression |
DelegateCreationExpression |
AnonymousObjectCreationExpression |
TypeofExpression |
CheckedExpression |
UncheckedExpression |
DefaultValueExpression |
AnonymousMethodExpression ;
public static Rule SimpleName =
Identifier + Opt(TypeArgumentList) ;
public static Rule ParenthesizedExpression =
Parentheses(Expression) ;
StringToken("out") ;
public static Rule ImplicitAnonymousFunctionSignature =
Parentheses(Opt(ImplicitAnonymousFunctionParameterList)) |
ImplicitAnonymousFunctionParameter ;
public static Rule ImplicitAnonymousFunctionParameterList =
ImplicitAnonymousFunctionParameter |
ImplicitAnonymousFunctionParameterList + CharToken(',') |
ImplicitAnonymousFunctionParameter ;
public static Rule ImplicitAnonymousFunctionParameter =
Identifier ;
public static Rule AnonymousFunctionBody =
Expression |
Block ;
public static Rule QueryExpression =
FromClause + QueryBody ;
public static Rule FromClause =
From + Opt(Type) + Identifier + StringToken("in") + Expression ;
public static Rule QueryBody =
Opt(QueryBodyClauses) + SelectOrGroupClause + Opt(QueryContinuation) ;
public static Rule QueryBodyClauses =
QueryBodyClause |
QueryBodyClauses + QueryBodyClause ;
public static Rule QueryBodyClause =
FromClause |
LetClause |
WhereClause |
JoinClause |
JoinIntoClause |
OrderbyClause ;
public static Rule LetClause =
StringToken("let") + Identifier + CharToken('=') + Expression ;
public static Rule WhereClause =
StringToken("where") + BooleanExpression ;
public static Rule JoinClause =
StringToken("join") + Opt(Type) + Identifier + StringToken("in") + Expression +
StringToken("on") + Expression + Equals + Expression ;
public static Rule JoinIntoClause =
StringToken("join") + Opt(Type) + Identifier + StringToken("in") + Expression +
StringToken("on") + Expression + Equals + Expression |
StringToken("into") + Identifier ;
public static Rule OrderbyClause =
StringToken("orderby") + Orderings ;
public static Rule Orderings =
Ordering |
Orderings + CharToken(',') + Ordering ;
public static Rule Ordering =
Expression + Opt(OrderingDirection) ;
public static Rule OrderingDirection =
StringToken("ascending") |
StringToken("descending") ;
public static Rule SelectOrGroupClause =
SelectClause |
GroupClause ;
public static Rule SelectClause =
StringToken("select") + Expression ;
public static Rule GroupClause =
StringToken("group") + Expression + StringToken("by") + Expression ;
public static Rule QueryContinuation =
StringToken("into") + Identifier + QueryBody ;
public static Rule Assignment =
LocalVariableDeclaration |
StatementExpressionList ;
public static Rule ForCondition =
BooleanExpression ;
public static Rule ForIterator =
StatementExpressionList ;
public static Rule StatementExpressionList =
StatementExpression |
StatementExpressionList + CharToken(',') + StatementExpression ;
public static Rule ForeachStatement =
StringToken("foreach") + Parentheses(LocalVariableType + Identifier + StringToke
n("in") + Expression) + EmbeddedStatement ;
public static Rule JumpStatement =
BreakStatement |
ContinueStatement |
GotoStatement |
ReturnStatement |
ThrowStatement ;
public static Rule BreakStatement =
StringToken("break") + CharToken(';') ;
public static Rule ContinueStatement =
StringToken("continue") + CharToken(';') ;
public static Rule GotoStatement =
StringToken("goto") + Identifier + CharToken(';') |
StringToken("goto") + StringToken("case") + ConstantExpression + CharToken(';')
|
StringToken("goto") + StringToken("default") + CharToken(';') ;
public static Rule ReturnStatement =
StringToken("return") + Opt(Expression) + CharToken(';') ;
public static Rule ThrowStatement =
StringToken("throw") + Opt(Expression) + CharToken(';') ;
public static Rule TryStatement =
StringToken("try") + Block + CatchClauses |
StringToken("try") + Block + FinallyClause |
StringToken("try") + Block + CatchClauses + FinallyClause ;
public static Rule CatchClauses =
SpecificCatchClauses + Opt(GeneralCatchClause) |
Opt(SpecificCatchClauses) + GeneralCatchClause ;
public static Rule SpecificCatchClauses =
SpecificCatchClause |
SpecificCatchClauses + SpecificCatchClause ;
public static Rule SpecificCatchClause =
StringToken("catch") + Parentheses(ClassType + Opt(Identifier)) + Block ;
public static Rule GeneralCatchClause =
StringToken("catch") + Block ;
public static Rule FinallyClause =
StringToken("finally") + Block ;
public static Rule CheckedStatement =
StringToken("checked") + Block ;
public static Rule UncheckedStatement =
StringToken("unchecked") + Block ;
public static Rule LockStatement =
StringToken("lock") + Parentheses(Expression) + EmbeddedStatement ;
public static Rule UsingStatement =
StringToken("using") + Parentheses(ResourceAcquisition) + EmbeddedStatement ;
public static Rule ResourceAcquisition =
LocalVariableDeclaration |
Expression ;
public static Rule YieldStatement =
Yield + StringToken("return") + Expression + CharToken(';') |
StringToken("static") ;
public static Rule TypeParameterList =
Brackets(TypeParameters) ;
public static Rule TypeParameters =
Opt(Attributes) + TypeParameter |
TypeParameters + CharToken(',') + Opt(Attributes) + TypeParameter ;
public static Rule TypeParameter =
Identifier ;
public static Rule ClassBase =
: ClassType |
: InterfaceTypeList |
: ClassType + CharToken(',') + InterfaceTypeList ;
public static Rule InterfaceTypeList =
InterfaceType |
InterfaceTypeList + CharToken(',') + InterfaceType ;
public static Rule TypeParameterConstraintsClauses =
TypeParameterConstraintsClause |
TypeParameterConstraintsClauses + TypeParameterConstraintsClause ;
public static Rule TypeParameterConstraintsClause =
StringToken("where") + TypeParameter : TypeParameterConstraints ;
public static Rule TypeParameterConstraints =
PrimaryConstraint |
SecondaryConstraints |
ConstructorConstraint |
PrimaryConstraint + CharToken(',') + SecondaryConstraints |
PrimaryConstraint + CharToken(',') + ConstructorConstraint |
SecondaryConstraints + CharToken(',') + ConstructorConstraint |
PrimaryConstraint + CharToken(',') + SecondaryConstraints + CharToken(',') + Con
structorConstraint ;
public static Rule PrimaryConstraint =
ClassType |
StringToken("class") |
StringToken("struct") ;
public static Rule SecondaryConstraints =
InterfaceType |
TypeParameter |
SecondaryConstraints + CharToken(',') + InterfaceType |
SecondaryConstraints + CharToken(',') + TypeParameter ;
public static Rule ConstructorConstraint =
StringToken("new") + ( ) ;
public static Rule ClassBody =
CurlyBrackets(Opt(ClassMemberDeclarations)) ;
public static Rule ClassMemberDeclarations =
ClassMemberDeclaration |
ClassMemberDeclarations + ClassMemberDeclaration ;
public static Rule ClassMemberDeclaration =
ConstantDeclaration |
FieldDeclaration |
MethodDeclaration |
PropertyDeclaration |
EventDeclaration |
IndexerDeclaration |
OperatorDeclaration |
ConstructorDeclaration |
DestructorDeclaration |
StaticConstructorDeclaration |
TypeDeclaration ;
public static Rule ConstantDeclaration =
Opt(Attributes) + Opt(ConstantModifiers) + StringToken("const") + Type + Constan
tDeclarators + CharToken(';') ;
StringToken("internal") + StringToken("protected") ;
public static Rule AccessorBody =
Block |
CharToken(';') ;
public static Rule EventDeclaration =
Opt(Attributes) + Opt(EventModifiers) + StringToken("event") + Type + VariableDe
clarators + CharToken(';') |
Opt(Attributes) + Opt(EventModifiers) + StringToken("event") + Type + MemberName
|
CurlyBrackets(EventAccessorDeclarations) ;
public static Rule EventModifiers =
EventModifier |
EventModifiers + EventModifier ;
public static Rule EventModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("static") |
StringToken("virtual") |
StringToken("sealed") |
StringToken("override") |
StringToken("abstract") |
StringToken("extern") ;
public static Rule EventAccessorDeclarations =
AddAccessorDeclaration + RemoveAccessorDeclaration |
RemoveAccessorDeclaration + AddAccessorDeclaration ;
public static Rule AddAccessorDeclaration =
Opt(Attributes) + StringToken("add") + Block ;
public static Rule RemoveAccessorDeclaration =
Opt(Attributes) + StringToken("remove") + Block ;
public static Rule IndexerDeclaration =
Opt(Attributes) + Opt(IndexerModifiers) + IndexerDeclarator + CurlyBrackets(Acce
ssorDeclarations) ;
public static Rule IndexerModifiers =
IndexerModifier |
IndexerModifiers + IndexerModifier ;
public static Rule IndexerModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("virtual") |
StringToken("sealed") |
StringToken("override") |
StringToken("abstract") |
StringToken("extern") ;
public static Rule IndexerDeclarator =
Type + StringToken("this") + SquareBrackets(FormalParameterList) |
Type + InterfaceType + CharToken('.') + StringToken("this") + SquareBrackets(For
malParameterList) ;
public static Rule OperatorDeclaration =
Opt(Attributes) + OperatorModifiers + OperatorDeclarator + OperatorBody ;
public static Rule OperatorModifiers =
OperatorModifier |
OperatorModifiers + OperatorModifier ;
public static Rule OperatorModifier =
StringToken("public") |
StringToken("static") |
StringToken("extern") ;
public static Rule OperatorDeclarator =
UnaryOperatorDeclarator |
BinaryOperatorDeclarator |
ConversionOperatorDeclarator ;
public static Rule UnaryOperatorDeclarator =
Type + StringToken("operator") + OverloadableUnaryOperator + Parentheses(Type +
Identifier) ;
public static Rule OverloadableUnaryOperator =
CharToken('+') |
CharToken('-') |
CharToken('!') |
CharToken('~') |
StringToken('++') |
StringToken('--') |
StringToken("true") |
StringToken("false") ;
public static Rule BinaryOperatorDeclarator =
Type + StringToken("operator") + OverloadableBinaryOperator + Parentheses(Type +
Identifier + CharToken(',') + Type + Identifier) ;
public static Rule OverloadableBinaryOperator =
CharToken('+') |
CharToken('-') |
CharToken('*') |
CharToken('/') |
CharToken('%') |
CharToken('&') |
CharToken('|') |
CharToken('^') |
StringToken('<<') |
RightShift |
StringToken('==') |
StringToken('!=') |
CharToken('>') |
CharToken('<') |
StringToken('>=') |
StringToken('<=') ;
public static Rule ConversionOperatorDeclarator =
StringToken("implicit") + StringToken("operator") + Type + Parentheses(Type + Id
entifier) |
StringToken("explicit") + StringToken("operator") + Type + Parentheses(Type + Id
entifier) ;
public static Rule OperatorBody =
Block |
CharToken(';') ;
public static Rule ConstructorDeclaration =
Opt(Attributes) + Opt(ConstructorModifiers) + ConstructorDeclarator + Constructo
rBody ;
public static Rule ConstructorModifiers =
ConstructorModifier |
ConstructorModifiers + ConstructorModifier ;
public static Rule ConstructorModifier =
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("extern") ;
public static Rule ConstructorDeclarator =
Identifier + Parentheses(Opt(FormalParameterList)) + Opt(ConstructorInitializer)
;
public static Rule ConstructorInitializer =
: StringToken("base") + Parentheses(Opt(ArgumentList)) |
: StringToken("this") + Parentheses(Opt(ArgumentList)) ;
public static Rule ConstructorBody =
Block |
CharToken(';') ;
public static Rule StaticConstructorDeclaration =
Opt(Attributes) + StaticConstructorModifiers + Identifier + ( ) + StaticConstruc
torBody ;
public static Rule StaticConstructorModifiers =
Opt(StringToken("extern")) + StringToken("static") |
StringToken("static") + Opt(StringToken("extern")) ;
public static Rule StaticConstructorBody =
Block |
CharToken(';') ;
public static Rule DestructorDeclaration =
Opt(Attributes) + Opt(StringToken("extern")) + CharToken('~') + Identifier + ( )
+ DestructorBody ;
public static Rule DestructorBody =
Block |
CharToken(';') |
Structs ;
public static Rule StructDeclaration =
Opt(Attributes) + Opt(StructModifiers) + Opt(StringToken("partial")) + StringTok
en("struct") + Identifier + Opt(TypeParameterList) |
Opt(StructInterfaces) + Opt(TypeParameterConstraintsClauses) + StructBody + Char
Token(';')Opt ;
public static Rule StructModifiers =
StructModifier |
StructModifiers + StructModifier ;
public static Rule StructModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") ;
public static Rule StructInterfaces =
: InterfaceTypeList ;
public static Rule StructBody =
CurlyBrackets(Opt(StructMemberDeclarations)) ;
public static Rule StructMemberDeclarations =
StructMemberDeclaration |
StructMemberDeclarations + StructMemberDeclaration ;
public static Rule StructMemberDeclaration =
ConstantDeclaration |
FieldDeclaration |
MethodDeclaration |
PropertyDeclaration |
EventDeclaration |
IndexerDeclaration |
OperatorDeclaration |
ConstructorDeclaration |
StaticConstructorDeclaration |
TypeDeclaration ;
public static Rule ArrayType =
NonArrayType + RankSpecifiers ;
public static Rule NonArrayType =
Type ;
public static Rule RankSpecifiers =
RankSpecifier |
RankSpecifiers + RankSpecifier ;
public static Rule RankSpecifier =
SquareBrackets(Opt(DimSeparators)) ;
public static Rule DimSeparators =
CharToken(',') |
DimSeparators + CharToken(',') ;
public static Rule ArrayInitializer =
CurlyBrackets(Opt(VariableInitializerList)) |
CurlyBrackets(VariableInitializerList + CharToken(',')) ;
public static Rule VariableInitializerList =
VariableInitializer |
VariableInitializerList + CharToken(',') + VariableInitializer ;
public static Rule VariableInitializer =
Expression |
ArrayInitializer ;
public static Rule InterfaceDeclaration =
Opt(Attributes) + Opt(InterfaceModifiers) + Opt(StringToken("partial")) + String
Token("interface") |
Identifier + Opt(VariantTypeParameterList) + Opt(InterfaceBase) |
Opt(TypeParameterConstraintsClauses) + InterfaceBody + CharToken(';')Opt ;
public static Rule InterfaceModifiers =
InterfaceModifier |
InterfaceModifiers + InterfaceModifier ;
public static Rule InterfaceModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") ;
public static Rule VariantTypeParameterList =
Brackets(VariantTypeParameters) ;
public static Rule VariantTypeParameters =
Opt(Attributes) + Opt(VarianceAnnotation) + TypeParameter |
VariantTypeParameters + CharToken(',') + Opt(Attributes) + Opt(VarianceAnnotatio
n) + TypeParameter ;
public static Rule VarianceAnnotation =
StringToken("in") |
StringToken("out") ;
public static Rule InterfaceBase =
: InterfaceTypeList ;
public static Rule InterfaceBody =
CurlyBrackets(Opt(InterfaceMemberDeclarations)) ;
public static Rule InterfaceMemberDeclarations =
InterfaceMemberDeclaration |
InterfaceMemberDeclarations + InterfaceMemberDeclaration ;
public static Rule InterfaceMemberDeclaration =
InterfaceMethodDeclaration |
InterfacePropertyDeclaration |
InterfaceEventDeclaration |
InterfaceIndexerDeclaration ;
public static Rule InterfaceMethodDeclaration =
Opt(Attributes) + Opt(StringToken("new")) + ReturnType + Identifier + TypeParame
terList |
Parentheses(Opt(FormalParameterList)) + Opt(TypeParameterConstraintsClauses) + C
harToken(';') ;
public static Rule InterfacePropertyDeclaration =
Opt(Attributes) + Opt(StringToken("new")) + Type + Identifier + CurlyBrackets(In
terfaceAccessors) ;
public static Rule InterfaceAccessors =
GlobalAttributeTarget :
GlobalAttributeTarget:
Assembly |
Module ;
public static Rule Attributes =
AttributeSections ;
public static Rule AttributeSections =
AttributeSection |
AttributeSections + AttributeSection ;
public static Rule AttributeSection =
SquareBrackets(Opt(AttributeTargetSpecifier) + AttributeList) |
SquareBrackets(Opt(AttributeTargetSpecifier) + AttributeList + CharToken(',')) ;
public static Rule AttributeTargetSpecifier =
AttributeTarget :
AttributeTarget:
Field |
StringToken("event") |
Method |
Param |
Property |
StringToken("return") |
Type ;
public static Rule AttributeList =
Attribute |
AttributeList + CharToken(',') + Attribute ;
public static Rule Attribute =
AttributeName + Opt(AttributeArguments) ;
public static Rule AttributeName =
TypeName ;
public static Rule AttributeArguments =
Parentheses(Opt(PositionalArgumentList)) |
Parentheses(PositionalArgumentList + CharToken(',') + NamedArgumentList) |
Parentheses(NamedArgumentList) ;
public static Rule PositionalArgumentList =
PositionalArgument |
PositionalArgumentList + CharToken(',') + PositionalArgument ;
public static Rule PositionalArgument =
Opt(ArgumentName) + AttributeArgumentExpression ;
public static Rule NamedArgumentList =
NamedArgument |
NamedArgumentList + CharToken(',') + NamedArgument ;
public static Rule NamedArgument =
Identifier + CharToken('=') + AttributeArgumentExpression ;
public static Rule AttributeArgumentExpression =
Expression |