0% found this document useful (0 votes)
13 views

Grammar

hrft

Uploaded by

PhạmQuỳnhAnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Grammar

hrft

Uploaded by

PhạmQuỳnhAnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 19

NamespaceName:

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) ;

public static Rule MemberAccess =


PrimaryExpression + CharToken('.') + Identifier + Opt(TypeArgumentList) |
PredefinedType + CharToken('.') + Identifier + Opt(TypeArgumentList) |
QualifiedAliasMember + CharToken('.') + Identifier + Opt(TypeArgumentList) ;
public static Rule PredefinedType =
StringToken("bool") |
StringToken("byte") |
StringToken("char") |
StringToken("decimal") |
StringToken("double") |
StringToken("float") |
StringToken("int") |
StringToken("long") |
StringToken("object") |
StringToken("sbyte") |
StringToken("short") |
StringToken("string") |
StringToken("uint") |
StringToken("ulong") |
StringToken("ushort") ;
public static Rule InvocationExpression =
PrimaryExpression + Parentheses(Opt(ArgumentList)) ;
public static Rule ElementAccess =
PrimaryNoArrayCreationExpression + SquareBrackets(ArgumentList) ;
public static Rule ThisAccess =
StringToken("this") ;
public static Rule BaseAccess =
StringToken("base") + CharToken('.') + Identifier |
StringToken("base") + SquareBrackets(ArgumentList) ;
public static Rule PostIncrementExpression =
PrimaryExpression + StringToken('++') ;
public static Rule PostDecrementExpression =
PrimaryExpression + StringToken('--') ;
public static Rule ObjectCreationExpression =
StringToken("new") + Type + Parentheses(Opt(ArgumentList)) + Opt(ObjectOrCollect
ionInitializer) |
StringToken("new") + Type + ObjectOrCollectionInitializer ;
public static Rule ObjectOrCollectionInitializer =
ObjectInitializer |
CollectionInitializer ;
public static Rule ObjectInitializer =
CurlyBrackets(Opt(MemberInitializerList)) |
CurlyBrackets(MemberInitializerList + CharToken(',')) ;
public static Rule MemberInitializerList =
MemberInitializer |
MemberInitializerList + CharToken(',') + MemberInitializer ;
public static Rule MemberInitializer =
Identifier + CharToken('=') + InitializerValue ;
public static Rule InitializerValue =
Expression |
ObjectOrCollectionInitializer ;
public static Rule CollectionInitializer =
CurlyBrackets(ElementInitializerList) |
CurlyBrackets(ElementInitializerList + CharToken(',')) ;
public static Rule ElementInitializerList =
ElementInitializer |
ElementInitializerList + CharToken(',') + ElementInitializer ;
public static Rule ElementInitializer =
NonAssignmentExpression |
CurlyBrackets(ExpressionList) ;

public static Rule ExpressionList =


Expression |
ExpressionList + CharToken(',') + Expression ;
public static Rule ArrayCreationExpression =
StringToken("new") + NonArrayType + SquareBrackets(ExpressionList) + Opt(RankSpe
cifiers) + Opt(ArrayInitializer) |
StringToken("new") + ArrayType + ArrayInitializer |
StringToken("new") + RankSpecifier + ArrayInitializer ;
public static Rule DelegateCreationExpression =
StringToken("new") + DelegateType + Parentheses(Expression) ;
public static Rule AnonymousObjectCreationExpression =
StringToken("new") + AnonymousObjectInitializer ;
public static Rule AnonymousObjectInitializer =
CurlyBrackets(Opt(MemberDeclaratorList)) |
CurlyBrackets(MemberDeclaratorList + CharToken(',')) ;
public static Rule MemberDeclaratorList =
MemberDeclarator |
MemberDeclaratorList + CharToken(',') + MemberDeclarator ;
public static Rule MemberDeclarator =
SimpleName |
MemberAccess |
BaseAccess |
Identifier + CharToken('=') + Expression ;
public static Rule TypeofExpression =
StringToken("typeof") + Parentheses(Type) |
StringToken("typeof") + Parentheses(UnboundTypeName) |
StringToken("typeof") + Parentheses(StringToken("void")) ;
public static Rule UnboundTypeName =
Identifier + Opt(GenericDimensionSpecifier) |
Identifier :: Identifier + Opt(GenericDimensionSpecifier) |
UnboundTypeName + CharToken('.') + Identifier + Opt(GenericDimensionSpecifier) ;
public static Rule GenericDimensionSpecifier =
Brackets(Opt(Commas)) ;
public static Rule Commas =
CharToken(',') |
Commas + CharToken(',') ;
public static Rule CheckedExpression =
StringToken("checked") + Parentheses(Expression) ;
public static Rule UncheckedExpression =
StringToken("unchecked") + Parentheses(Expression) ;
public static Rule DefaultValueExpression =
StringToken("default") + Parentheses(Type) ;
public static Rule UnaryExpression =
PrimaryExpression |
CharToken('+') + UnaryExpression |
CharToken('-') + UnaryExpression |
CharToken('!') + UnaryExpression |
CharToken('~') + UnaryExpression |
PreIncrementExpression |
PreDecrementExpression |
CastExpression ;
public static Rule PreIncrementExpression =
StringToken('++') + UnaryExpression ;
public static Rule PreDecrementExpression =
StringToken('--') + UnaryExpression ;
public static Rule CastExpression =
Parentheses(Type) + UnaryExpression ;
public static Rule MultiplicativeExpression =
UnaryExpression |
MultiplicativeExpression + CharToken('*') + UnaryExpression |

