1Pegex(3)              User Contributed Perl Documentation             Pegex(3)
2
3
4

NAME

6       Pegex - Pegex Parser Generator
7

SYNOPSIS

9           use Pegex;
10           my $data = pegex($grammar)->parse($input);
11
12       or more explicitly:
13
14           use Pegex::Grammar;
15           use Pegex::AST;
16           my $grammar = Pegex::Grammar->new(
17               grammar => $grammar,
18               receiver => Pegex::AST->new(),
19           );
20           $grammar->parse($input, 'rule_name');
21           my $data = $grammar->receiver->data;
22
23       or customized explicitly:
24
25           package MyGrammar;
26           use Pegex::Grammar -base;
27           has grammar_text => "some grammar text goes here";
28
29           package MyReceiver;
30           use Pegex::Receiver -base;
31           got_some_rule { ... }
32           got_other_rule { ... }
33
34           package main;
35           use MyReceiver;
36           use MyGrammar;
37           my $receiver = MyReceiver->new();
38           my $grammar = MyGrammar->new(
39               receiver => $receiver,
40           );
41           $grammar->parse($input);
42           my $data = $receiver->data;
43

DESCRIPTION

45       Pegex is a Acmeist parser framework. It is a PEG parser grammar syntax,
46       combined with PCRE compatible regular expressions as the match tokens.
47       Pegex draws heavily from Perl 6 rules, but works equivalently in many
48       modern programming languages.
49
50       With Pegex you can easily define new mini languages that can be easily
51       compiled in many programming languages.
52

A REAL WORLD EXAMPLE

54       TestML is a new Acmeist unit test language. It is perfect for software
55       that needs to run equivalently in more than one language.
56
57       TestML has a language specification grammar:
58       http://www.testml.org/specification/language/
59
60       The Perl6 implementation of TestML uses this grammar in:
61       http://github.com/ingydotnet/testml-pm6/blob/master/lib/TestML/Parser/Grammar.pm
62
63       All other implementations of TestML use this Pegex grammar:
64       http://github.com/ingydotnet/testml-pgx/blob/master/testml.pgx
65
66       In Perl 5, Pegex::Compiler is used to compile the grammar into this
67       simple data structure (shown in YAML):
68       http://github.com/ingydotnet/testml-pgx/blob/master/grammar.yaml
69
70       The grammar can also be precompiled to JSON:
71       http://github.com/ingydotnet/testml-pgx/blob/master/grammar.json
72
73       Pegex::Compiler further compiles this into a Perl 5 only graamar tree,
74       which becomes this module:
75       http://github.com/ingydotnet/testml-pm/blob/master/lib/TestML/Parser/Grammar.pm
76
77       TestML::Parser::Grammar is a subclass of Pegex::Grammar. It can be used
78       to parse TestML files. TestML::Parser calls the "parse()" method of the
79       grammar with a TestML::Receiver object that receives callbacks when
80       various rules match, and uses the information to build a
81       TestML::Document object.
82       http://github.com/ingydotnet/testml-pm/blob/master/lib/TestML/Parser.pm
83

REPOSITORY AND COMMUNITY

85       The Pegex module can be found on CPAN and on GitHub:
86       http://github.com/ingydotnet/pegex-pm
87       <http://github.com/ingydotnet/pegex-pm>.
88
89       Please join the Pegex discussion on #pegex on irc.freenode.net.
90

AUTHOR

92       Ingy doet Net <ingy@cpan.org>
93
95       Copyright (c) 2010. Ingy doet Net.
96
97       This program is free software; you can redistribute it and/or modify it
98       under the same terms as Perl itself.
99
100       See http://www.perl.com/perl/misc/Artistic.html
101
102
103
104perl v5.12.2                      2010-10-10                          Pegex(3)
Impressum