[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/NodeNameNormalization.pm (_p
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/NodeNameNormalization.pm (_parse_float_type) (set_float_types), tp/Texinfo/ParserNonXS.pm (_end_line_misc_line) (_end_line_starting_block, _parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (get_parser_info) (_set_errors_node_lists_labels_indices), tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block) (end_line_misc_line), tp/Texinfo/command_data.txt: make float a global commmand. Move normalization of float type out of parsers to NodeNameNormalization.pm for fu [...] |
Date: |
Fri, 23 Dec 2022 11:07:00 -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 ff46fb690a * tp/Texinfo/Convert/NodeNameNormalization.pm
(_parse_float_type) (set_float_types), tp/Texinfo/ParserNonXS.pm
(_end_line_misc_line) (_end_line_starting_block, _parse_texi),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (get_parser_info)
(_set_errors_node_lists_labels_indices), tp/Texinfo/XS/parsetexi/end_line.c
(end_line_starting_block) (end_line_misc_line), tp/Texinfo/command_data.txt:
make float a global commmand. Move normalization of float type out of parsers
to NodeNameNo [...]
ff46fb690a is described below
commit ff46fb690ad8a5324b219d8a35092f3fb1138ce5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 23 17:06:49 2022 +0100
* tp/Texinfo/Convert/NodeNameNormalization.pm (_parse_float_type)
(set_float_types), tp/Texinfo/ParserNonXS.pm (_end_line_misc_line)
(_end_line_starting_block, _parse_texi),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (get_parser_info)
(_set_errors_node_lists_labels_indices),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block)
(end_line_misc_line), tp/Texinfo/command_data.txt: make float a global
commmand. Move normalization of float type out of parsers to
NodeNameNormalization.pm for future normalization using functions
there.
---
ChangeLog | 13 +++++++++
tp/Texinfo/Convert/NodeNameNormalization.pm | 44 +++++++++++++++++++++++++++++
tp/Texinfo/ParserNonXS.pm | 34 ++++++----------------
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 7 +++--
tp/Texinfo/XS/parsetexi/api.c | 2 ++
tp/Texinfo/XS/parsetexi/end_line.c | 14 ++++++++-
tp/Texinfo/command_data.txt | 2 +-
7 files changed, 87 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2fb8c38c51..c3ba68bcac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-12-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/NodeNameNormalization.pm (_parse_float_type)
+ (set_float_types), tp/Texinfo/ParserNonXS.pm (_end_line_misc_line)
+ (_end_line_starting_block, _parse_texi),
+ tp/Texinfo/XS/parsetexi/Parsetexi.pm (get_parser_info)
+ (_set_errors_node_lists_labels_indices),
+ tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block)
+ (end_line_misc_line), tp/Texinfo/command_data.txt: make float a global
+ commmand. Move normalization of float type out of parsers to
+ NodeNameNormalization.pm for future normalization using functions
+ there.
+
2022-12-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/LaTeX.pm: cut at 80 columns better.
diff --git a/tp/Texinfo/Convert/NodeNameNormalization.pm
b/tp/Texinfo/Convert/NodeNameNormalization.pm
index bdf2992ace..5e5d9d38cd 100644
--- a/tp/Texinfo/Convert/NodeNameNormalization.pm
+++ b/tp/Texinfo/Convert/NodeNameNormalization.pm
@@ -400,6 +400,50 @@ sub set_nodes_list_labels($$$)
}
$self->{'labels'} = \%labels;
}
+
+sub _parse_float_type($)
+{
+ my $current = shift;
+ #$current->{'extra'} = {} if (!$current->{'extra'});
+ $current->{'extra'}->{'type'} = {};
+ if ($current->{'args'} and @{$current->{'args'}}
+ and $current->{'args'}->[0]->{'contents'}) {
+ my $normalized
+ = Texinfo::Convert::Texinfo::convert_to_texinfo(
+ {'contents' => $current->{'args'}->[0]->{'contents'}});
+ $current->{'extra'}->{'type'}->{'content'} =
+ $current->{'args'}->[0]->{'contents'};
+ $current->{'extra'}->{'type'}->{'normalized'} = $normalized;
+ return 1;
+ }
+ $current->{'extra'}->{'type'}->{'normalized'} = '';
+ return 0;
+}
+
+# Called from Texinfo::ParserNonXS and Texinfo::XS::parsetexi::Parsetexi.
+# This should be considered an internal function of the parsers for all
+# purposes, it is here to avoid code duplication.
+sub set_float_types
+{
+ my $self = shift;
+
+ my $global_commands = $self->global_commands_information();
+
+ if ($global_commands->{'float'}) {
+ foreach my $current (@{$global_commands->{'float'}}) {
+ my $type = '';
+ _parse_float_type($current);
+ $type = $current->{'extra'}->{'type'}->{'normalized'};
+ push @{$self->{'floats'}->{$type}}, $current;
+ }
+ }
+ if ($global_commands->{'listoffloats'}) {
+ foreach my $current (@{$global_commands->{'listoffloats'}}) {
+ _parse_float_type($current);
+ }
+ }
+}
+
1;
__END__
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index a28bb256fd..9e7344909c 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -135,8 +135,6 @@ my %parser_state_initialization = (
# values are arrays for global multiple
@-commands
# and a value for non multiple global @-commands.
'conditionals_stack' => [], # a stack of conditional commands that are
expanded.
- # 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.
@@ -2571,25 +2569,6 @@ sub _parse_node_manual($)
return $parsed_node_manual;
}
-sub _parse_float_type($)
-{
- my $current = shift;
- #$current->{'extra'} = {} if (!$current->{'extra'});
- $current->{'extra'}->{'type'} = {};
- if ($current->{'args'} and @{$current->{'args'}}
- and $current->{'args'}->[0]->{'contents'}) {
- my $normalized
- = Texinfo::Convert::Texinfo::convert_to_texinfo(
- {'contents' => $current->{'args'}->[0]->{'contents'}});
- $current->{'extra'}->{'type'}->{'content'} =
- $current->{'args'}->[0]->{'contents'};
- $current->{'extra'}->{'type'}->{'normalized'} = $normalized;
- return 1;
- }
- $current->{'extra'}->{'type'}->{'normalized'} = '';
- return 0;
-}
-
# split non-space text elements into strings without [ ] ( ) , and single
# character strings with one of them
sub _split_delimiters
@@ -3124,7 +3103,9 @@ sub _end_line_misc_line($$$)
}
$self->{'current_node'} = $current;
} elsif ($command eq 'listoffloats') {
- _parse_float_type($current);
+ # for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ # good to do in Parser/XS
+ #_parse_float_type($current);
} else {
# Handle all the other 'line' commands. Here just check that they
# have an argument. Empty @top is allowed
@@ -3437,10 +3418,12 @@ sub _end_line_starting_block($$$)
$float_label = _parse_node_manual($current->{'args'}->[1]);
_check_internal_node($self, $float_label, $source_info);
}
+ # for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ # good to do in Parser/XS
+ #_parse_float_type($current);
+ #$type = $current->{'extra'}->{'type'}->{'normalized'};
+ #push @{$self->{'floats'}->{$type}}, $current;
_register_label($self->{'targets'}, $current, $float_label);
- _parse_float_type($current);
- $type = $current->{'extra'}->{'type'}->{'normalized'};
- push @{$self->{'floats'}->{$type}}, $current;
$current->{'extra'}->{'float_section'} = $self->{'current_section'}
if (defined($self->{'current_section'}));
}
@@ -6026,6 +6009,7 @@ sub _parse_texi($$$)
# Setup labels info and nodes list based on 'targets'
Texinfo::Convert::NodeNameNormalization::set_nodes_list_labels($self,
$self->{'registrar'}, $self);
+ Texinfo::Convert::NodeNameNormalization::set_float_types($self);
Texinfo::Translations::complete_indices($self);
return $root;
}
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 25f3672ae1..0dbb27ceeb 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -214,6 +214,7 @@ sub _set_errors_node_lists_labels_indices($)
# Setup labels info and nodes list based on 'targets'
Texinfo::Convert::NodeNameNormalization::set_nodes_list_labels($self,
$self->{'registrar'}, $self);
+ Texinfo::Convert::NodeNameNormalization::set_float_types($self);
my $INDEX_NAMES = build_index_data ();
$self->{'index_names'} = $INDEX_NAMES;
@@ -226,12 +227,14 @@ sub get_parser_info {
my ($INTL_XREFS, $FLOATS, $ERRORS, $GLOBAL_INFO, $GLOBAL_INFO2);
$INTL_XREFS = build_internal_xref_list ();
- $FLOATS = build_float_list ();
+ # done for now in _set_errors_node_lists_labels_indices, could
+ # be redone here when float types are set in the parser
+ #$FLOATS = build_float_list ();
$GLOBAL_INFO = build_global_info ();
$GLOBAL_INFO2 = build_global_info2 ();
$self->{'internal_references'} = $INTL_XREFS;
- $self->{'floats'} = $FLOATS;
+ #$self->{'floats'} = $FLOATS;
$self->{'info'} = $GLOBAL_INFO;
$self->{'commands_info'} = $GLOBAL_INFO2;
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 4f27c156ff..03e5d73fda 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -667,6 +667,8 @@ build_internal_xref_list (void)
}
/* Return hash for list of @float's that appeared in the file. */
+/* not used for now, since the normalization of of float type is done
+ outside of the barser. Could be done here again when possible */
HV *
build_float_list (void)
{
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 28f02de63b..98d0b882f1 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -968,10 +968,14 @@ parse_node_manual (ELEMENT *node)
return result;
}
+/* for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ good to do in Parser/XS */
/* Array of recorded @float's. */
+/*
FLOAT_RECORD *floats_list = 0;
size_t floats_number = 0;
size_t floats_space = 0;
+*/
int
parse_float_type (ELEMENT *current)
@@ -1098,6 +1102,9 @@ end_line_starting_block (ELEMENT *current)
destroy_element (float_label->manual_content);
free (float_label);
}
+ /* for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ good to do in Parser/XS */
+ /*
parse_float_type (current);
k = lookup_extra (current, "type");
if (k)
@@ -1105,7 +1112,9 @@ end_line_starting_block (ELEMENT *current)
eft = (EXTRA_FLOAT_TYPE *) k->value;
type = eft->normalized;
}
+ */
/* add to global 'floats' array */
+ /*
if (floats_number == floats_space)
{
floats_list = realloc (floats_list,
@@ -1113,6 +1122,7 @@ end_line_starting_block (ELEMENT *current)
}
floats_list[floats_number].type = type;
floats_list[floats_number++].element = current;
+ */
if (current_section)
add_extra_element (current, "float_section", current_section);
}
@@ -1740,7 +1750,9 @@ end_line_misc_line (ELEMENT *current)
}
else if (current->cmd == CM_listoffloats)
{
- parse_float_type (current);
+ /* for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ good to do in Parser/XS */
+ /* parse_float_type (current); */
}
else
{
diff --git a/tp/Texinfo/command_data.txt b/tp/Texinfo/command_data.txt
index 7d5346801a..5026d0441a 100644
--- a/tp/Texinfo/command_data.txt
+++ b/tp/Texinfo/command_data.txt
@@ -563,7 +563,7 @@ enumerate
block,close_paragraph,blockitem,contain_simple_text BL
quotation block,close_paragraph,contain_simple_text
BLOCK_quotation 1
smallquotation block,close_paragraph,contain_simple_text
BLOCK_quotation 1
-float block,close_paragraph,contain_simple_text
BLOCK_float 2
+float block,close_paragraph,global,contain_simple_text
BLOCK_float 2
displaymath block,close_paragraph,math BLOCK_math
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/NodeNameNormalization.pm (_parse_float_type) (set_float_types), tp/Texinfo/ParserNonXS.pm (_end_line_misc_line) (_end_line_starting_block, _parse_texi), tp/Texinfo/XS/parsetexi/Parsetexi.pm (get_parser_info) (_set_errors_node_lists_labels_indices), tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block) (end_line_misc_line), tp/Texinfo/command_data.txt: make float a global commmand. Move normalization of float type out of parsers to NodeNameNormalization.pm for fu [...],
Patrice Dumas <=