MultiplicativeExpression + CharToken('/') + UnaryExpression |


MultiplicativeExpression + CharToken('%') + UnaryExpression ;
public static Rule AdditiveExpression =
MultiplicativeExpression |
AdditiveExpression + CharToken('+') + MultiplicativeExpression |
AdditiveExpression + ?MultiplicativeExpression ;
public static Rule ShiftExpression =
AdditiveExpression |
ShiftExpression + StringToken('<<') + AdditiveExpression |
ShiftExpression + RightShift + AdditiveExpression ;
public static Rule RelationalExpression =
ShiftExpression |
RelationalExpression + CharToken('<') + ShiftExpression |
RelationalExpression + CharToken('>') + ShiftExpression |
RelationalExpression + StringToken('<=') + ShiftExpression |
RelationalExpression + StringToken('>=') + ShiftExpression |
RelationalExpression + StringToken("is") + Type |
RelationalExpression + StringToken("as") + Type ;
public static Rule EqualityExpression =
RelationalExpression |
EqualityExpression + StringToken('==') + RelationalExpression |
EqualityExpression + StringToken('!=') + RelationalExpression ;
public static Rule AndExpression =
EqualityExpression |
AndExpression + CharToken('&') + EqualityExpression ;
public static Rule ExclusiveOrExpression =
AndExpression |
ExclusiveOrExpression + CharToken('^') + AndExpression ;
public static Rule InclusiveOrExpression =
ExclusiveOrExpression |
InclusiveOrExpression + CharToken('|') + ExclusiveOrExpression ;
public static Rule ConditionalAndExpression =
InclusiveOrExpression |
ConditionalAndExpression + StringToken('&&') + InclusiveOrExpression ;
public static Rule ConditionalOrExpression =
ConditionalAndExpression |
ConditionalOrExpression + StringToken('||') + ConditionalAndExpression ;
public static Rule NullCoalescingExpression =
ConditionalOrExpression |
ConditionalOrExpression + ?? NullCoalescingExpression ;
public static Rule ConditionalExpression =
NullCoalescingExpression |
NullCoalescingExpression + ? Expression : Expression ;
public static Rule LambdaExpression =
AnonymousFunctionSignature + StringToken('=>') + AnonymousFunctionBody ;
public static Rule AnonymousMethodExpression =
StringToken("delegate") + Opt(ExplicitAnonymousFunctionSignature) + Block ;
public static Rule AnonymousFunctionSignature =
ExplicitAnonymousFunctionSignature |
ImplicitAnonymousFunctionSignature ;
public static Rule ExplicitAnonymousFunctionSignature =
Parentheses(Opt(ExplicitAnonymousFunctionParameterList)) ;
public static Rule ExplicitAnonymousFunctionParameterList =
ExplicitAnonymousFunctionParameter |
ExplicitAnonymousFunctionParameterList + CharToken(',') + ExplicitAnonymousFunct
ionParameter ;
public static Rule ExplicitAnonymousFunctionParameter =
Opt(AnonymousFunctionParameterModifier) + Type + Identifier ;
public static Rule AnonymousFunctionParameterModifier =
StringToken("ref") |

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 =

UnaryExpression + AssignmentOperator + Expression ;


public static Rule AssignmentOperator =
CharToken('=') |
StringToken('+=') |
StringToken('-=') |
StringToken('*=') |
StringToken('/=') |
StringToken('%=') |
StringToken('&=') |
StringToken('|=') |
StringToken('^=') |
StringToken('<<=') |
RightShiftAssignment ;
public static Rule Expression =
NonAssignmentExpression |
Assignment ;
public static Rule NonAssignmentExpression =
ConditionalExpression |
LambdaExpression |
QueryExpression ;
public static Rule ConstantExpression =
Expression ;
public static Rule BooleanExpression =
Expression ;
public static Rule Statement =
LabeledStatement |
DeclarationStatement |
EmbeddedStatement ;
public static Rule EmbeddedStatement =
Block |
EmptyStatement |
ExpressionStatement |
SelectionStatement |
IterationStatement |
JumpStatement |
TryStatement |
CheckedStatement |
UncheckedStatement |
LockStatement |
UsingStatement |
YieldStatement ;
public static Rule Block =
CurlyBrackets(Opt(StatementList)) ;
public static Rule StatementList =
Statement |
StatementList + Statement ;
public static Rule EmptyStatement =
CharToken(';') ;
public static Rule LabeledStatement =
Identifier : Statement ;
public static Rule DeclarationStatement =
LocalVariableDeclaration + CharToken(';') |
LocalConstantDeclaration + CharToken(';') ;
public static Rule LocalVariableDeclaration =
LocalVariableType + LocalVariableDeclarators ;
public static Rule LocalVariableType =
Type |
Var ;
public static Rule LocalVariableDeclarators =
LocalVariableDeclarator |

LocalVariableDeclarators + CharToken(',') + LocalVariableDeclarator ;


public static Rule LocalVariableDeclarator =
Identifier |
Identifier + CharToken('=') + LocalVariableInitializer ;
public static Rule LocalVariableInitializer =
Expression |
ArrayInitializer ;
public static Rule LocalConstantDeclaration =
StringToken("const") + Type + ConstantDeclarators ;
public static Rule ConstantDeclarators =
ConstantDeclarator |
ConstantDeclarators + CharToken(',') + ConstantDeclarator ;
public static Rule ConstantDeclarator =
Identifier + CharToken('=') + ConstantExpression ;
public static Rule ExpressionStatement =
StatementExpression + CharToken(';') ;
public static Rule StatementExpression =
InvocationExpression |
ObjectCreationExpression |
Assignment |
PostIncrementExpression |
PostDecrementExpression |
PreIncrementExpression |
PreDecrementExpression ;
public static Rule SelectionStatement =
IfStatement |
SwitchStatement ;
public static Rule IfStatement =
StringToken("if") + Parentheses(BooleanExpression) + EmbeddedStatement |
StringToken("if") + Parentheses(BooleanExpression) + EmbeddedStatement + StringT
oken("else") + EmbeddedStatement ;
public static Rule SwitchStatement =
StringToken("switch") + Parentheses(Expression) + SwitchBlock ;
public static Rule SwitchBlock =
CurlyBrackets(Opt(SwitchSections)) ;
public static Rule SwitchSections =
SwitchSection |
SwitchSections + SwitchSection ;
public static Rule SwitchSection =
SwitchLabels + StatementList ;
public static Rule SwitchLabels =
SwitchLabel |
SwitchLabels + SwitchLabel ;
public static Rule SwitchLabel =
StringToken("case") + ConstantExpression :
StringToken("default") :
IterationStatement:
WhileStatement |
DoStatement |
ForStatement |
ForeachStatement ;
public static Rule WhileStatement =
StringToken("while") + Parentheses(BooleanExpression) + EmbeddedStatement ;
public static Rule DoStatement =
StringToken("do") + EmbeddedStatement + StringToken("while") + Parentheses(Boole
anExpression) + CharToken(';') ;
public static Rule ForStatement =
StringToken("for") + ( Opt(ForInitializer) + CharToken(';') + Opt(ForCondition)
+ CharToken(';') + Opt(ForIterator) + ) + EmbeddedStatement ;
public static Rule ForInitializer =

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(';') |

Yield + StringToken("break") + CharToken(';') |


