Container
NAME
role Config::BINDish::AST::Container
- common declarations for any kind of value containers
DESCRIPTION
This role defines the interface and implementation of a container which is characterized by the value it contains and a type name associated with the value.
ATTRIBUTES
Mu $.payload
The actual value.
This attribute handles
all stadndard coercion methods found on Match and
Str classes. So, it is possible to coerce a container like this:
my Int(Config::BINDish::AST::Container:D) $some-count = $container;
or even easier:
my Int $some-count = Int($container);
Str:D $.type-name
The type name describing $.payload
. Normally borrowed from
Config::BINDish::Grammar::Value.
Defaults to "any".
METHODS
node-name()
Returns node class shortname
.
COERCIONS
The role supports specialized coercion from Config::BINDish::Grammar::Value:
my Config::BINDish::AST::Container $c = Config::BINDish::AST::Value($grammar-value);
In this case new container's payload and type name are set from corresponding attributes of
Config::BINDish::Grammar::Value
instance. The payload
is obtained using the coerced
method of
Config::BINDish::Grammar::Value.
For any other kind of value it is stored in the $.payload
attribute. And the type name is set to lowercased name of
the value's class. The only exception is any of Stringy
-consuming class for which the type name is set to
"sq-string".
multi ACCEPTS(Config::BINDish::AST::Container:D $val)
Matches $val.payload
against our $.payload
multi ACCEPTS(Any:D $val)
Matches $val
against our $.payload
.
SEE ALSO
Config::BINDish, Config::BINDish::AST
AUTHOR
Vadim Belman <[email protected]>