NAME

Protocol::MTProto::TLSchemaParser - a parser for TL schema declarations

SYNOPSIS

my $parser = Protocol::MTProto::TLSchemaParser->new;

my $declarations = $parser->from_file( "telegram-l57.tl" );

# $declarations is now a reference to an array of Declarations

DESCRIPTION

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.

RETURNED TYPES

Declaration

The toplevel parse result is a reference to an array of Declaration instances. Each instance relates to a single declaration from the schema file.

Responds to the following accessors:

ident

A string containing the full identifier name, including the namespace prefix.

number

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.

optargs

Either undef, or a reference to a non-empty array of Argument instances relating to the optional arguments of the declaration.

args

Either undef, or a reference to a non-empty array of Argument instances relating to the required arguments of the declaration.

result_type

A "Type" instance giving this constructor's result type.

kind

Either the string constructor if the declaration was parsed before encountering the ---functions--- marker, or the string function if parsed after it.

Argument

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.

Responds to the following accessors:

name

Either undef or a string giving the name of the argument.

type

A "Type" instance giving this argument's type.

conditional_on

Either undef, or a string giving the name of an earlier argument that this argument is conditional on.

condition_mask

Either undef, or a number giving the bitmask to apply to the earlier that argument this argument is conditional on.

has_pling

True if the type of this argument was declared using the ! modifier.

Type

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.

Responds to the following accessors:

name

A string giving the name of the type.

is_boxed

True if the type is boxed; that is, its name begins with a capital letter.

is_polymorphic

True if the type is polymorphic.

subtypes (optional)

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.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>