perlancar > Data-Sah > Data::Sah::Compiler

Download:
Data-Sah-0.35.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.35   Source  

NAME ^

Data::Sah::Compiler - Base class for Sah compilers (Data::Sah::Compiler::*)

VERSION ^

This document describes version 0.35 of Data::Sah::Compiler (from Perl distribution Data-Sah), released on 2014-12-19.

ATTRIBUTES ^

main => OBJ

Reference to the main Data::Sah object.

expr_compiler => OBJ

Reference to expression compiler object. In the perl compiler, for example, this will be an instance of Language::Expr::Compiler::Perl object.

METHODS ^

new() => OBJ

$c->compile(%args) => HASH

Compile schema into target language.

Arguments (* denotes required arguments, subclass may introduce others):

Compilation data

During compilation, compile() will call various hooks (listed below). The hooks will be passed compilation data ($cd) which is a hashref containing various compilation state and result. Compilation data is written to this hashref instead of on the object's attributes to make it easy to do recursive compilation (compilation of subschemas).

Subclasses may add more data (see their documentation).

Keys which contain input data, compilation state, and others (many of these keys might exist only temporarily during certain phases of compilation and will no longer exist at the end of compilation, for example clause will only exist during processing of a clause and will be seen by hooks like before_clause and after_clause, it will not be seen by before_all_clauses or after_compile):

Keys which contain compilation result:

Return value

The compilation data will be returned as return value. Main result will be in the result key. There is also ccls, and subclasses may put additional results in other keys. Final usable result might need to be pieced together from these results, depending on your needs.

Hooks

By default this base compiler does not define any hooks; subclasses can define hooks to implement their compilation process. Each hook will be passed compilation data, and should modify or set the compilation data as needed. The hooks that compile() will call at various points, in calling order, are:

$c->get_th

$c->get_fsh

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Data-Sah.

SOURCE ^

Source repository is at https://github.com/perlancar/perl-Data-Sah.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: