Protocol::MTProto::TLSchemaParser - a parser for TL schema declarations
Protocol::MTProto::TLSchemaParser
my $parser = Protocol::MTProto::TLSchemaParser->new; my $declarations = $parser->from_file( "telegram-l57.tl" ); # $declarations is now a reference to an array of Declarations
This subclass of Parser::MGC recognises the TL schema grammar. Or, at least, at this early version it recognises a subset of the grammar sufficient to pass its own unit tests and to parse the Telegram TL schema files. It does not yet recognise the full TL grammar.
Details of this module should be considered very subject to change as the implementation progresses.
The toplevel parse result is a reference to an array of Declaration instances. Each instance relates to a single declaration from the schema file.
Declaration
Responds to the following accessors:
A string containing the full identifier name, including the namespace prefix.
A 32bit number giving the parsed identification hash from the schema file, or undef if one was not given in the file. Note that this implementation does not generate numbers by CRC32 hashes at present.
undef
Either undef, or a reference to a non-empty array of Argument instances relating to the optional arguments of the declaration.
Argument
Either undef, or a reference to a non-empty array of Argument instances relating to the required arguments of the declaration.
A "Type" instance giving this constructor's result type.
Either the string constructor if the declaration was parsed before encountering the ---functions--- marker, or the string function if parsed after it.
constructor
---functions---
function
Each element of the args and optargs arrays for a "Declaration" will be an Argument instance. Each relates to a single positional argument of the declaration.
args
optargs
Either undef or a string giving the name of the argument.
A "Type" instance giving this argument's type.
Either undef, or a string giving the name of an earlier argument that this argument is conditional on.
Either undef, or a number giving the bitmask to apply to the earlier that argument this argument is conditional on.
True if the type of this argument was declared using the ! modifier.
!
The result_type of a "Declaration", and the type of an "Argument" will be a Type instance. At present, no attempt is made to intern the instances; comparison for equallity should be performed on the string name and its subtypes, not object identity.
result_type
type
Type
A string giving the name of the type.
True if the type is boxed; that is, its name begins with a capital letter.
True if the type is polymorphic.
If the type is polymorphic, a reference to an array of other "Type" instances corresponding to the subtypes. If the type is not polymorphic this accessor will not exist.
Paul Evans <leonerd@leonerd.org.uk>
To install Protocol::MTProto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::MTProto
CPAN shell
perl -MCPAN -e shell install Protocol::MTProto
For more information on module installation, please visit the detailed CPAN module installation guide.