NaturalDocs:: Languages

A package to manage all the programming languages Natural Docs supports.

Usage and Dependencies

Summary
A package to manage all the programming languages Natural Docs supports.
An array of all the defined languages.
A hash of all the defined languages’ extensions.
A hash of all the defined languages’ strings to search for in the shebang (#!)
Returns the language of the passed source file.
Returns whether the language of the passed file is supported.
Separates a class from its member.
These functions are not for general use.
Adds a <NaturalDocs::Languages::Language> object to the package.

Variables

languages

my @languages

An array of all the defined languages.  Each entry is a <NaturalDocs::Languages::Language> object.

extensions

my %extensions

A hash of all the defined languages’ extensions.  The keys are the all-lowercase extensions, and the values are indexes into languages.

shebangs

my %shebangs

A hash of all the defined languages’ strings to search for in the shebang (#!) line.  The keys are the all-lowercase strings, and the values are indexes into languages.

Functions

LanguageOf

sub LanguageOf #(sourceFile)

Returns the language of the passed source file.

Parameters

sourceFileThe source file to get the language of.

Returns

A <NaturalDocs::Languages::Language> object for the passed file, or undef if the file is not a recognized language.

IsSupported

sub IsSupported #(file)

Returns whether the language of the passed file is supported.

Parameters

fileThe file to test.

Returns

Whether the file’s language is supported.

SeparateMember

sub SeparateMember #(string)

Separates a class from its member.  If there are multiple member separators in the string, it assumes the last one is correct and all previous ones are part of the class name.  For example, “package::class::function” will be split into “package::class” and “function”.

Parameters

stringThe string of text to separate.

Returns

An array.  If the string had a member separator in it, the first item will be the class and the second the identifier.  If there was no member separator, there will only be one item, which will contain the original string.

Interface Functions

These functions are not for general use.  They’re interfaces between specific packages and should only be used where noted.

Add

sub Add #(languageObject)

Adds a <NaturalDocs::Languages::Language> object to the package.

Usage

This function is only to be called by NaturalDocs::Languages::Base->New().  Languages self-add when created, so there is no need to call anywhere else.

Parameters

languageObjectA reference to the NaturalDocs::Languages::Base-derived object.
my @languages
An array of all the defined languages.
my %extensions
A hash of all the defined languages’ extensions.
my %shebangs
A hash of all the defined languages’ strings to search for in the shebang (#!)
sub LanguageOf #(sourceFile)
Returns the language of the passed source file.
sub IsSupported #(file)
Returns whether the language of the passed file is supported.
sub SeparateMember #(string)
Separates a class from its member.
sub Add #(languageObject)
Adds a NaturalDocs::Languages::Language object to the package.
A package to handle the command line and various other program settings.
sub New
Creates and returns a new object.
A base class for all programming language parsers.