NaturalDocs::Languages::CSharp |
A subclass to handle the language variations of C#.
NaturalDocs:: | A subclass to handle the language variations of C#. |
Language Support | |
Package Variables | |
classKeywords | An existence hash of all the acceptable class keywords. |
classModifiers | An existence hash of all the acceptable class modifiers. |
functionModifiers | An existence hash of all the acceptable function modifiers. |
variableModifiers | An existence hash of all the acceptable variable modifiers. |
enumTypes | An existence hash of all the possible enum types. |
impossibleTypeWords | An existence hash of all the reserved words that cannot be in a type. |
Interface Functions | |
PackageSeparator | Returns the package separator symbol. |
EnumValues | Returns the EnumValuesType that describes how the language handles enums. |
ParseFile | Parses the passed source file, sending comments acceptable for documentation to NaturalDocs::Parser->OnComment(). |
Statement Parsing Functions | All functions here assume that the current position is at the beginning of a statement. |
TryToGetNamespace | Determines whether the position is at a namespace declaration statement, and if so, adjusts the scope, skips it, and returns true. |
TryToGetClass | Determines whether the position is at a class declaration statement, and if so, generates a topic for it, skips it, and returns true. |
TryToGetUsing | Determines whether the position is at a using statement, and if so, adds it to the current scope, skips it, and returns true. |
TryToGetFunction | Determines if the position is on a function declaration, and if so, generates a topic for it, skips it, and returns true. |
TryToGetOverloadedOperator | Determines if the position is on an operator overload declaration, and if so, generates a topic for it, skips it, and returns true. |
TryToGetVariable | Determines if the position is on a variable declaration statement, and if so, generates a topic for each variable, skips the statement, and returns true. |
TryToGetEnum | Determines if the position is on an enum declaration statement, and if so, generates a topic for it. |
TryToGetType | Determines if the position is on a type identifier, and if so, skips it and returns it as a string. |
Low Level Parsing Functions | |
GenericSkip | Advances the position one place through general code. |
GenericSkipUntilAfter | Advances the position via GenericSkip() until a specific token is reached and passed. |
SkipRestOfStatement | Advances the position via GenericSkip() until after the end of the current statement, which is defined as a semicolon or a brace group. |
TryToSkipString | If the current position is on a string delimiter, skip past the string and return true. |
TryToSkipAttributes | If the current position is on an attribute section, skip it and return true. |
TryToSkipWhitespace | If the current position is on a whitespace token, a line break token, a comment, or a preprocessing directive, it skips them and returns true. |
TryToSkipComment | If the current position is on a comment, skip past it and return true. |
TryToSkipLineComment | If the current position is on a line comment symbol, skip past it and return true. |
TryToSkipMultilineComment | If the current position is on an opening comment symbol, skip past it and return true. |
TryToSkipPreprocessingDirective | If the current position is on a preprocessing directive, skip past it and return true. |
sub EnumValues
Returns the EnumValuesType that describes how the language handles enums.
sub ParseFile #( sourceFile, topicsList )
Parses the passed source file, sending comments acceptable for documentation to NaturalDocs::Parser->OnComment().
sourceFile | The FileName to parse. |
topicList | A reference to the list of NaturalDocs::Parser::ParsedTopics being built by the file. |
The array ( autoTopics, scopeRecord ).
autoTopics | An arrayref of automatically generated topics from the file, or undef if none. |
scopeRecord | An arrayref of NaturalDocs::Languages::Advanced::ScopeChanges, or undef if none. |
All functions here assume that the current position is at the beginning of a statement.
Note for developers: I am well aware that the code in these functions do not check if we’re past the end of the tokens as often as it should. We’re making use of the fact that Perl will always return undef in these cases to keep the code simpler.
sub TryToGetNamespace #( indexRef, lineNumberRef )
Determines whether the position is at a namespace declaration statement, and if so, adjusts the scope, skips it, and returns true.
The main reason we don’t create a Natural Docs topic for a namespace is because in order to declare class A.B.C in C#, you must do this:
namespace A.B { class C { ... } }
That would result in a namespace topic whose only purpose is really to qualify C. It would take the default page title, and thus the default menu title. So if you have files for A.B.X, A.B.Y, and A.B.Z, they all will appear as A.B on the menu.
If something actually appears in the namespace besides a class, it will be handled by NaturalDocs::Parser->AddPackageDelineators(). That function will add a package topic to correct the scope.
If the user actually documented it, it will still appear because of the manual topic.
sub GenericSkip #( indexRef, lineNumberRef )
Advances the position one place through general code.
indexRef | A reference to the current index. |
lineNumberRef | A reference to the current line number. |
sub GenericSkipUntilAfter #( indexRef, lineNumberRef, token )
Advances the position via GenericSkip() until a specific token is reached and passed.
sub SkipRestOfStatement #( indexRef, lineNumberRef )
Advances the position via GenericSkip() until after the end of the current statement, which is defined as a semicolon or a brace group. Of course, either of those appearing inside parenthesis, a nested brace group, etc. don’t count.
sub TryToSkipString #( indexRef, lineNumberRef )
If the current position is on a string delimiter, skip past the string and return true.
indexRef | A reference to the index of the position to start at. |
lineNumberRef | A reference to the line number of the position. |
Whether the position was at a string.
An existence hash of all the acceptable class keywords.
my %classKeywords
An existence hash of all the acceptable class modifiers.
my %classModifiers
An existence hash of all the acceptable function modifiers.
my %functionModifiers
An existence hash of all the acceptable variable modifiers.
my %variableModifiers
An existence hash of all the possible enum types.
my %enumTypes
An existence hash of all the reserved words that cannot be in a type.
my %impossibleTypeWords
Returns the package separator symbol.
sub PackageSeparator
Returns the EnumValuesType that describes how the language handles enums.
sub EnumValues
Parses the passed source file, sending comments acceptable for documentation to NaturalDocs::Parser->OnComment().
sub ParseFile #( sourceFile, topicsList )
The function called by NaturalDocs::Languages::Base-derived objects when their parsers encounter a comment suitable for documentation.
sub OnComment #( string[] commentLines, int lineNumber, bool isJavaDoc )
Determines whether the position is at a namespace declaration statement, and if so, adjusts the scope, skips it, and returns true.
sub TryToGetNamespace #( indexRef, lineNumberRef )
Determines whether the position is at a class declaration statement, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetClass #( indexRef, lineNumberRef )
Determines whether the position is at a using statement, and if so, adds it to the current scope, skips it, and returns true.
sub TryToGetUsing #( indexRef, lineNumberRef )
Determines if the position is on a function declaration, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetFunction #( indexRef, lineNumberRef )
Determines if the position is on an operator overload declaration, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetOverloadedOperator #( indexRef, lineNumberRef )
Determines if the position is on a variable declaration statement, and if so, generates a topic for each variable, skips the statement, and returns true.
sub TryToGetVariable #( indexRef, lineNumberRef )
Determines if the position is on an enum declaration statement, and if so, generates a topic for it.
sub TryToGetEnum #( indexRef, lineNumberRef )
Determines if the position is on a type identifier, and if so, skips it and returns it as a string.
sub TryToGetType #( indexRef, lineNumberRef )
Advances the position one place through general code.
sub GenericSkip #( indexRef, lineNumberRef )
Advances the position via GenericSkip() until a specific token is reached and passed.
sub GenericSkipUntilAfter #( indexRef, lineNumberRef, token )
Advances the position via GenericSkip() until after the end of the current statement, which is defined as a semicolon or a brace group.
sub SkipRestOfStatement #( indexRef, lineNumberRef )
If the current position is on a string delimiter, skip past the string and return true.
sub TryToSkipString #( indexRef, lineNumberRef )
If the current position is on an attribute section, skip it and return true.
sub TryToSkipAttributes #( indexRef, lineNumberRef )
If the current position is on a whitespace token, a line break token, a comment, or a preprocessing directive, it skips them and returns true.
sub TryToSkipWhitespace #( indexRef, lineNumberRef )
If the current position is on a comment, skip past it and return true.
sub TryToSkipComment #( indexRef, lineNumberRef )
If the current position is on a line comment symbol, skip past it and return true.
sub TryToSkipLineComment #( indexRef, lineNumberRef )
If the current position is on an opening comment symbol, skip past it and return true.
sub TryToSkipMultilineComment #( indexRef, lineNumberRef )
If the current position is on a preprocessing directive, skip past it and return true.
sub TryToSkipPreprocessingDirective #( indexRef, lineNumberRef )
Adds section and class topics to make sure the package is correctly represented in the documentation.
sub AddPackageDelineators