NaturalDocs::Languages::Perl |
A subclass to handle the language variations of Perl.
NaturalDocs:: | A subclass to handle the language variations of Perl. |
Language Support | |
hereDocTerminators | An array of active Here Doc terminators, or an empty array if not active. |
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(). |
PreprocessFile | Overridden to support “=begin nd” and similar. |
Statement Parsing Functions | All functions here assume that the current position is at the beginning of a statement. |
TryToGetPackage | Determines whether the position is at a package declaration statement, and if so, generates a topic for it, skips it, and returns true. |
TryToGetBase | Determines whether the position is at a package base declaration statement, and if so, calls NaturalDocs::Parser->OnClassParent(). |
TryToGetFunction | Determines whether the position is at a function declaration statement, and if so, generates a topic for it, skips it, and returns true. |
TryToGetVariable | Determines if the position is at a variable declaration statement, and if so, generates a topic for it, skips it, and returns true. |
TryToGetVariableName | Determines if the position is at a variable name, and if so, skips it and returns the name. |
TryToGetListOfStrings | Attempts to retrieve a list of strings from the current position. |
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. |
GenericRegexpSkip | Advances the position one place through regexp code. |
GenericRegexpSkipUntilAfter | Advances the position via GenericRegexpSkip() 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. |
TryToSkipWhitespace | If the current position is on whitespace 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. |
TryToSkipPODComment | If the current position is on a POD comment symbol, skip past it and return true. |
TryToSkipString | If the current position is on a string delimiter, skip past the string and return true. |
TryToSkipHereDocDeclaration | If the current position is on a Here Doc declaration, add its terminators to hereDocTerminators and skip it. |
TryToSkipHereDocContent | If the current position is at the beginning of a line and there are entries in hereDocTerminators, skips lines until all the terminators are exhausted or we reach the end of the file. |
TryToSkipRegexp | If the current position is on a regular expression or a quote-like operator, skip past it and return true. |
Support Functions | |
IsStringed | Returns whether the position is after a string (dollar sign) character. |
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 name 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 topics from the file, or undef if none. |
scopeRecord | An arrayref of NaturalDocs::Languages::Advanced::ScopeChanges, or undef if none. |
sub PreprocessFile #( lines )
Overridden to support “=begin nd” and similar.
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 TryToGetBase #( indexRef, lineNumberRef )
Determines whether the position is at a package base declaration statement, and if so, calls NaturalDocs::Parser->OnClassParent().
use base [list of strings] @ISA = [list of strings] @[package]::ISA = [list of strings] our @ISA = [list of strings]
sub TryToGetVariable #( indexRef, lineNumberRef )
Determines if the position is at a variable declaration statement, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetListOfStrings #( indexRef, lineNumberRef )
Attempts to retrieve a list of strings from the current position. Returns an arrayref of them if any are found, or undef if none. It stops the moment it reaches a non-string, so “string1, variable, string2” will only return string1.
sub GenericSkip #( indexRef, lineNumberRef, noRegExps )
Advances the position one place through general code.
indexRef | A reference to the current index. |
lineNumberRef | A reference to the current line number. |
noRegExps | If set, does not test for regular expressions. |
sub GenericSkipUntilAfter #( indexRef, lineNumberRef, token, noRegExps, allowStringedClosingParens )
Advances the position via GenericSkip() until a specific token is reached and passed.
sub GenericRegexpSkip #( indexRef, lineNumberRef, inBrackets )
Advances the position one place through regexp code.
Also differs from GenericSkip() in that the parenthesis in $( and $) do count against the scope, where they wouldn’t normally.
indexRef | A reference to the current index. |
lineNumberRef | A reference to the current line number. |
inBrackets | Whether we’re in brackets or not. If true, we don’t care about matching braces and parenthesis. |
sub GenericRegexpSkipUntilAfter #( indexRef, lineNumberRef, token )
Advances the position via GenericRegexpSkip() 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 TryToSkipWhitespace #( indexRef, lineNumberRef )
If the current position is on whitespace it skips them and returns true. If there are a number of these in a row, it skips them all.
sub TryToSkipString #( indexRef, lineNumberRef, startContentIndexRef, endContentIndexRef )
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. |
startContentIndexRef | A reference to the variable in which to store the index of the first content token. May be undef. |
endContentIndexRef | A reference to the variable in which to store the index of the end of the content, which is one past the last content token. may be undef. |
Whether the position was at a string. The index, line number, and content index variabls will only be changed if true.
sub TryToSkipHereDocDeclaration #( indexRef, lineNumberRef )
If the current position is on a Here Doc declaration, add its terminators to hereDocTerminators and skip it.
sub TryToSkipHereDocContent #( indexRef, lineNumberRef )
If the current position is at the beginning of a line and there are entries in hereDocTerminators, skips lines until all the terminators are exhausted or we reach the end of the file.
Whether the position was on Here Doc content.
sub TryToSkipRegexp #( indexRef, lineNumberRef )
If the current position is on a regular expression or a quote-like operator, skip past it and return true.
An array of active Here Doc terminators, or an empty array if not active.
my @hereDocTerminators
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 )
Overridden to support “=begin nd” and similar.
sub PreprocessFile #( lines )
Determines whether the position is at a package declaration statement, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetPackage #( indexRef, lineNumberRef )
Determines whether the position is at a package base declaration statement, and if so, calls NaturalDocs::Parser->OnClassParent().
sub TryToGetBase #( indexRef, lineNumberRef )
A function called by NaturalDocs::Languages::Base-derived objects when their parsers encounter a declaration of inheritance.
sub OnClassParent #( class, parent, scope, using, resolvingFlags )
Determines whether the position is at a function declaration statement, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetFunction #( indexRef, lineNumberRef )
Determines if the position is at a variable declaration statement, and if so, generates a topic for it, skips it, and returns true.
sub TryToGetVariable #( indexRef, lineNumberRef )
Determines if the position is at a variable name, and if so, skips it and returns the name.
sub TryToGetVariableName #( indexRef, lineNumberRef )
Attempts to retrieve a list of strings from the current position.
sub TryToGetListOfStrings #( indexRef, lineNumberRef )
Advances the position one place through general code.
sub GenericSkip #( indexRef, lineNumberRef, noRegExps )
Advances the position via GenericSkip() until a specific token is reached and passed.
sub GenericSkipUntilAfter #( indexRef, lineNumberRef, token, noRegExps, allowStringedClosingParens )
Advances the position one place through regexp code.
sub GenericRegexpSkip #( indexRef, lineNumberRef, inBrackets )
Advances the position via GenericRegexpSkip() until a specific token is reached and passed.
sub GenericRegexpSkipUntilAfter #( 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 whitespace 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 a POD comment symbol, skip past it and return true.
sub TryToSkipPODComment #( indexRef, lineNumberRef )
If the current position is on a string delimiter, skip past the string and return true.
sub TryToSkipString #( indexRef, lineNumberRef, startContentIndexRef, endContentIndexRef )
If the current position is on a Here Doc declaration, add its terminators to hereDocTerminators and skip it.
sub TryToSkipHereDocDeclaration #( indexRef, lineNumberRef )
If the current position is at the beginning of a line and there are entries in hereDocTerminators, skips lines until all the terminators are exhausted or we reach the end of the file.
sub TryToSkipHereDocContent #( indexRef, lineNumberRef )
If the current position is on a regular expression or a quote-like operator, skip past it and return true.
sub TryToSkipRegexp #( indexRef, lineNumberRef )
Returns whether the position is after a string (dollar sign) character.
sub IsStringed #( index )
Loads the passed file, sends all appropriate comments to NaturalDocs::Parser->OnComment(), and breaks the rest into an arrayref of tokens.
sub ParseForCommentsAndTokens #( FileName sourceFile, string[] lineCommentSymbols, string[] blockCommentSymbols, string[] javadocLineCommentSymbols, string[] javadocBlockCommentSymbols )