|
NAMEPegex::Receiver - Base Class for All Pegex ReceiversSYNOPSISpackage MyReceiver; use base 'Pegex::Receiver'; # Handle data for a specific rule sub got_somerulename { my ($self, $got) = @_; # ... process ... return $result; } # Handle data for any other rule sub gotrule { my ($self, $got) = @_; return $result; } # Pre-process sub initial { ... } # Post-process sub final { ...; return $final_result; } DESCRIPTIONIn Pegex, a receiver is the class object that a parser passes captured data to when a rule in a grammar matches a part of an input stream. A receiver provides action methods to turn parsed data into what the parser is intended to do.This is the base class of all Pegex receiver classes. It doesn't do much of anything, which is the correct thing to do. If you use this class as your receiver if won't do any extra work. See Pegex::Tree for a receiver base class that will help organize your matches by default. How A Receiver WorksA Pegex grammar is made up of named-rules, regexes, and groups. When a regex matches, the parser makes array of its capture strings. When a group matches, the parser makes an array of all the submatch arrays. In this way a parse tree forms.When a named-rule matches, an action method is called in the receiver class. The method is passed the current parse tree and returns what parser will consider the new parse tree. This makes for a very elegant and understandable API. APIThis section documents the methods that you can include in receiver subclass.
Methods
AUTHORIngy döt Net <ingy@cpan.org>COPYRIGHT AND LICENSECopyright 2010-2020. Ingy döt Net.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html>
Visit the GSP FreeBSD Man Page Interface. |