Namespaces ;
public static Rule CompilationUnit =
Opt(ExternAliasDirectives) + Opt(UsingDirectives) + Opt(GlobalAttributes) |
Opt(NamespaceMemberDeclarations) ;
public static Rule NamespaceDeclaration =
StringToken("namespace") + QualifiedIdentifier + NamespaceBody + CharToken(';')O
pt ;
public static Rule QualifiedIdentifier =
Identifier |
QualifiedIdentifier + CharToken('.') + Identifier ;
public static Rule NamespaceBody =
CurlyBrackets(Opt(ExternAliasDirectives) + Opt(UsingDirectives) + Opt(NamespaceM
emberDeclarations)) ;
public static Rule ExternAliasDirectives =
ExternAliasDirective |
ExternAliasDirectives + ExternAliasDirective ;
public static Rule ExternAliasDirective =
StringToken("extern") + Alias + Identifier + CharToken(';') ;
public static Rule UsingDirectives =
UsingDirective |
UsingDirectives + UsingDirective ;
public static Rule UsingDirective =
UsingAliasDirective |
UsingNamespaceDirective ;
public static Rule UsingAliasDirective =
StringToken("using") + Identifier + CharToken('=') + NamespaceOrTypeName + CharT
oken(';') ;
public static Rule UsingNamespaceDirective =
StringToken("using") + NamespaceName + CharToken(';') ;
public static Rule NamespaceMemberDeclarations =
NamespaceMemberDeclaration |
NamespaceMemberDeclarations + NamespaceMemberDeclaration ;
public static Rule NamespaceMemberDeclaration =
NamespaceDeclaration |
TypeDeclaration ;
public static Rule TypeDeclaration =
ClassDeclaration |
StructDeclaration |
InterfaceDeclaration |
EnumDeclaration |
DelegateDeclaration ;
public static Rule QualifiedAliasMember =
Identifier :: Identifier + Opt(TypeArgumentList) ;
public static Rule ClassDeclaration =
Opt(Attributes) + Opt(ClassModifiers) + Opt(StringToken("partial")) + StringToke
n("class") + Identifier + Opt(TypeParameterList) |
Opt(ClassBase) + Opt(TypeParameterConstraintsClauses) + ClassBody + CharToken(';
')Opt ;
public static Rule ClassModifiers =
ClassModifier |
ClassModifiers + ClassModifier ;
public static Rule ClassModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("abstract") |
StringToken("sealed") |

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(';') ;

public static Rule ConstantModifiers =


ConstantModifier |
ConstantModifiers + ConstantModifier ;
public static Rule ConstantModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") ;
public static Rule ConstantDeclarators =
ConstantDeclarator |
ConstantDeclarators + CharToken(',') + ConstantDeclarator ;
public static Rule ConstantDeclarator =
Identifier + CharToken('=') + ConstantExpression ;
public static Rule FieldDeclaration =
Opt(Attributes) + Opt(FieldModifiers) + Type + VariableDeclarators + CharToken('
;') ;
public static Rule FieldModifiers =
FieldModifier |
FieldModifiers + FieldModifier ;
public static Rule FieldModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("static") |
StringToken("readonly") |
StringToken("volatile") ;
public static Rule VariableDeclarators =
VariableDeclarator |
VariableDeclarators + CharToken(',') + VariableDeclarator ;
public static Rule VariableDeclarator =
Identifier |
Identifier + CharToken('=') + VariableInitializer ;
public static Rule VariableInitializer =
Expression |
ArrayInitializer ;
public static Rule MethodDeclaration =
MethodHeader + MethodBody ;
public static Rule MethodHeader =
Opt(Attributes) + Opt(MethodModifiers) + Opt(StringToken("partial")) + ReturnTyp
e + MemberName |
Opt(TypeParameterList) |
Parentheses(Opt(FormalParameterList)) + Opt(TypeParameterConstraintsClauses) ;
public static Rule MethodModifiers =
MethodModifier |
MethodModifiers + MethodModifier ;
public static Rule MethodModifier =
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 ReturnType =


Type |
StringToken("void") ;
public static Rule MemberName =
Identifier |
InterfaceType + CharToken('.') + Identifier ;
public static Rule MethodBody =
Block |
CharToken(';') ;
public static Rule FormalParameterList =
FixedParameters |
FixedParameters + CharToken(',') + ParameterArray |
ParameterArray ;
public static Rule FixedParameters =
FixedParameter |
FixedParameters + CharToken(',') + FixedParameter ;
public static Rule FixedParameter =
Opt(Attributes) + Opt(ParameterModifier) + Type + Identifier + Opt(DefaultArgume
nt) ;
public static Rule DefaultArgument =
CharToken('=') + Expression ;
public static Rule ParameterModifier =
StringToken("ref") |
StringToken("out") |
StringToken("this") ;
public static Rule ParameterArray =
Opt(Attributes) + StringToken("params") + ArrayType + Identifier ;
public static Rule PropertyDeclaration =
Opt(Attributes) + Opt(PropertyModifiers) + Type + MemberName + CurlyBrackets(Acc
essorDeclarations) ;
public static Rule PropertyModifiers =
PropertyModifier |
PropertyModifiers + PropertyModifier ;
public static Rule PropertyModifier =
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 MemberName =
Identifier |
InterfaceType + CharToken('.') + Identifier ;
public static Rule AccessorDeclarations =
GetAccessorDeclaration + Opt(SetAccessorDeclaration) |
SetAccessorDeclaration + Opt(GetAccessorDeclaration) ;
public static Rule GetAccessorDeclaration =
Opt(Attributes) + Opt(AccessorModifier) + StringToken("get") + AccessorBody ;
public static Rule SetAccessorDeclaration =
Opt(Attributes) + Opt(AccessorModifier) + StringToken("set") + AccessorBody ;
public static Rule AccessorModifier =
StringToken("protected") |
StringToken("internal") |
StringToken("private") |
StringToken("protected") + StringToken("internal") |

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 =

Opt(Attributes) + StringToken("get") + CharToken(';') |


Opt(Attributes) + StringToken("set") + CharToken(';') |
Opt(Attributes) + StringToken("get") + CharToken(';') + Opt(Attributes) + String
Token("set") + CharToken(';') |
Opt(Attributes) + StringToken("set") + CharToken(';') + Opt(Attributes) + String
Token("get") + CharToken(';') ;
public static Rule InterfaceEventDeclaration =
Opt(Attributes) + Opt(StringToken("new")) + StringToken("event") + Type + Identi
fier + CharToken(';') ;
public static Rule InterfaceIndexerDeclaration =
Opt(Attributes) + Opt(StringToken("new")) + Type + StringToken("this") + SquareB
rackets(FormalParameterList) + CurlyBrackets(InterfaceAccessors) ;
public static Rule EnumDeclaration =
Opt(Attributes) + Opt(EnumModifiers) + StringToken("enum") + Identifier + Opt(En
umBase) + EnumBody + CharToken(';')Opt ;
public static Rule EnumBase =
: IntegralType ;
public static Rule EnumBody =
CurlyBrackets(Opt(EnumMemberDeclarations)) |
CurlyBrackets(EnumMemberDeclarations + CharToken(',')) ;
public static Rule EnumModifiers =
EnumModifier |
EnumModifiers + EnumModifier ;
public static Rule EnumModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") ;
public static Rule EnumMemberDeclarations =
EnumMemberDeclaration |
EnumMemberDeclarations + CharToken(',') + EnumMemberDeclaration ;
public static Rule EnumMemberDeclaration =
Opt(Attributes) + Identifier |
Opt(Attributes) + Identifier + CharToken('=') + ConstantExpression ;
public static Rule DelegateDeclaration =
Opt(Attributes) + Opt(DelegateModifiers) + StringToken("delegate") + ReturnType
|
Identifier + Opt(VariantTypeParameterList) |
Parentheses(Opt(FormalParameterList)) + Opt(TypeParameterConstraintsClauses) + C
harToken(';') ;
public static Rule DelegateModifiers =
DelegateModifier |
DelegateModifiers + DelegateModifier ;
public static Rule DelegateModifier =
StringToken("new") |
StringToken("public") |
StringToken("protected") |
StringToken("internal") |
StringToken("private") ;
public static Rule GlobalAttributes =
GlobalAttributeSections ;
public static Rule GlobalAttributeSections =
GlobalAttributeSection |
GlobalAttributeSections + GlobalAttributeSection ;
public static Rule GlobalAttributeSection =
SquareBrackets(GlobalAttributeTargetSpecifier + AttributeList) |
SquareBrackets(GlobalAttributeTargetSpecifier + AttributeList + CharToken(','))
;
public static Rule GlobalAttributeTargetSpecifier =

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 |

You might also like