[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (%parser_state_initia
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization) (%parser_state_configuration, %parser_settable_configuration) (_setup_conf): split %parser_state_configuration in two, with %parser_state_initialization being not configurable anymore to match with the XS parser in which those configuration keys are not implemented. Two configuration keys, clickstyle and kbdinputstyle are duplicated in Texinfo::Translations::gdt(), so are put in %parser_state_configuration although they are not imp [...] |
Date: |
Mon, 03 Jan 2022 19:48:47 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 371dd496df * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
(%parser_state_configuration, %parser_settable_configuration) (_setup_conf):
split %parser_state_configuration in two, with %parser_state_initialization
being not configurable anymore to match with the XS parser in which those
configuration keys are not implemented. Two configuration keys, clickstyle and
kbdinputstyle are duplicated in Texinfo::Translations::gdt(), so are put in
%parser_state_configuration alth [...]
371dd496df is described below
commit 371dd496df6fe830f627c4b8e432f52ba4a32812
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jan 4 01:48:15 2022 +0100
* tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
(%parser_state_configuration, %parser_settable_configuration)
(_setup_conf): split %parser_state_configuration in two, with
%parser_state_initialization being not configurable anymore
to match with the XS parser in which those configuration keys
are not implemented.
Two configuration keys, clickstyle and kbdinputstyle are
duplicated in Texinfo::Translations::gdt(), so are put in
%parser_state_configuration although they are not implemented
in the XS parser.
* tp/Texinfo/ParserNonXS.pm (parse_texi_text): set first line to 1.
* tp/Texinfo/ParserNonXS.pm (_setup_conf),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser):
pass registrar object as is instead of copying.
* tp/Texinfo/Report.pm (line_warn, line_error, document_warn)
(document_error): accept an undef $configuration_informations
to be able to use a Texinfo::Report standalone without configuration
information.
---
ChangeLog | 24 ++++
tp/TODO | 3 +
tp/Texinfo/ParserNonXS.pm | 233 ++++++++++++++++++++---------------
tp/Texinfo/Report.pm | 18 ++-
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 12 +-
tp/t/test_parser_registrar.t | 44 +++++++
6 files changed, 225 insertions(+), 109 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 020246f19f..10691e739d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,30 @@
* TODO, NEWS: Change a couple of items.
+2022-01-03 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
+ (%parser_state_configuration, %parser_settable_configuration)
+ (_setup_conf): split %parser_state_configuration in two, with
+ %parser_state_initialization being not configurable anymore
+ to match with the XS parser in which those configuration keys
+ are not implemented.
+ Two configuration keys, clickstyle and kbdinputstyle are
+ duplicated in Texinfo::Translations::gdt(), so are put in
+ %parser_state_configuration although they are not implemented
+ in the XS parser.
+
+ * tp/Texinfo/ParserNonXS.pm (parse_texi_text): set first line to 1.
+
+ * tp/Texinfo/ParserNonXS.pm (_setup_conf),
+ tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser):
+ pass registrar object as is instead of copying.
+
+ * tp/Texinfo/Report.pm (line_warn, line_error, document_warn)
+ (document_error): accept an undef $configuration_informations
+ to be able to use a Texinfo::Report standalone without configuration
+ information.
+
2022-01-03 Patrice Dumas <pertusus@free.fr>
* Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
diff --git a/tp/TODO b/tp/TODO
index 664ffeff65..bb33fb622a 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -39,6 +39,9 @@ replaced, elided, elided_block types.
extra->'comment_at_end' and extra->'spaces_after_argument'
likely in many line commands
+'extra'->'menu_entry'->'index_ignore_chars'
+
+'extra'->'isindex' for nodes.
For converter writers,
'output_init_conf' and 'converter_init_conf'.
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 277296dbf7..bb155c52a8 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -99,7 +99,10 @@ sub N__($)
}
# these are the default values for the parser state
-my %parser_state_configuration = (
+# they could become configurable if moved to the next hash, but they
+# are not configurable/implemented in the XS parser, so they are best
+# left internal.
+my %parser_state_initialization = (
# these are the user-added indices. May be an array reference on names
# or an hash reference in the same format than %index_names below
'indices' => [],
@@ -120,53 +123,73 @@ my %parser_state_configuration = (
# as obtained by parsing the @macro
'merged_indices' => {}, # the key is merged in the value
'sections_level' => 0, # modified by raise/lowersections
- 'values' => {'txicommandconditionals' => 1},
- # the key is the name, the value the @set name
- # argument. A Texinfo tree may also be used.
- # The txicommandconditionals is a special value
- # that is set to mark that @ifcommandnotdefined
- # is implemented
+ # floats is not really needed, as it would be autogenerated,
+ # but this allows to have an output more similar to the XS parser output.
+ 'floats' => {}, # key is the normalized float type, value is
+ # an array reference holding all the floats
+ # of that type.
+
'info' => {
'input_encoding_name' => 'utf-8',
'input_perl_encoding' => 'utf-8'
},
- 'accept_internalvalue' => 0, # whether @txiinternalvalue should be added
- # to the tree or considered invalid.
- # currently set if called by gdt.
- 'clickstyle' => 'arrow',
- 'kbdinputstyle' => 'distinct',
- # this is not really needed, as it would be autogenerated,
- # but this allows to have an output more similar to the XS parser output.
- 'floats' => {},
'commands_info' => {}, # keys are @-commands names (without @) and
# values are arrays for global multiple
@-commands
# and a value for non multiple global
@-commands.
);
+# configurable parser state
+my %parser_state_configuration = (
+ 'accept_internalvalue' => 0, # whether @txiinternalvalue should be added
+ # to the tree or considered invalid.
+ # currently set if called by gdt.
+ 'clickstyle' => 'arrow', # duplicated in gdt but not set nor used by
the XS parser
+ 'kbdinputstyle' => 'distinct', # duplicated in gdt but not set nor used by
the XS parser
+ 'registrar' => undef, # Texinfo::Report object used for error
reporting.
+ 'values' => {'txicommandconditionals' => 1},
+ # the key is the name, the value the @set name
+ # argument.
+ # The txicommandconditionals is a special value
+ # that is set to mark that @ifcommandnotdefined
+ # is implemented
+);
+
+my %parser_settable_configuration = (
+ %parser_state_configuration,
+ %Texinfo::Common::default_parser_customization_values,
+);
+
my %parser_default_configuration = (
- %parser_state_configuration,
- %Texinfo::Common::default_parser_customization_values,
+ %parser_state_initialization,
+ %parser_settable_configuration
);
# the other possible keys for the parser state are:
#
# expanded_formats_hash each key comes from EXPANDED_FORMATS value is 1
-# index_names a structure holding the link between index
+# index_names a structure holding the link between index
# names, merged indices,
# initial value is %index_names in Texinfo::Common.
# context_stack stack of the contexts, more recent on top.
-# 'line' is added when on a line or
+# 'ct_line' is added when on a line or
# block @-command line,
-# 'def' is added instead if on a definition line.
-# 'preformatted' is added in block commands
-# where there is no paragraphs and spaces are kept
-# (format, example, display...)
-# 'math' is added in math block commands (displaymath)
-# 'rawpreformatted' is added in raw block commands
+# 'ct_def' is added instead if on a definition line.
+# 'ct_preformatted' is added in block commands
+# where there is no paragraphs and spaces are kept
+# (format, example, display and menu commands...)
+# 'ct_math' is added in math block commands
+# (displaymath) and @math brace commands
+# 'ct_rawpreformatted' is added in raw block commands
# (html, xml, docbook...)
-# 'menu' is added in menu commands
-# 'math', 'footnote', 'caption', 'shortcaption',
-# 'inlineraw' are also added when in those commands
+# 'ct_inlineraw' is added when in inlineraw
+# 'ct_brace_command' is added when in footnote,
+# caption, or shortcaption (in %context_brace_commands
+# that does not already start another context, ie not
+# not math).
+# context_command_stack the stack of @-commands. An @-command name can
+# be added each time a context is pushed on
+# 'context_stack'. Could be undef if there
+# is no @-command associated with the context.
# conditionals_stack a stack of conditional commands that are expanded.
# macro_stack stack of macros being expanded (more recent first)
# definfoenclose an hash, key is the command name, value is an array
@@ -174,27 +197,26 @@ my %parser_default_configuration = (
# input a stack, with last at bottom. Holds the opened files
# or text. Pending macro expansion or text expansion
# is also in that structure.
-# line_commands the same as %line_commands in Texinfo::Common,
+# line_commands the same as %line_commands in Texinfo::Common,
# but with index entry commands dynamically added
# close_paragraph_commands same as %close_paragraph_commands
# close_preformatted_commands same as %close_preformatted_commands
# no_paragraph_commands the same as %default_no_paragraph_commands
# below, with index
# entry commands dynamically added
-# simple_text_commands the same as %simple_text_commands below, but
+# simple_text_commands the same as %simple_text_commands below, but
# with index entry commands dynamically added
# current_node last seen node.
# current_section last seen section.
# nodes list of nodes.
# command_index associate a command name with an index name
-# floats key is the normalized float type, value is an array
-# reference holding all the floats.
# internal_references an array holding all the internal references.
# set points to the value set when initializing, for
# configuration items that are not to be overriden
# by @-commands. For example documentlanguage.
+
# A line information is an hash reference with the keys:
# line_nr the line number
# file_name the file name
@@ -204,7 +226,7 @@ my %parser_default_configuration = (
# text fragment, the second is the line information.
# The input structure is an array, the first is the most recently included
-# file. The last element may be a file if the parsing is done on a file,
+# file. The last element may be a file if the parsing is done on a file,
# with parse_texi_file, or simply pending text, if called as parse_texi_text.
# each element of the array is a hash reference. The key are:
# pending an array reference containing pending text fragments, either the
@@ -643,11 +665,13 @@ sub _setup_conf($$)
if (defined($conf)) {
foreach my $key (keys(%$conf)) {
- if (exists($parser_default_configuration{$key})) {
- if ($key eq 'info') {
- # merge hashes prefering values from $conf
- $parser->{'info'} = { %{$parser->{'info'}}, %{$conf->{'info'}} };
- } elsif ($key ne 'values' and ref($conf->{$key})) {
+ if (exists($parser_settable_configuration{$key})) {
+ #if ($key eq 'info') {
+ # # merge hashes prefering values from $conf
+ # $parser->{'info'} = { %{$parser->{'info'}}, %{$conf->{'info'}} };
+ #}
+ # we keep registrar instead of copying on purpose, to reuse the object
+ if ($key ne 'values' and $key ne 'registrar' and ref($conf->{$key})) {
$parser->{$key} = dclone($conf->{$key});
} else {
$parser->{$key} = $conf->{$key};
@@ -857,10 +881,10 @@ sub parse_texi_text($$;$$$$)
if (ref($text) eq '') {
$text = _text_to_lines($text);
}
- $lines_nr = [] if (!defined($lines_nr));
+ $lines_nr = 1 if (!defined($lines_nr));
if (ref($lines_nr) eq '') {
# $lines_nr is the first line number
- $lines_array = _complete_line_nr($text, $lines_nr, $file,
+ $lines_array = _complete_line_nr($text, $lines_nr, $file,
$macro, $fixed_line_number);
} else {
# $lines_nr is an array of line numbers
@@ -5973,15 +5997,14 @@ The following method is used to construct a new
C<Texinfo::Parser> object:
=item $parser = Texinfo::Parser::parser($options);
This method creates a new parser. The options may be provided as a hash
-reference. There are two types of option. The first type of option
-change the way the parser behaves; they are described right here. The
-other type of option allows giving the parser some information as if
-it came from texinfo code; for example, allow setting aliases (as with
-C<@alias>), values (as with C<@set>), or merged indices (as with
-C<@synindex>). These options are described below in L</Texinfo Parser
options>.
+reference.
=over
+=item CPP_LINE_DIRECTIVES
+
+Handle cpp like synchronization lines if set. Set in the default case.
+
=item EXPANDED_FORMATS
An array reference of the output formats for which C<@ifI<FORMAT>>
@@ -6010,6 +6033,35 @@ menu-related errors for 'menu'.
Texinfo::Report object reused by the parser to register errors.
+=begin comment
+
+Duplicated in gdt() but not implemented in the XS Parser, so not
+documented.
+
+=item clickstyle
+
+A string, the command name associated with C<@clickstyle>.
+
+=item kbdinputstyle
+
+A string, the C<@kbdinputstyle> style.
+
+=end comment
+
+=item documentlanguage
+
+A string corresponding to a document language set by C<@documentlanguage>.
+It overrides the document C<@documentlanguage> informations, if present.
+
+=item novalidate
+
+As if C<@novalidate> appeared at the beginning of the document.
+
+=item values
+
+A hash reference. Keys are names, values are the corresponding values.
+Same as values set by C<@set>.
+
=back
=back
@@ -6092,9 +6144,9 @@ described in
L<errors|Texinfo::Report/($error_warnings_list, $error_count) = err
=item $registrar = registered_errors($parser)
-C<$registrar> is a C<Texinfo::Report> object in which the errors
-and warnings encountered while parsing are registered. If a C<registrar>
-option is pased to the parser initialization it is reused, otherwise
+I<$registrar> is a C<Texinfo::Report> object in which the errors
+and warnings encountered while parsing are registered. If a I<registrar>
+passed to the parser initialization options, it is reused, otherwise
a new one is created.
=back
@@ -6136,7 +6188,6 @@ in the document.
If set, it means that C<@novalidate> was set in the document or as option
for the parser, in general from the command-line.
-
=back
=back
@@ -6163,12 +6214,13 @@ the association with @-commands is available through
C<labels_information>:
=over
-=item $labels_information, $targets_list = labels_information($parser)
+=item $labels_information, $targets_list, $nodes_list =
labels_information($parser)
I<$labels_information> is a hash reference whose keys are normalized
labels, and the associated value is the corresponding @-command.
I<$targets_list> is a list of labels @-command. Using
-I<$labels_information> is preferred.
+I<$labels_information> is preferred. I<$nodes_list> is a list of all
+the nodes appearing in the document.
=back
@@ -6307,6 +6359,12 @@ If C<name> is not set, it is set to the index name.
=back
+=begin comment
+
+The following are not implemented in the XS parser, and we do not want them
+to be used for the NonXS parser. They are not set to be configurable in the
+NonXS parser anyway (but could easily be).
+
=head2 Texinfo Parser options
Setting these options is the same as seeing some Texinfo constructs in the
@@ -6319,14 +6377,6 @@ document.
A hash reference. The key is a command name, the value is the alias, as
could be set by C<@alias>.
-=item clickstyle
-
-A string, the command name associated with C<@clickstyle>.
-
-=item documentlanguage
-
-A string corresponding to a document language set by C<@documentlanguage>.
-
=item indices
If it is a hash reference, the keys are index names, the values are
@@ -6339,10 +6389,6 @@ entered as
@defindex name
-=item kbdinputstyle
-
-A string, the C<@kbdinputstyle> style.
-
=item labels
A hash reference. Keys are normalized node names as described in the
@@ -6378,13 +6424,10 @@ is merged in the value. Same as setting C<@synindex>
or C<syncodeindex>.
Modifier of the sections level. Same as calling C<@lowersections> or
C<@raisesections>.
-=item values
-
-A hash reference. Keys are names, values are the corresponding values.
-Same as values set by C<@set>.
-
=back
+=end comment
+
=head1 TEXINFO TREE
A Texinfo tree element (called element because node is overloaded in
@@ -6392,20 +6435,18 @@ the Texinfo world) is an hash reference. There are
three main categories
of tree element. Tree elements associated with an @-command have a
C<cmdname> key holding the @-command name. Tree elements corresponding
to text fragments have a C<text> key holding the corresponding text.
-Finally, the last category is other containers (hereafter called
-containers) which in most cases have a C<type> key holding their name.
-Text fragments and @-command elements may also have an associated type
-when such information is needed.
-
-The children of an @-command or container element are in the array
-referred to with the C<args> key or with the C<contents> key. The
-C<args> key is for arguments of @-commands, either in braces or on
-the rest of the line after the command, depending on the type of command.
-C<args> is also used for the elements of a menu entry, as a menu
-entry is well-structured with a limited number of arguments.
-The C<contents> key array holds the contents of the texinfo
-code appearing within a block @-command, within a container,
-or within a C<@node> or sectioning @-command.
+Finally, the last category is other elements, which in most cases have
+a I<type> key holding their name. Text fragments and @-command elements
+may also have an associated type when such information is needed.
+
+The children of an @-command or of other container element are in the array
+referred to with the C<args> key or with the C<contents> key. The C<args> key
+is for arguments of @-commands, either in braces or on the rest of the line
+after the command, depending on the type of command. C<args> is also used for
+the elements of a menu entry, as a menu entry is well-structured with a limited
+number of arguments. The C<contents> key array holds the contents of the
+texinfo code appearing within a block @-command, within a container, or within
+a C<@node> or sectioning @-command.
Another important key for the elements is the C<extra> key which is
associated to a hash reference and holds all kinds of information that
@@ -6436,13 +6477,13 @@ The text fragment of text elements.
=item type
The type of the element. For C<@verb> it is the delimiter. But otherwise
-it is the type of element considered as a container. Frequent types
-encountered are I<paragraph> for a paragraph container,
+it is the type of element considered, in general a container. Frequent
+types encountered are I<paragraph> for a paragraph container,
I<brace_command_arg> for the container holding the brace @-commands
contents, I<line_arg> and I<block_line_arg> contain the arguments
appearing on the line of @-commands. Text fragments may have a type to
give an information of the kind of text fragment, for example
-C<empty_spaces_before_argument> is associated to spaces after a brace
+I<empty_spaces_before_argument> is associated to spaces after a brace
opening and before the argument. Many @-commands elements don't have
a type associated.
@@ -6516,8 +6557,6 @@ details below.
=item command_as_argument
-=item command_as_argument_kbd_code
-
This is the type of a command given in argument of C<@itemize>,
C<@table>, C<@vtable> or C<@ftable>. For example in
@@ -6893,7 +6932,7 @@ arguments.
=item spaces_before_argument
For @-commands with opening brace or comma followed by spaces held in a
-C<empty_spaces_before_argument> element, a reference to those spaces.
+I<empty_spaces_before_argument> element, a reference to those spaces.
For context brace commands, I<spaces_before_argument> is associated
with the @-command element, for other brace commands it is associated
with each argument elements.
@@ -6931,6 +6970,9 @@ in the B<HTML Xref> node.
An I<associated_section> key holds the tree element of the
sectioning command that follows the node.
+A node containing a menu have a I<menus> key which refers to an array of
+references to menu elements occuring in the node.
+
=item C<@part>
The next sectioning command is in I<part_associated_section>.
@@ -7119,19 +7161,6 @@ C<@inlinefmtifelse>, and 1 for other commands.
=back
-=head2 Other information set by the parser
-
-The parser creates an array of nodes and stores this in the
-I<nodes> key of the parser object.
-
-Each element in the tree corresponding to a node contaning a menu
-has a I<menus> key which refers to an array of references to menu
-elements occuring in the node.
-
-These are both used by the C<Texinfo::Structuring> module.
-
-
-
=head1 SEE ALSO
L<Texinfo manual|http://www.gnu.org/s/texinfo/manual/texinfo/>
diff --git a/tp/Texinfo/Report.pm b/tp/Texinfo/Report.pm
index 7efe1ff49c..422b9ba0cc 100644
--- a/tp/Texinfo/Report.pm
+++ b/tp/Texinfo/Report.pm
@@ -79,7 +79,8 @@ sub line_warn($$$$)
# otherwise out of source build fail since the file names are different
my ($directories, $suffix);
($file, $directories, $suffix) = fileparse($file)
- if ($configuration_informations->get_conf('TEST'));
+ if (defined($configuration_informations)
+ and $configuration_informations->get_conf('TEST'));
my $warn_line;
if ($line_number->{'macro'} ne '') {
$warn_line = sprintf(__p("Texinfo source file warning",
@@ -90,7 +91,8 @@ sub line_warn($$$$)
"%s:%d: warning: %s\n"),
$file, $line_number->{'line_nr'}, $text);
}
- warn $warn_line if ($configuration_informations->get_conf('DEBUG'));
+ warn $warn_line if (defined($configuration_informations)
+ and $configuration_informations->get_conf('DEBUG'));
push @{$self->{'errors_warnings'}},
{ 'type' => 'warning', 'text' => $text, 'error_line' => $warn_line,
%{$line_number} };
@@ -108,12 +110,14 @@ sub line_error($$$$)
my $file = $line_number->{'file_name'};
my ($directories, $suffix);
($file, $directories, $suffix) = fileparse($file)
- if ($configuration_informations->get_conf('TEST'));
+ if (defined($configuration_informations)
+ and $configuration_informations->get_conf('TEST'));
my $macro_text = '';
$macro_text = " (possibly involving \@$line_number->{'macro'})"
if ($line_number->{'macro'} ne '');
my $error_text = "$file:$line_number->{'line_nr'}: $text$macro_text\n";
- warn "$error_text" if ($configuration_informations->get_conf('DEBUG'));
+ warn $error_text if (defined($configuration_informations)
+ and $configuration_informations->get_conf('DEBUG'));
push @{$self->{'errors_warnings'}},
{ 'type' => 'error', 'text' => $text, 'error_line' => $error_text,
%{$line_number} };
@@ -129,7 +133,8 @@ sub document_warn($$$)
chomp($text);
my $warn_line;
- if (defined($configuration_informations->get_conf('PROGRAM'))
+ if (defined($configuration_informations)
+ and defined($configuration_informations->get_conf('PROGRAM'))
and $configuration_informations->get_conf('PROGRAM') ne '') {
$warn_line = sprintf(__p("whole document warning", "%s: warning: %s\n"),
$configuration_informations->get_conf('PROGRAM'), $text);
@@ -148,7 +153,8 @@ sub document_error($$$)
my $text = shift;
chomp($text);
my $error_line;
- if (defined($configuration_informations->get_conf('PROGRAM'))
+ if (defined($configuration_informations)
+ and defined($configuration_informations->get_conf('PROGRAM'))
and $configuration_informations->get_conf('PROGRAM') ne '') {
$error_line = sprintf("%s: %s\n",
$configuration_informations->get_conf('PROGRAM'), $text);
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index b424f30137..a035bcc4d0 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -14,6 +14,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# File to be loaded in conjunction with Parsetexi.xs module
+#
+# FIXME two customization keys are duplicated from the main parser in
+# gdt(), which are set and used by the NonXS parser, 'kbdinputstyle'
+# and 'clickstyle'. The XS does not set nor use those keys, so their values
+# are not passed in gdt().
+# As long as there is no other code that sets those keys to another value than
+# their default value, and that there are no translated strings containing the
+# @-commands whose output is modified by those customization keys, however,
+# the difference between the parsers won't have any visible effect.
package Texinfo::Parser;
@@ -66,7 +75,8 @@ sub parser (;$$)
if (defined($conf)) {
foreach my $key (keys (%$conf)) {
# Copy conf to parser object.
- if ($key ne 'values' and ref($conf->{$key})) {
+ # we keep registrar instead of copying on purpose, to reuse the object
+ if ($key ne 'values' and $key ne 'registrar' and ref($conf->{$key})) {
$parser->{$key} = dclone($conf->{$key});
} else {
$parser->{$key} = $conf->{$key};
diff --git a/tp/t/test_parser_registrar.t b/tp/t/test_parser_registrar.t
new file mode 100644
index 0000000000..21127fb7c4
--- /dev/null
+++ b/tp/t/test_parser_registrar.t
@@ -0,0 +1,44 @@
+use strict;
+
+use lib '.';
+use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
+
+use Test::More;
+
+BEGIN { plan tests => 7; }
+
+use Texinfo::Parser;
+use Texinfo::Report;
+
+# For consistent error message, use the C locale
+$ENV{LC_ALL} = 'C';
+
+ok(1, "modules loading");
+
+my $registrar = Texinfo::Report::new();
+
+my $initial_error = "Initial error";
+$registrar->document_error(undef, $initial_error);
+
+my $parser = Texinfo::Parser::parser({'registrar' => $registrar});
+
+# this also tests errors with line_errors not defined
+my $tree = $parser->parse_texi_text("\@end format\n");
+use Data::Dumper;
+
+my $parser_registrar = $parser->registered_errors();
+ok ($parser_registrar eq $registrar, 'reused registrar');
+
+my ($error_warnings_list, $error_count) = $parser_registrar->errors();
+
+ok ($error_count == 2, 'error count');
+
+my @errors_references = ($initial_error, ':1: unmatched `@end format\'');
+
+my $error_idx = 0;
+foreach my $error_message (@$error_warnings_list) {
+ ok ($error_message->{'type'} eq 'error', "error type $error_idx");
+ ok ($error_message->{'error_line'} eq $errors_references[$error_idx]."\n",
+ "error message $error_idx");
+ $error_idx++;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization) (%parser_state_configuration, %parser_settable_configuration) (_setup_conf): split %parser_state_configuration in two, with %parser_state_initialization being not configurable anymore to match with the XS parser in which those configuration keys are not implemented. Two configuration keys, clickstyle and kbdinputstyle are duplicated in Texinfo::Translations::gdt(), so are put in %parser_state_configuration although they are not imp [...],
Patrice Dumas <=