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

NAME

6       Pegex::Parser - Pegex Parser Runtime
7

SYNOPSIS

9           use Pegex::Parser;
10           use SomeGrammarClass;
11           use SomeReceiverClass;
12
13           my $parser = Pegex::Parser->new(
14               grammar => SomeGrammarClass->new,
15               receiver => SomeReceiverClass->new,
16           );
17
18           my $result = $parser->parse($SomeInputText);
19

DESCRIPTION

21       Pegex::Parser is the Pegex component that provides the parsing engine
22       runtime. It requires a Grammar object and a Receiver object. It's
23       "parse()" method takes an input that is expected to be matched by the
24       grammar, and applies the grammar rules to the input. As the grammar is
25       applied, the receiver is notified of matches. The receiver is free to
26       do whatever it wishes, but often times it builds the data into a
27       structure that is commonly known as a Parse Tree.
28
29       When the parse method is complete it returns whatever object the
30       receiver has provided as the final result. If the grammar fails to
31       match the input along the way, the parse method will throw an error
32       with much information about the failure.
33

ATTRIBUTES

35       The Pegex::Parser "new" object constructor takes these attributes:
36
37       "grammar"
38           A Pegex::Grammar object. Required.
39
40       "receiver"
41           A Pegex::Receiver object.
42
43       "debug"
44           Boolean. Turn on debugging. Default false.
45
46       "recursion_limit"
47           Integer. Recursion level to terminate on. Default 0 (off).
48
49       "recursion_warn_limit"
50           Integer. Recursion level to warn on. Default 0 (off).
51
52       "iteration_limit"
53           Integer. Number of matches to try before terminating. Default 0
54           (off).
55

DEBUGGING

57       Pegex::Parser currently has 4 settings that are useful for debugging.
58       These can be set as Pegex::Parser object attributes, global variables
59       or environment variables:
60
61       "debug" or $Pegex::Parser::Debug or $ENV{PERL_PEGEX_DEBUG}
62           If set to a true value, it enables very useful trace messages for
63           every internal match operation.
64
65       "recursion_limit" or "Pegex::Parser::RecursionLimit" or
66       $ENV{PERL_PEGEX_RECURSION_LIMIT}
67           If set to a number greater than 0, Pegex::Parser will terminate
68           after that recursion level number is reached.
69
70       "recursion_warn_limit" or "Pegex::Parser::RecursionWarnLimit" or
71       $ENV{PERL_PEGEX_RECURSION_WARN_LIMIT}
72           If set to a number greater than 0, Pegex::Parser will issue a
73           warning every time that recursion level number is reached.
74
75       "iteration_limit" or "Pegex::Parser::IterationLimit" or
76       $ENV{PERL_PEGEX_ITERATION_LIMIT}
77           If set to a number greater than 0, Pegex::Parser will terminate
78           after that number of matches has been attempted.
79
80       "debug_indent" or $Pegex::Parser::DebugIndent or
81       $ENV{PERL_PEGEX_DEBUG_INDENT}
82           Tells the parser how many spaces should be used for indenting
83           debugging output. Default is 1.
84
85       "debug_color" or $Pegex::Parser::DebugColor or
86       $ENV{PERL_PEGEX_DEBUG_COLOR}
87           If enabled, it will color "got" and "not" events in the debugging
88           output ("bright_green" and "bright_red" respectively). Color will
89           be enabled by default for debugging. It requires Term::ANSIColor.
90
91           "always" or 1
92               Color is enabled.
93
94           "auto"
95               Color is enabled when STDERR is a tty.
96
97           "never" or 0
98               Color is disabled.
99
100           You can configure the specific colors used by appending them like
101           this:
102
103               PERL_PEGEX_DEBUG_COLOR='always, cyan bold, black on_yellow'
104
105           For available colors, see Term::ANSIColor
106
107       Note: Using these variables incurs a slight performance hit, but if you
108       don't
109             use them all the debugging code is optimized away.
110

SEE ALSO

112       ·   Pegex::Grammar
113
114       ·   Pegex::Receiver
115

AUTHOR

117       Ingy döt Net <ingy@cpan.org>
118
120       Copyright 2010-2018. Ingy döt Net.
121
122       This program is free software; you can redistribute it and/or modify it
123       under the same terms as Perl itself.
124
125       See <http://www.perl.com/perl/misc/Artistic.html>
126
127
128
129perl v5.28.0                      2018-11-12                  Pegex::Parser(3)
Impressum