Group
Extension

Matches 8

Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex.pod ( view source; MetaCPAN )
guages (DSLs) that need to be used in several programming languages and
environments. Things like JSON, YAML, Markdown etc. It also great for writing
parsers/compilers that only need to work in one la
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Tutorial/JSON.pod ( view source; MetaCPAN )
#readme

=encoding utf8

=head1 How to write a JSON Parser in Pegex

This document details the creation of the CPAN module: L<Pegex::JSON> which is
a JSON parser/decoder written in Perl using the Pege
ngydotnet/pegex-json-pm>.

=head1 Test First

Have a look at
L<https://github.com/ingydotnet/pegex-json-pm/blob/master/test/test.t>.
This simple test has a bunch of small pieces of
JSON and their YAML
 equivalents. It asserts that when the JSON is decoded, it
will match the YAML.

The test is written in a testing language known as TestML. TestML just happens
to also use Pegex in its compiler. Both 
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Resources.pod ( view source; MetaCPAN )
 L<The TestML Grammar|https://github.com/ingydotnet/testml-pgx>

=item * L<A JSON Grammar|https://github.com/ingydotnet/json-pgx>

=item * L<A CronTab Grammar|https://github.com/ingydotnet/crontab-pgx
et/testml-pm>

=item * L<Pegex JSON Parser for Perl|https://github.com/ingydotnet/pegex-json-pm>

=item * L<A JSONY Decoder Perl Module|https://github.com/ingydotnet/json-pgx>

=item * L<A CronTab Par
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Miscellany.pod ( view source; MetaCPAN )
-----------------.       .------.
    |noun: /world/       |       | Foo grammar tree   |       | JSON |
    |                    |       '--------------------'       '------'
    ....................
ster/testml.pgx.yaml>

The grammar can also be precompiled to JSON:
L<https://github.com/ingydotnet/testml-pgx/blob/master/testml.pgx.json>

Pegex::Compiler further compiles this into a Perl 5 only gr
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Compiler.pm ( view source; MetaCPAN )
ema => ['Core', 'Perl'])
        ->dump_string($self->tree);
}

sub to_json {
    require JSON::PP;
    my $self = shift;
    JSON::PP
        ->new
        ->utf8
        ->canonical
        ->pretty
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Tutorial.pod ( view source; MetaCPAN )
e current tutorials.

=over

=item L<Pegex::Tutorial::JSON>

This is a very in-depth tutorial of the creation of the module L<Pegex::JSON>
(a JSON decoder that uses Pegex) and the thought that went in
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Compiler.pod ( view source; MetaCPAN )
ammar tree, which is simply a
nested data structure.

The grammar tree can be serialized to YAML, JSON, Perl, or any other
programming language. This makes it extremely portable. Pegex::Grammar has
me
 >>

Serialize the current grammar tree to YAML.

=item C<< $compiler->to_json() >>

Serialize the current grammar tree to JSON.

=item C<< $compiler->to_perl() >>

Serialize the current grammar tree 
 it trivial to update your grammar module after making
changes to the grammar file.

See L<Pegex::JSON> for an example.

=head1 AUTHOR

Ingy döt Net <ingy@cpan.org>

=head1 COPYRIGHT AND LICENSE

Cop
Pegex ( I/IN/INGY/Pegex-0.75.tar.gz, INGY, 2020; MetaCPAN )
Pegex/lib/Pegex/Syntax.pod ( view source; MetaCPAN )
rom a Pegex grammar for parsing JSON:

    json: hash | array
    array: / LSQUARE / ( node* % / COMMA / ) (
        / RSQUARE / | `missing ']'` )

This is saying: "json is either a hash or array. arr

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.