This document contains things about Pegex that were written but seemed out of place in their original documents. Still they are possibly useful so live here fornow.
=head1 Pegex Overview
In the diagram below, there is a simple language called Foo. The diagram shows how Pegex can take a text grammar defining Foo and generate a parser that can parse Foo sources into data (abstract syntax trees).
Parsing a language called "Foo"
withthe Pegex toolset.
.-----------------------.
.--------------------. | Pegex::Compiler |
| Foo Language | |-----------------------| Serialize
Pegex is self-hosting. This means that the Pegex grammar language syntax is definedby a Pegex grammar! This is important because (just like any Pegex based language) it makes it easier to port to new programming languages. You can find the Pegex grammar forPegex grammars here: L<http://github.com/ingydotnet/pegex-pgx/>.
Pegex was originally inspired by Perl 6 Rules. It also takes ideas from Damian Conway's Perl 5 module, L<Regexp::Grammars>. Pegex tries to take the best ideas from these great works, and make them work in as many languages as possible. That's Acmeism.
=head1 Self Compilation Tricks
You can have some fun using Pegex to compile itself. First get the Pegex grammar repo:
This specifies a "receiving"class that can shape the results into something useful. Indeed, this is the exact guts of L<Pegex::Grammar::Pegex>.
=head1 A Real World EXAMPLE
L<TestML> is a new Acmeist unit test language. It is perfect forsoftware that needs to run equivalently in more than one language. In fact, Pegex itself is tested withTestML!!
TestML::Parser::Grammar is a subclass of Pegex::Grammar. It can be used to parse TestML files. TestML::Parser calls the L<parse()> method of the grammar witha TestML::AST object that receives callbacks whenvarious rules match, and uses the information to build a TestML::Document object.
Thus TestML is an Acmeist language written in Pegex. It can be easily ported to every language where Pegex exists. In fact, it must be ported to those languages in order to test the new Pegex implementation!
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
go to github issues (only if github is preferred repository)