Exporter |
NaturalDocs::Languages::Base |
A base class for all programming language parsers.
NaturalDocs:: | A base class for all programming language parsers. |
@EXPORT | |
EnumValuesType | How enum values are handled in the language. |
SOURCEFILEHANDLE | The handle of the source file currently being parsed. |
New | Creates and returns a new object. |
Name | Returns the language’s name. |
Extensions | Returns an arrayref of the language’s file extensions, or undef if none. |
SetExtensions | Replaces the arrayref of the language’s file extensions. |
ShebangStrings | Returns an arrayref of the language’s shebang strings, or undef if none. |
SetShebangStrings | Replaces the arrayref of the language’s shebang strings. |
PackageSeparator | Returns the language’s package separator string. |
PackageSeparatorWasSet | Returns whether the language’s package separator string was ever changed from the default. |
EnumValues | Returns the EnumValuesType that describes how the language handles enums. |
IgnoredPrefixesFor | Returns an arrayref of ignored prefixes for the passed TopicType, or undef if none. |
SetIgnoredPrefixesFor | Replaces the arrayref of ignored prefixes for the passed TopicType. |
HasIgnoredPrefixes | Returns whether the language has any ignored prefixes at all. |
CopyIgnoredPrefixesOf | Copies all the ignored prefix settings of the passed NaturalDocs::Languages::Base object. |
Parsing Functions | |
ParseFile | Parses the passed source file, sending comments acceptable for documentation to NaturalDocs::Parser->OnComment(). |
ParsePrototype | Parses the prototype and returns it as a NaturalDocs::Languages::Prototype object. |
ParseParameterLine | Parses a prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object. |
ParsePascalParameterLine | Parses a Pascal-like prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object. |
TypeBeforeParameter | Returns whether the type appears before the parameter in prototypes. |
IgnoredPrefixLength | Returns the length of the prefix that should be ignored in the index, or zero if none. |
Support Functions | |
StripOpeningSymbols | Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. |
StripOpeningJavaDocSymbols | Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. |
StripOpeningBlockSymbols | Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces. |
StripOpeningJavaDocBlockSymbols | Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces. |
StripClosingSymbol | Determines if the line contains a symbol, and if so, truncates it just before the symbol. |
NormalizePrototype | Normalizes a prototype. |
How enum values are handled in the language.
sub EnumValues
Returns the EnumValuesType that describes how the language handles enums.
sub IgnoredPrefixesFor #( type )
Returns an arrayref of ignored prefixes for the passed TopicType, or undef if none. The array is sorted so that the longest prefixes are first.
sub SetIgnoredPrefixesFor #( type, prefixes )
Replaces the arrayref of ignored prefixes for the passed TopicType.
sub CopyIgnoredPrefixesOf #( language )
Copies all the ignored prefix settings of the passed NaturalDocs::Languages::Base object.
Parses the passed source file, sending comments acceptable for documentation to NaturalDocs::Parser->OnComment(). This must be defined by a subclass.
sourceFile | The FileName of the source file 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 NaturalDocs::Parser::ParsedTopics from the file, or undef if none. |
scopeRecord | An arrayref of NaturalDocs::Languages::Advanced::ScopeChanges, or undef if none. |
sub ParsePrototype #( type, prototype )
Parses the prototype and returns it as a NaturalDocs::Languages::Prototype object.
type | The TopicType. |
prototype | The text prototype. |
A NaturalDocs::Languages::Prototype object.
sub ParseParameterLine #( line )
Parses a prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object.
This vesion assumes a C++ style line. If you need a Pascal style line, override this function to forward to ParsePascalParameterLine().
Function(parameter, type parameter, type parameter = value);
sub ParsePascalParameterLine #( line )
Parses a Pascal-like prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object. Pascal lines are as follows:
Function (name: type; name, name: type := value)
Also supports ActionScript lines
Function (name: type, name, name: type = value)
sub IgnoredPrefixLength #( name, type )
Returns the length of the prefix that should be ignored in the index, or zero if none.
name | The name of the symbol. |
type | The symbol’s TopicType. |
The length of the prefix to ignore, or zero if none.
sub StripOpeningSymbols #( lineRef, symbols )
Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. This only happens if the only thing before it on the line is whitespace.
lineRef | A reference to the line to check. |
symbols | An arrayref of the symbols to check for. |
If the line starts with any of the passed comment symbols, it will replace it in the line with spaces and return the symbol. If the line doesn’t, it will leave the line alone and return undef.
sub StripOpeningJavaDocSymbols #( lineRef, symbols )
Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. This only happens if the only thing before it on the line is whitespace and the next character after it is whitespace or the end of the line.
lineRef | A reference to the line to check. |
symbols | An arrayref of the symbols to check for. |
If the line starts with any of the passed comment symbols, it will replace it in the line with spaces and return the symbol. If the line doesn’t, it will leave the line alone and return undef.
sub StripOpeningBlockSymbols #( lineRef, symbolPairs )
Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces. This only happens if the only thing before it on the line is whitespace.
lineRef | A reference to the line to check. |
symbolPairs | An arrayref of the symbol pairs to check for. Pairs are specified as two consecutive array entries, with the opening symbol first. |
If the line starts with any of the opening symbols, it will replace it in the line with spaces and return the closing symbol. If the line doesn’t, it will leave the line alone and return undef.
sub StripOpeningJavaDocBlockSymbols #( lineRef, symbolPairs )
Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces. This only happens if the only thing before it on the line is whitespace and the next character is whitespace or the end of the line.
lineRef | A reference to the line to check. |
symbolPairs | An arrayref of the symbol pairs to check for. Pairs are specified as two consecutive array entries, with the opening symbol first. |
If the line starts with any of the opening symbols, it will replace it in the line with spaces and return the closing symbol. If the line doesn’t, it will leave the line alone and return undef.
our @EXPORT
Creates and returns a new object.
sub New #( name )
Returns the language’s package separator string.
sub PackageSeparator
Returns whether the language’s package separator string was ever changed from the default.
sub PackageSeparatorWasSet
Returns the EnumValuesType that describes how the language handles enums.
sub EnumValues
Returns an arrayref of ignored prefixes for the passed TopicType, or undef if none.
sub IgnoredPrefixesFor #( type )
Replaces the arrayref of ignored prefixes for the passed TopicType.
sub SetIgnoredPrefixesFor #( type, prefixes )
Returns whether the language has any ignored prefixes at all.
sub HasIgnoredPrefixes
Copies all the ignored prefix settings of the passed NaturalDocs::Languages::Base object.
sub CopyIgnoredPrefixesOf #( language )
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 )
Parses the prototype and returns it as a NaturalDocs::Languages::Prototype object.
sub ParsePrototype #( type, prototype )
Parses a prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object.
sub ParseParameterLine #( line )
Parses a Pascal-like prototype parameter line and returns it as a NaturalDocs::Languages::Prototype::Parameter object.
sub ParsePascalParameterLine #( line )
Returns whether the type appears before the parameter in prototypes.
sub TypeBeforeParameter
Returns the length of the prefix that should be ignored in the index, or zero if none.
sub IgnoredPrefixLength #( name, type )
Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces.
sub StripOpeningSymbols #( lineRef, symbols )
Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces.
sub StripOpeningJavaDocSymbols #( lineRef, symbols )
Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces.
sub StripOpeningBlockSymbols #( lineRef, symbolPairs )
Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces.
sub StripOpeningJavaDocBlockSymbols #( lineRef, symbolPairs )
Determines if the line contains a symbol, and if so, truncates it just before the symbol.
sub StripClosingSymbol #( lineRef, symbol )
Normalizes a prototype.
sub NormalizePrototype #( prototype )