Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar CS;
- import Unicode;
- start: namespaceOrTypeName EOF;
- /**********
- *
- * Basic Concepts
- *
- **********/
- namespaceName
- : namespaceOrTypeName
- ;
- typeName
- : namespaceOrTypeName
- ;
- namespaceOrTypeName
- : Identifier typeArgumentList?
- | namespaceOrTypeName '.' Identifier typeArgumentList?
- | qualifiedAliasMember
- ;
- /**********
- *
- * Types
- *
- **********/
- type
- : (typeName
- | simpleType
- | enumType
- | classType
- | interfaceType
- | delegateType
- | typeParameter
- | 'void' '*'
- ) ('?' | rankSpecifiers | '*')*
- ;
- valueType
- : structType
- | enumType
- ;
- structType
- : typeName
- | simpleType
- | nullableType
- ;
- simpleType
- : numericType
- | 'bool'
- ;
- numericType
- : integralType
- | floatingPointType
- | 'decimal'
- ;
- integralType
- : 'sbyte'
- | 'byte'
- | 'short'
- | 'ushort'
- | 'int'
- | 'uint'
- | 'long'
- | 'ulong'
- | 'char'
- ;
- floatingPointType
- : 'float'
- | 'double'
- ;
- nullableType
- : nonNullableValueType '?'
- ;
- nonNullableValueType
- : type
- ;
- enumType
- : typeName
- ;
- referenceType
- : classType
- | interfaceType
- | arrayType
- | delegateType
- ;
- classType
- : typeName
- | 'object'
- | 'dynamic'
- | 'string'
- ;
- interfaceType
- : typeName
- ;
- rankSpecifiers
- : rankSpecifier
- | rankSpecifiers rankSpecifier
- ;
- rankSpecifier
- : '[' dimSeparators? ']'
- ;
- dimSeparators
- : ','
- | dimSeparators ','
- ;
- delegateType
- : typeName
- ;
- typeArgumentList
- : '<' typeArguments '>'
- ;
- typeArguments
- : typeArgument
- | typeArguments ',' typeArgument
- ;
- typeArgument
- : type
- ;
- typeParameter
- : Identifier
- ;
- pointerType
- : unmanagedType '*'
- | 'void' '*'
- ;
- unmanagedType
- : type
- ;
- qualifiedAliasMember
- : Identifier '::' Identifier typeArgumentList?
- ;
- arrayType
- : nonArrayType rankSpecifiers
- ;
- nonArrayType
- : type
- ;
- /**********
- *
- * Identifiers
- *
- **********/
- Identifier
- : AvailableIdentifier
- | '@' IdentifierOrKeyword
- ;
- AvailableIdentifier
- : IdentifierOrKeyword
- ;
- IdentifierOrKeyword
- : IdentifierStartCharacter IdentifierPartCharacter*
- ;
- IdentifierStartCharacter
- : LetterCharacter
- | '_'
- ;
- fragment
- IdentifierPartCharacter
- : LetterCharacter
- | DecimalDigitCharacter
- | ConnectingCharacter
- | CombiningCharacter
- | FormattingCharacter
- ;
- fragment
- LetterCharacter
- : UNICODE_CLASS_LU
- | UNICODE_CLASS_LL
- | UNICODE_CLASS_LT
- | UNICODE_CLASS_LM
- | UNICODE_CLASS_LO
- | UNICODE_CLASS_NL
- ;
- fragment
- CombiningCharacter
- : UNICODE_CLASS_MN
- | UNICODE_CLASS_MC
- ;
- fragment
- DecimalDigitCharacter
- : UNICODE_CLASS_ND
- ;
- fragment
- ConnectingCharacter
- : UNICODE_CLASS_PC
- ;
- fragment
- FormattingCharacter
- : UNICODE_CLASS_CF
- ;
- /**********
- *
- * Whitespace and comments
- *
- **********/
- WS : [ \t\r\n\u000C]+ -> skip
- ;
- COMMENT
- : '/*' .*? '*/' -> skip
- ;
- LINE_COMMENT
- : '//' ~[\r\n]* -> skip
- ;
- DIRECTIVE
- : '#' ~[\r\n]* -> skip
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement