texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Common.pm (%parser_state_configurati


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%parser_state_configuration) (%parser_inner_configuration, %parser_settable_configuration), tp/Texinfo/ParserNonXS.pm (parser), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): move %parser_state_configuration, %parser_inner_configuration and %parser_settable_configuration to Texinfo::Common. Update Parsetexi.pm to set the same keys as ParserNonXS parser. Inline _setup_conf in ParserNonXS.pm parser.
Date: Mon, 20 May 2024 06:10:45 -0400

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 99cd7982c8 * tp/Texinfo/Common.pm (%parser_state_configuration) 
(%parser_inner_configuration, %parser_settable_configuration), 
tp/Texinfo/ParserNonXS.pm (parser), tp/Texinfo/XS/parsetexi/Parsetexi.pm 
(parser): move %parser_state_configuration, %parser_inner_configuration and 
%parser_settable_configuration to Texinfo::Common.  Update Parsetexi.pm to set 
the same keys as ParserNonXS parser.  Inline _setup_conf in ParserNonXS.pm 
parser.
99cd7982c8 is described below

commit 99cd7982c807bd934dc2773e9b0dd2eb848f7bbd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon May 20 12:10:45 2024 +0200

    * tp/Texinfo/Common.pm (%parser_state_configuration)
    (%parser_inner_configuration, %parser_settable_configuration),
    tp/Texinfo/ParserNonXS.pm (parser),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): move
    %parser_state_configuration, %parser_inner_configuration and
    %parser_settable_configuration to Texinfo::Common.  Update
    Parsetexi.pm to set the same keys as ParserNonXS parser.  Inline
    _setup_conf in ParserNonXS.pm parser.
---
 ChangeLog                            |  11 ++++
 tp/Texinfo/Common.pm                 |  32 ++++++++++-
 tp/Texinfo/ParserNonXS.pm            | 108 ++++++++++++-----------------------
 tp/Texinfo/XS/parsetexi/Parsetexi.pm |  23 ++++----
 4 files changed, 89 insertions(+), 85 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ee60012e2..e1c2514b3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-20  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (%parser_state_configuration)
+       (%parser_inner_configuration, %parser_settable_configuration),
+       tp/Texinfo/ParserNonXS.pm (parser),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): move
+       %parser_state_configuration, %parser_inner_configuration and
+       %parser_settable_configuration to Texinfo::Common.  Update
+       Parsetexi.pm to set the same keys as ParserNonXS parser.  Inline
+       _setup_conf in ParserNonXS.pm parser.
+
 2024-05-20  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/api.c (initialize_parsing),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 690888f2d5..d4f0953c5f 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -161,6 +161,36 @@ my %parser_options = (
 # also used in util/txicustomvars
 our %default_parser_customization_values = (%common_parser_options, 
%parser_options);
 
+# customizable parser state, can be passed to the parser function.
+my %parser_state_configuration = (
+  'registrar' => undef,        # Texinfo::Report object used for error
+                               # reporting.
+
+  # parsed document parsing information still relevant after parsing
+  '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
+);
+
+# parser keys related to customization
+# Set when initializing a parser, but never from command-line/init files
+my %parser_inner_configuration = (
+  'accept_internalvalue' => 0, # whether @txiinternalvalue should be added
+                               # to the tree or considered invalid.
+                               # currently set if called by gdt.
+);
+
+# configurable parser state
+our %parser_settable_configuration = (
+  %parser_inner_configuration,
+  %parser_state_configuration,
+  %default_parser_customization_values,
+);
+
+
 # check that settable commands are contained in global commands
 # from command_data.txt
 if (0) {
@@ -2160,7 +2190,7 @@ and C<plaintext>.
 =back
 
 TODO: undocumented
-%null_device_file %default_parser_customization_values 
%multiple_at_command_options %unique_at_command_options 
%converter_cmdline_options %default_main_program_customization_options 
%converter_customization_options %document_settable_at_commands %def_map 
%command_structuring_level %level_to_structuring_command 
%encoding_name_conversion_map %text_brace_no_arg_commands
+%null_device_file %default_parser_customization_values 
%parser_settable_configuration %multiple_at_command_options 
%unique_at_command_options %converter_cmdline_options 
%default_main_program_customization_options %converter_customization_options 
%document_settable_at_commands %def_map %command_structuring_level 
%level_to_structuring_command %encoding_name_conversion_map 
%text_brace_no_arg_commands
 
 =head1 @-COMMAND INFORMATION
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 566a97dde2..923047536f 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -140,7 +140,8 @@ our $VERSION = '7.1dev';
 
 
 # these are the default values for the parsing state of a document.
-# Some could become configurable if moved to %parser_state_configuration,
+# Some could become configurable if moved to Texinfo::Common
+# %parser_state_configuration,
 # but they are not configurable/implemented in the XS parser, so they are
 # best left internal.  Could be relevant to reuse for diverse sources
 # of input associated to the same document.
@@ -230,47 +231,13 @@ my %parser_state_initialization = 
(%parser_document_state_initialization,
 # command_index           associate a command name with an index name.
 # index_entry_commands    index entry commands, including added index commands.
 
-# customizable parser state, can be passed to the parser function.
-my %parser_state_configuration = (
-  'registrar' => undef,        # Texinfo::Report object used for error
-                               # reporting.
-
-  # parsed document parsing information still relevant after parsing
-  '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
-);
-
-
 # parser keys related to customization
-# Set when initializing a parser, but never from command-line/init files
-my %parser_inner_configuration = (
-  'accept_internalvalue' => 0, # whether @txiinternalvalue should be added
-                               # to the tree or considered invalid.
-                               # currently set if called by gdt.
-);
-
 # expanded_formats_hash   each key comes from EXPANDED_FORMATS, value is 1
 # set                     points to the value set when initializing, for
 #                         configuration items that are not to be overriden
 #                         by @-commands.  For example documentlanguage.
 # conf                    For get_conf
 
-# configurable parser state
-# customization options are in Texinfo::Common because all the
-# customization options informations is gathered here, and also
-# because it is used in other codes, in particular the XS parser.
-my %parser_settable_configuration = (
-  %parser_inner_configuration,
-  %parser_state_configuration,
-  %Texinfo::Common::default_parser_customization_values,
-);
-
-
-
 # A source information is an hash reference with the keys:
 # line_nr        the line number.
 # file_name      the file name, a binary string.
@@ -590,14 +557,45 @@ foreach my $no_paragraph_context ('math', 'preformatted', 
'rawpreformatted',
 # initialization entry point.  Set up a parser.
 # The last argument, optional, is a hash provided by the user to change
 # the default values for what is present in %parser_settable_configuration.
-sub parser(;$$)
+sub parser(;$)
 {
   my $conf = shift;
 
-  my $parser = dclone(\%parser_settable_configuration);
+  # In Texinfo::Common because all the
+  # customization options information is gathered here, and also
+  # because it is used in other codes, in particular the XS parser.
+  my $parser = dclone(\%Texinfo::Common::parser_settable_configuration);
   bless $parser;
 
-  _setup_conf($parser, $conf);
+  # for get_conf, set for all the configuration keys that are also in
+  # %Texinfo::Common::default_parser_customization_values to the
+  # values set at parser initialization
+  $parser->{'set'} = {};
+  if (defined($conf)) {
+    foreach my $key (keys(%$conf)) {
+      if (exists($Texinfo::Common::parser_settable_configuration{$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};
+        }
+        if ($initialization_overrides{$key}) {
+          $parser->{'set'}->{$key} = $parser->{$key};
+        }
+      } else {
+        warn "ignoring parser configuration value \"$key\"\n";
+      }
+    }
+  }
+
+  $parser->{'conf'} = {};
+  # restrict variables found by get_conf, and set the values to the
+  # parser initialization values only.  What is found in the document
+  # has no effect.
+  foreach my $key 
(keys(%Texinfo::Common::default_parser_customization_values)) {
+    $parser->{'conf'}->{$key} = $parser->{$key};
+  }
 
   # This is not very useful in perl, but mimics the XS parser
   print STDERR "!!!!!!!!!!!!!!!! RESETTING THE PARSER !!!!!!!!!!!!!!!!!!!!!\n"
@@ -1002,40 +1000,6 @@ sub errors($)
   return $registrar->errors();
 }
 
-sub _setup_conf($$)
-{
-  my ($parser, $conf) = @_;
-
-  # for get_conf, set for all the configuration keys that are also in
-  # %Texinfo::Common::default_parser_customization_values to the
-  # values set at parser initialization
-  $parser->{'conf'} = {};
-  $parser->{'set'} = {};
-  if (defined($conf)) {
-    foreach my $key (keys(%$conf)) {
-      if (exists($parser_settable_configuration{$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};
-        }
-        if ($initialization_overrides{$key}) {
-          $parser->{'set'}->{$key} = $parser->{$key};
-        }
-      } else {
-        warn "ignoring parser configuration value \"$key\"\n";
-      }
-    }
-  }
-  # restrict variables found by get_conf, and set the values to the
-  # parser initialization values only.  What is found in the document
-  # has no effect.
-  foreach my $key 
(keys(%Texinfo::Common::default_parser_customization_values)) {
-    $parser->{'conf'}->{$key} = $parser->{$key};
-  }
-}
-
 # Following are the internal parsing subroutines.  The most important are
 #
 # _parse_texi:                main entry point, loop on input lines.
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 5bea49834f..a6bb0f3a3a 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -50,9 +50,6 @@ use Texinfo::Translations;
 # to return a resulting document
 use Texinfo::Document;
 
-my %parser_default_configuration =
-  (%Texinfo::Common::default_parser_customization_values);
-
 sub get_conf($$)
 {
   my $self = shift;
@@ -61,21 +58,23 @@ sub get_conf($$)
 }
 
 # Initialize the parser
-sub parser (;$$)
+sub parser (;$)
 {
   my $conf = shift;
 
-  my $parser = dclone(\%parser_default_configuration);
+  my $parser = dclone(\%Texinfo::Common::parser_settable_configuration);
 
   if (defined($conf)) {
     foreach my $key (keys (%$conf)) {
-      # Copy conf to parser object.
-      # 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};
-      }
+      if (exists($Texinfo::Common::parser_settable_configuration{$key})) {
+        # Copy conf to parser object.
+        # 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};
+        }
+      } # no warning here as in pure Perl as it is warned below
     }
   }
   # restrict variables found by get_conf, and set the values to the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]